Equation of line is given by
Y = MX + C
Where M = Slope of a Line and C = Intercept
To Find the slope of a line if (x1, y1) and (x2, y2) are given, M
M = (y2 – y1) / (x2 – x1)
M = (y2 - y1) / (x2 - x1)
Intercept of the line if C is given by
C = y1 - (M) * x1
If the difference between the slope of two lines are ZERO, then there is no intersection. Otherwise to find the intersecting point we have to solve the below euqations
- Y = M1X + C1
- Y = M2X + C2
At intersection point
M1X + C1 = M2X + C2
Therefore
intersection_X = (C2 – C1) / (M1 – M2);
intersection_Y = M1 * intersection_X + C1;