/// <summary>
        /// Computes a segment intersection using homogeneous coordinates.
        /// Round-off error can cause the raw computation to fail,
        /// (usually due to the segments being approximately parallel).
        /// If this happens, a reasonable approximation is computed instead.
        /// </summary>
        private static Coordinate SafeHCoordinateIntersection(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
        {
            Coordinate intPt;

            try
            {
                intPt = HCoordinate.Intersection(p1, p2, q1, q2);
            }
            catch (NotRepresentableException e)
            {
                intPt = CentralEndpointIntersector.GetIntersection(p1, p2, q1, q2);
            }
            return(intPt);
        }
Example #2
0
        /// <summary>
        /// Computes a segment intersection using homogeneous coordinates.
        /// Round-off error can cause the raw computation to fail,
        /// (usually due to the segments being approximately parallel).
        /// If this happens, a reasonable approximation is computed instead.
        /// </summary>
        private static Coordinate SafeHCoordinateIntersection(Coordinate p1, Coordinate p2, Coordinate q1, Coordinate q2)
        {
            Coordinate intPt;

            try
            {
                intPt = HCoordinate.Intersection(p1, p2, q1, q2);
            }
            catch (NotRepresentableException e)
            {
                // compute an approximate result
                // intPt = CentralEndpointIntersector.GetIntersection(p1, p2, q1, q2);
                intPt = NearestEndpoint(p1, p2, q1, q2);
            }
            return(intPt);
        }