FromPoints() public static method

Creates a Line that goes through the two specified points.
Thrown if the two points are the same.
public static FromPoints ( Point point1, Point point2 ) : Line
point1 Point One point on the line.
point2 Point Another point on the line.
return Line
Example #1
0
        private static ConvexityDefect extractDefect(List <IntPoint> contour, int startIndex, int endIndex)
        {
            // Navigate the contour until the next point of the convex hull,
            //  taking note of the distance between the current contour point
            //  and the line connecting the two consecutive convex hull points

            IntPoint start = contour[startIndex];
            IntPoint end   = contour[endIndex];
            Line     line  = Line.FromPoints(start, end);

            double maxDepth = 0;
            int    maxIndex = 0;

            for (int i = startIndex; i < endIndex; i++)
            {
                double d = line.DistanceToPoint(contour[i]);

                if (d > maxDepth)
                {
                    maxDepth = d;
                    maxIndex = i;
                }
            }

            return(new ConvexityDefect(maxIndex, startIndex, endIndex, maxDepth));
        }
Example #2
0
        /// <summary>
        /// Calculate minimum angle between two lines measured in [0, 90] degrees range.
        /// </summary>
        ///
        /// <param name="a1">A point on the first line.</param>
        /// <param name="a2">Another point on the first line.</param>
        /// <param name="b1">A point on the second line.</param>
        /// <param name="b2">Another point on the second line.</param>
        ///
        /// <returns>Returns minimum angle between two lines.</returns>
        ///
        /// <remarks><para><note>It is preferred to use <see cref="Line.GetAngleBetweenLines"/> if it is required to calculate angle
        /// multiple times for one of the lines.</note></para></remarks>
        ///
        /// <exception cref="ArgumentException"><paramref name="a1"/> and <paramref name="a2"/> are the same,
        /// -OR- <paramref name="b1"/> and <paramref name="b2"/> are the same.</exception>
        ///
        public static float GetAngleBetweenLines(Point a1, Point a2, Point b1, Point b2)
        {
            Line line1 = Line.FromPoints(a1, a2);

            return(line1.GetAngleBetweenLines(Line.FromPoints(b1, b2)));
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LineSegment"/> class.
 /// </summary>
 ///
 /// <param name="start">Segment's start point.</param>
 /// <param name="end">Segment's end point.</param>
 ///
 /// <exception cref="ArgumentException">Thrown if the two points are the same.</exception>
 ///
 public LineSegment(Point start, Point end)
 {
     line       = Line.FromPoints(start, end);
     this.start = start;
     this.end   = end;
 }