Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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: http://i.stack.imgur.com/lxX9l.png). I am pretty sure i have followed the answer given correctly....

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

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). $$

share|improve this answer
    
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.stack.imgur.com/lxX9l.png to demonstrate. –  fiscme Jan 16 '13 at 13:51
    
You should check $v$: if $u = (a,b)$ then take $v=(b, -a)$. –  Siméon Jan 16 '13 at 13:56
    
you sir, are both a scholar and a gentleman.. thank you. –  fiscme Jan 16 '13 at 15:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.