Esempio n. 1
0
        public bool Contains(GePoint point)
        {
            if (null == point) return false;

            GeLine Line = new GeLine(m_StartPoint, m_EndPoint);
            if (null == Line) return false;

            GePoint ClosestPoint = Line.ClosestPointTo(point);
            if (null == ClosestPoint || !ClosestPoint.IsEqualTo(point))
                return false;

            Vector C2S = new Vector(ClosestPoint, m_StartPoint);
            Vector C2E = new Vector(ClosestPoint, m_EndPoint);

            double angle = C2S.AngleTo(C2E);
            //bool bRet = C2S.AngleTo(C2E);

            if ( MathUtil.IsTwoDoubleEqual(angle
                , MathUtil.PI))
            {
                return true;
            }

            return false;
        }
Esempio n. 2
0
        public GePoint ClosestPointTo(GePoint point)
        {
            if (null == point) return null;

            GeLine Line = new GeLine(m_StartPoint, m_EndPoint);

            GePoint ClosePoint = Line.ClosestPointTo(point);

            if(Contains(ClosePoint))
            {
                return ClosePoint;
            }
            else
            {
                double P2S = point.DistanceTo(m_StartPoint);
                double P2E = point.DistanceTo(m_EndPoint);

                if (P2S < P2E)
                    return (GePoint)m_StartPoint.Clone();
                else
                    return (GePoint)m_EndPoint.Clone();
            }
        }