Home > Archive > AWK > September 2006 > calculating endpoint using angle & distance
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
calculating endpoint using angle & distance
|
|
| durant 2006-09-21, 6:56 pm |
| i am trying to calculate a midpoint between two paris
of XY values, from the midpoint i want to calculate a
new XY that is 90 degrees and 300 feet from the
midpoint.
i am using gawk and i can calculate atan2 value for
the two pair of XY's and the midpoint, but i am
getting stumped when i am adding 90 degrees (1.57
radians) and then trying to calculate the new XY at
the end of the rotate "line".
any chance you could help me with this?
here is a sample input.
x1 = 0
y1 = 0
x2 = 1000
y2 = 1000
i am looking for x3 & y3 which will be 300 feet at 90 degrees from the
midpoint between x1y1 & x2y2.
thank you for your time,
durant
| |
| Beau Nanaz 2006-09-21, 6:56 pm |
| What does this have to do with awk? It is a coordinate geometry
problem. I'll staqrt you off.
The midpoint between (x1, y1) and (x2, y2) is at ((x1+x2)/2),
(y1+y2)/2).
Call this (xm, ym)
The slope of the line between these points is ((y2-y1) / (x2-x1))
A line at 90% from *any* point on the above line has a slope of
((x1-x2) / (y2-y1)), the negative reciprocal of the slope of the given
line.
So what you are looking for is a point L units (in this case, 300) from
the midpoint with that second slope. The rest of the problem is basic,
9th grade trig, combined with parallel lines and laternate-interior
angles. Which I'm not going to delve into in this awk newsgroup.
Beau N.
durant wrote:
> i am trying to calculate a midpoint between two paris
> of XY values, from the midpoint i want to calculate a
> new XY that is 90 degrees and 300 feet from the
> midpoint.
>
> i am using gawk and i can calculate atan2 value for
> the two pair of XY's and the midpoint, but i am
> getting stumped when i am adding 90 degrees (1.57
> radians) and then trying to calculate the new XY at
> the end of the rotate "line".
>
> any chance you could help me with this?
>
> here is a sample input.
>
> x1 = 0
> y1 = 0
> x2 = 1000
> y2 = 1000
>
> i am looking for x3 & y3 which will be 300 feet at 90 degrees from the
> midpoint between x1y1 & x2y2.
>
> thank you for your time,
> durant
|
|
|
|
|