I have two Line objects in C# WPF, and I’m trying to construct a method to work out the coordinates at which the lines intersect (if at all). After giving myself a headache reminding myself of high school maths to do this, I can’t work out how to map it into programming format – anyone know how to do this?
Thanks very much,
Becky
I suppose your line objects are made up of two points. What you should do is get the equations of both lines.
Then you should solve the following equation:
equation-line1 = equation-line2
Calculate slope of a line:
p1 = Point 1 of your line
p2 = Point 2 of your line
Equation of a line:
y = ax + b
a = the slope you calculated
b = the intersect
Solving the equation:
vars:
So, x and y are the coordinates of the point where the two lines intersect