Jump to content
  • Advertisement
Sign in to follow this  
Exchange

Variable Y location in the Cartesian Plane

This topic is 3884 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

Suppose you have two points with (x1, y1) and (x2 and y2). Y2 is unknown but all the rest are known. You also have the length of the line between these two points. How am I supposed to calculate y2? I tried the length formula L = Sqrt ( (x2-x2)^2 + (y2-y1)^2 ) but I couldn't find y2. I'd appreciate it if somebody could please help me with this.

Share this post


Link to post
Share on other sites
Advertisement
You first want to square both sides to get rid of the square root. Then you expand the binomials. You'll get a rather long expression, but since only y2 is a variable, a lot of them are constants and can be combined. You're left with a quadratic equation in terms of y2, which you can solve using the quadratic formula.

Share this post


Link to post
Share on other sites
And you'll likely end up with two answers or none at all.

Visually, the three coordinates define a point and a vertical line. If the horizontal distance between these two is strictly bigger than L, then obviously no answer may exist. Conversely, if it's strictly smaller than L then two such lines will exist (mirror-images of each other about this connecting horizontal line). Only in the degenerate case where |x1 - x2| = L does a unique answer exist.

Admiral

Share this post


Link to post
Share on other sites
Thank you guys for your help. The farthest I could go with this equation is this:

http://img266.imageshack.us/my.php?image=formulaor1.png

I am ending up with a quadratic equation. I try to simplify the equation by moving the variables to one side and others to the other side. However, I am ending up with two y2 variables while in fact I have to end up with one only. I would appreciate it if somebody could help me simplify this equation further.

Share this post


Link to post
Share on other sites
(x2 - x1)^2 + (y2 - y1)^2 = L^2

After expanding the second term:

y2^2 - 2y1y2 + y1^2 + (x2 - x1)^2 - L^2 = 0

So:

for polynomial:

ax^2 + bx + c = 0

Here we have:

a = 1
b = -2y1
c = y1^2 + (x2 - x1)^2 - L^2

delta = b^2 - 4ac

No you have two solutions:

y2 = (-b - sqrt(delta)) / 2a or
y2 = (-b + sqrt(delta)) / 2a

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!