3
$\begingroup$

I want to create a rectangular polygon using two points as guides.

So let's say a journey starts in Egypt and ends in London, my polygon should have 4 points:

  • 10 miles further from London than Egypt is, following the line between them (roughly south in this example).
  • Halfway between the two cities but 50 miles at right angles from the line that joins them.
  • Like the above point but 50 miles in the other direction.
  • 20 miles further from Egypt than London is, following the line between them (roughly north in this example).

I'll end up with a rough diamond shaped polygon that would completely contain the straight line journey from Egypt to London.

I hope this makes sense; any help for how I can calculate the 4 points is appreciated.

enter image description here

I have also asked this on gis.stackexchange.com but as I only need 2D and the fact that its map coordinates is irrelevant. I thought I would ask it here as well.

EDIT:

Thanks to Ju'x i have come a long way, but the outer points dont seem to be at 90 degrees to the mid point (image here: https://i.sstatic.net/lxX9l.png). I am pretty sure i have followed the answer given correctly....

$\endgroup$

1 Answer 1

2
$\begingroup$

Let's say $L$ with coordinates $(x_L;y_L)$ stands for London, and $C$ with coordinates $(x_C; y_C)$ stands for Cairo (Egypt is hardly a point on a map). I will assume that the coordinates are expressed in miles, so that (for example) $$ LC = \sqrt{(x_C-x_L)^2 + (y_L - y_c)^2} $$ is the distance between London and Cairo in miles.

The unit vector $u = \dfrac{\overrightarrow{LC}}{\left\|\overrightarrow{LC}\right\|}$ has coordinates $\left(\dfrac{x_C-x_L}{LC},\dfrac{y_C-y_L}{LC}\right) = \left(x_u,y_u\right)$.

The two extremal points of your polygon are $C' = C + 10u$ and $L' = L - 20u$ : $$ C' = \left(x_C + 10x_u,y_c + 10y_u\right)\qquad L' = \left(x_L - 20x_u, y_L - 20y_u\right) $$

The midpoint $M$ has coordinates $(x_M,y_M)=\left(\dfrac{x_C+x_L}{2},\dfrac{y_C+y_L}{2}\right)$, and an orthogonal vector to $u$ is the unit vector $v$ with coordinates $(x_v,y_v) = (y_u, -x_u)$. The two lateral points of your polygon are $A = M + 50v$ and $B = M - 50v$ : $$ A = \left(x_M + 50x_v, y_M + 50 y_v\right),\qquad B = \left(x_M - 50x_v, y_M - 50y_v\right). $$

$\endgroup$
4
  • $\begingroup$ Thanks so much, i dont seem to be creating the 2 lateral points correctly though, i have added a new image link above and here i.sstatic.net/lxX9l.png to demonstrate. $\endgroup$ Commented Jan 16, 2013 at 13:51
  • $\begingroup$ You should check $v$: if $u = (a,b)$ then take $v=(b, -a)$. $\endgroup$ Commented Jan 16, 2013 at 13:56
  • $\begingroup$ you sir, are both a scholar and a gentleman.. thank you. $\endgroup$ Commented Jan 16, 2013 at 15:42
  • $\begingroup$ @Siméon maybe you can help me with this question: math.stackexchange.com/questions/1548841/… $\endgroup$ Commented Nov 27, 2015 at 16:38

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.