Exemplo n.º 1
0
        /// <summary>
        /// Determines whether [is any point on segment and not ends] [the specified polyline].
        /// </summary>
        /// <param name="polyline">The polyline.</param>
        /// <returns><c>true</c> if [is any point on segment and not ends] [the specified polyline]; otherwise, <c>false</c>.</returns>
        public static bool IsJoiningPointOnAnotherSegment(PolyLine polyline)
        {
            CartesianCoordinate firstPoint = polyline.FirstPoint();
            CartesianCoordinate lastPoint  = polyline.LastPoint();

            for (int i = 1; i < polyline.CountSegments - 1; i++)
            {   // Loop is skipping first and last segments
                if (polyline[i] is LineSegment)
                {
                    LineSegment segment = (LineSegment)polyline[i];
                    if ((segment.IncludesCoordinate(firstPoint) &&
                         !PointIntersection.IsOnPoint(firstPoint, segment.I) &&
                         !PointIntersection.IsOnPoint(firstPoint, segment.J)) ||
                        (segment.IncludesCoordinate(lastPoint) &&
                         !PointIntersection.IsOnPoint(lastPoint, segment.I) &&
                         !PointIntersection.IsOnPoint(lastPoint, segment.J)))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        [TestCase(1, -2, 1, -2, ExpectedResult = true)]      // On
        public static bool IsOnPoint(double x, double y, double x1, double y1)
        {
            CartesianCoordinate point = new CartesianCoordinate(x1, y1);

            return(PointIntersection.IsOnPoint(point, new CartesianCoordinate(x, y)));
        }