AForge.Math.Geometry.LineSegment.DistanceToPoint C# (CSharp) Method

DistanceToPoint() public method

Calculate Euclidean distance between a point and a finite line segment.
public DistanceToPoint ( DoublePoint point ) : double
point DoublePoint The point to calculate the distance to.
return double
        public double DistanceToPoint( DoublePoint point )
        {
            double segmentDistance;

            switch ( LocateProjection( point ) )
            {
                case ProjectionLocation.RayA:
                    segmentDistance = point.DistanceTo( start );
                    break;
                case ProjectionLocation.RayB:
                    segmentDistance = point.DistanceTo( end );
                    break;
                default:
                    segmentDistance = line.DistanceToPoint( point );
                    break;
            };

            return segmentDistance;
        }