Accord.Math.Geometry.Line.FromPoints C# (CSharp) Method

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
        public static Line FromPoints(Point point1, Point point2)
        {
            return new Line(point1, point2);
        }

Usage Example

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));
        }
All Usage Examples Of Accord.Math.Geometry.Line::FromPoints