Two Lines Calculator (2D)

This tool calculates two Lines relative position in a space of dimension 2 : intersection point, distance between the two lines and angle formed by them.



We suppose that L1 and L2 are two lines in 2d space with the following equations,

`L_1 : a_1 x + b_1 y + c_1 = 0`

`L_2 : a_2 x + b_2 y + c_2 = 0`

Angle between two lines

We denote `theta` the angle between the two above lines, then we have the following formula,

`tan(theta) = (a_1*b_2-a_2*b_1)/(a_1*a_2+b_1*b_2)`

Intersection of two lines

The lines L1 and L2 are secant lines under this condition,

`a_1*b_2-a_2*b_1 != 0`

If `a_1*b_2-a_2*b_1 = 0`, then they are either parallel or coincident lines.

The coordinates of the intersection point I(x0 , y0) are calculated with the following formulas :

`x_0=(b_1*c_2-b_2*c_1)/(a_1*b_2-a_2*b_1)`

`y_0=(a_2*c_1-a_1*c_2)/(a_1*b_2-a_2*b_1);`

Distance between two parallel lines

We suppose that lines L1 and L2 (defined above) are parallel then, they have the same slope m and their equations can be written in this form :

`L_1 : y = m x + c_1`

`L_2 : y = m x + c_2`

The distance between these two lines is equal to,

`d = |c_2-c_1|/sqrt(1+m^2)`

See also

Line Calculator
Coordinate Geometry calculators
Geometry calculators
Mathematics calculators