Finding intersection point of two lines on "extending the lines" till they intersect

1398
2
04-21-2014 10:41 PM
Occasional Contributor
Hi All,

Could any one please direct me on finding an intersection point of two polyline objects by extending them till they intersect, using ArcObjects (its not 3D). The two input polylines initially do not intersect. Need to identify the point where they intersect when their ToPoint 's are extended.

Thanks in advance!

With Regards,
Vara Prasad.
Reply
0 Kudos
2 Replies
Occasional Contributor III
Based on This Post you can get the approximate intersection point of two lines.

 
 
        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;
        }


Regards,
Reply
0 Kudos
Occasional Contributor II
I think there are some existing  ArcObjects methods might be useful to you.

IConstructCurve.ConstructExtended
http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#//002m000000t6000000

IConstructLine.ConstructExtended
http://resources.arcgis.com/en/help/arcobjects-net/componenthelp/index.html#/ConstructExtended_Metho...
Reply
0 Kudos