public IPoint GetLinesIntersection(IPoint line1P1, IPoint line1P2, IPoint line2P1, IPoint line2P2) { //Line 1 (p1, p2) var A1 = line1P2.Y - line1P1.Y; var B1 = line1P1.X - line1P2.X; var C1 = A1 * line1P1.X + B1 * line1P1.Y; //Line 2 (p3, p4) var A2 = line2P2.Y - line2P1.Y; var B2 = line2P1.X - line2P2.X; var C2 = A2 * line2P1.X + B2 * line2P1.Y; var determinate = A1 * B2 - A2 * B1; IPoint intersectionPoint; if (determinate != 0) { double x = (B2 * C1 - B1 * C2) / determinate; double y = (A1 * C2 - A2 * C1) / determinate; intersectionPoint = new Point(); intersectionPoint.X = x; intersectionPoint.Y = y; } else //lines are parrallel intersectionPoint = null; return intersectionPoint; }
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.