Exemple #1
0
        public double GetDistanceTo(Point point)
        {
            if (A.Equals(B))
            {
                return(A.GetDistanceTo(point));
            }

            var a = A - point;
            var b = B - point;

            double aa, bb, cc;

            Geom.GetABC(a, b, out aa, out bb, out cc);

            if (Geom.Sign((a.Y + bb) * aa - (a.X + aa) * bb) * Geom.Sign((b.Y + bb) * aa - (b.X + aa) * bb) <= 0)
            {
                return(Math.Abs(cc / Math.Sqrt(aa * aa + bb * bb)));
            }
            return(Math.Min(a.Length, b.Length));
        }