Jump to content
  • Advertisement


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


the math challenge

This topic is 6359 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 2 2d line equations in general form (Ax+By+C=0) and I would like to find the point of intersection (if any). How can I do this? I started to write it out on paper and gave up because I would have had to simplify a huge equation. I know there is a simple solution, so if you are man(or women) enough to take the math challenge, please post what you think is the quickest solution. Pseudo

Share this post

Link to post
Share on other sites
Lets say we have two lines:

y = mx + b

y = 3x + 3
y = 4x + 1

To find the point of intersection we arrange them like this:

x + y = b

-3x + y = 3
-4x + y = 1

This is a systems of equation. What we have to do is have either the x or the y on the top and bottom being the inverse value. So lets use the x:

12x - 4y = -12
-12x + 3y = 3

All I did was multiply the top by - 3, and the bottom by + 3. This gives us an equation we can solve. We now cross of the zeroing xs, add the ys and add the ending term:

0x - 1y = -9
-1y = -9
y = 9

Now to find the x point, we take a line and substitute in for y and solve for x.

9 = 3x + 3
6 = 3x
2 = x

(2, 9) is the point of intersection for the two lines defined by: y = 3x + 3, y = 4x + 1. Hope this helped. I did this based on memory so I''m not sure if it is all entirely correct.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster

I''d rewrite each formula so that a single variable (x or y) was on one side. I will pick y:

Ax + By + C = 0
By = -Ax - C
y = -Ax/B - C/B (y=mx+b format)

Do that for each line, then set the y of one line = to the y of the other line, so you will get something like:

4x + 5 = 5x + 3

Then solve for x:

5 - 3 = 5x - 4x

2 = x

Share this post

Link to post
Share on other sites
Yeah, those are the two easiest ways to do it. If you have more than 2 equations, the same thing goes, only for n equations, you must have n variables to solve.

Got Slack?
Commander M

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!