mimicocotopus
mimicocotopus

Reputation: 5610

How can I find the intersection of two lines in general equation form?

If I have six variables representing two lines in general equation form (ax + by + c = 0). So for example:

ax + by + c = 0
jx + ky + l = 0

How can I find the intersection point's (x and y) [assuming there is one] from the six variables?

PS. Any recommendation of a good source for information on very simply computational geometry, like this, would be appreciated.

Upvotes: 2

Views: 5652

Answers (1)

Petar Ivanov
Petar Ivanov

Reputation: 93080

The intersection point satisfies both equations. So all you need is to solve them simultaneously:

ax + by + c = 0    (*j)
jx + ky + l = 0    (*a)

ajx + bjy + cj = 0   (-)
ajx + aky + al = 0

(bj-ak)y + cj - al = 0

y = (al-cj) / (bj-ak)

And similarly for x. (Or you can substitute the found value for y in any of the original equations and then find x):

x = (ck-bl) / (bj-ak)

Upvotes: 12

Related Questions