Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kevinheeney

Math Problem - Finding X2 & Y2 coordinate

This topic is 5740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a problem. I am trying to find the coordinates of a point along a line at a given distance from a given point on the same line. What I mean is I have X1, X2, slope and distance, and I want to find the point (X2,Y2) that would be that distance from X1, X2 at that slope. I tried combining the distance formula: Sqr((X1 - X2) ^ 2 + (Y1 - Y2) ^ 2) And the slope formula: (Y2 - Y1) / (X2-X1) = m to (Y2-Y1) = (X2-X1)m by substituting the Y''s To get this: (X2-X1)2 + ((X2-X1)m)2 = distance2 The problem is that I have the value of M(slope) and the distance, as well as X1, X2. So If I was manually doing the math, I would have enough variables to figure it out. However, I am trying to throw this into VBasic, so I will need to have the X2 (the unknown) separated from the the rest of the formula. Is there a way for me to do this? Also, I am aware that there will be two points at a given distance from the original point depending on the direction of the line, but I am not worried about that yet.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
X2^2 - 2*X2*X1 + X1^2 - distance^2/(1+m) = 0

Share this post


Link to post
Share on other sites
The answer is much simpler than what you are trying to do. You just need to remember about Thales law.
Reminder:
the equation of a line is expressed under the form: y = ax + b, where a is the slope.
the distance between two points A(x1,y1) and B(x2,y2) is: d=sqrt( (x2-x1)^2 + (y2-y1)^2)
Thales law: if several parallels intersect two straightlines, they''ll determine proportional segments.

OK, let''s start to find the equation giving us the coordinates of point C(x3,y3) knowing distance d and the point A(x1,y1):

the elementary distance when you increment your x variable by 1 is equal to:
delem = sqrt (1 + a^2) since (x2-x1) = 1 and (y2-y1) = slope.

now using Thales law, you can say that
delem / d = 1 / (x3 - x1) or d / delem = (x3 - x1) / 1 which is strictly equivalent.

thus you find that x3 = x1 + (d / delem)

To derive the y3 value, you just use your line equation: y3 = ax3 + b.

Hope that helps.
Ghostly yours,
Red.

Share this post


Link to post
Share on other sites
quote:
Original post by kevinheeney
What is delem?


d-elem = distance elementary = elementary distance

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!