). Recently, I asked you how to find the "Intersection of 2 Lines in 2D" and the answers revolved around the Determinants ( http://en.wikipedia.org/wiki/Line-line_intersection ) or Systems ( Intersection Of Two Lines In 2D ).
Now, based on what I learned here from Isaac about how to get the General Form Linear Equation from 2 points ( How to obtain Line Equation of the form ax + bx + c = 0 ), isn't it simpler to find the intersection like this?
Where x1 to x4 and y1 to y4 are the 4 points defining the 2 lines.
//First line's Equation. var a: Number = y1 - y2; var b: Number = x2 - x1; var c: Number = (y2 - y1) * x1 - (x2 - x1) * y1; //Second line's Equation. var d: Number = y3 - y4; var e: Number = x4 - x3; var f: Number = (y4 - y3) * x3 - (x4 - x3) * y3; //Below formulas obtained via System. intersection.y = (c*d - f*a) / (-d*b + a*e); intersection.x = (-b * intersection.y - c) / a;
It seems to me to be less mathematical operations here compared to the determinants solution. Does this method seem ok to you, mathematically speaking? I like that it's slope-independent (vertical lines result in useless checks in those cases).