Esempio n. 1
0
        /// <summary>
        /// Tests whether a triangular ring would be eroded completely by the given
        /// buffer distance.
        /// This is a precise test.  It uses the fact that the inner buffer of a
        /// triangle converges on the inCentre of the triangle (the point
        /// equidistant from all sides).  If the buffer distance is greater than the
        /// distance of the inCentre from a side, the triangle will be eroded completely.
        /// This test is important, since it removes a problematic case where
        /// the buffer distance is slightly larger than the inCentre distance.
        /// In this case the triangle buffer curve "inverts" with incorrect topology,
        /// producing an incorrect hole in the buffer.
        /// </summary>
        /// <param name="triangleCoord"></param>
        /// <param name="bufferDistance"></param>
        /// <returns></returns>
        private bool IsTriangleErodedCompletely(IList <Coordinate> triangleCoord, double bufferDistance)
        {
            Triangle   tri          = new Triangle(triangleCoord[0], triangleCoord[1], triangleCoord[2]);
            Coordinate inCentre     = tri.InCentre;
            double     distToCentre = CgAlgorithms.DistancePointLine(inCentre, tri.P0, tri.P1);

            return(distToCentre < Math.Abs(bufferDistance));
        }
Esempio n. 2
0
 /// <summary>
 /// Computes the distance between this line segment and a point.
 /// </summary>
 public virtual double Distance(Coordinate p)
 {
     return(CgAlgorithms.DistancePointLine(new Coordinate(p), P0, P1));
 }