Beispiel #1
0
 public void set(GE_Point ptCenter, GE_Point ptStart, GE_Point ptEnd)
 {
     m_StartPoint  = new GE_Point(ptStart.X, ptStart.Y);
     m_EndPoint    = new GE_Point(ptEnd.X, ptEnd.Y);
     m_CenterPoint = new GE_Point(ptCenter.X, ptCenter.Y);
     m_Radiu       = m_CenterPoint.distanceTo(m_StartPoint);
     m_Kind        = 1;
 }
Beispiel #2
0
        //圆心ptCen,点p1到p2的弧长(逆时针,半径为ptCen到p1的距离)
        static public double GetArcLengthByPoint(GE_Point ptCen, GE_Point p1, GE_Point p2)
        {
            double dRad, dAng1, dAng2;

            dRad  = ptCen.distanceTo(p1);
            dAng1 = GetAngleByPoint(ptCen, p1);
            dAng2 = GetAngleByPoint(ptCen, p2);
            dAng1 = Mid_angle(dAng1, dAng2);
            return(dRad * dAng1);
        }
Beispiel #3
0
        public double Length()
        {
            double dRet = 0;

            if (m_Kind == 0)
            {
                dRet = m_StartPoint.distanceTo(m_EndPoint);
            }
            else
            {
                dRet = Geo.GetArcLengthByPoint(m_CenterPoint, m_StartPoint, m_EndPoint);
            }
            return(dRet);
        }
Beispiel #4
0
        public double distanceTo(GE_Point pt)
        {
            GE_Point ptPerp = PerpendPoint(pt);

            return(pt.distanceTo(ptPerp));
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="lin"></param>
        /// <param name="ptInt1"></param>
        /// <param name="ptInt2"></param>
        /// <returns></returns>
        public int intersectWith(GE_Line lin, out GE_Point ptInt1, out GE_Point ptInt2)
        {
            int nRet = 0;

            ptInt1 = new GE_Point(0, 0);
            ptInt2 = new GE_Point(0, 0);
            double A, B, a, b, c, d, P, Q, AA, BB, CC, X1, X2, Y1, Y2;

            double u;

            if (m_Kind == 0 && lin.m_Kind == 0)
            {
                PointF point1 = new PointF((float)m_StartPoint.X, (float)m_StartPoint.Y);
                PointF point2 = new PointF((float)m_EndPoint.X, (float)m_EndPoint.Y);
                PointF point3 = new PointF((float)lin.m_StartPoint.X, (float)lin.m_StartPoint.Y);
                PointF point4 = new PointF((float)lin.m_EndPoint.X, (float)lin.m_EndPoint.Y);

                PointF pointResult;
                if (GetIntersection(point1, point2, point3, point4, out pointResult))
                {
                    ptInt1.X = pointResult.X;
                    ptInt1.Y = pointResult.Y;
                    nRet     = 1;
                }


                //double x11, y11, x12, y12, x21, y21, x22, y22;

                //x11 = m_StartPoint.X;
                //y11 = m_StartPoint.Y;
                //x12 = m_EndPoint.X;
                //y12 = m_EndPoint.Y;
                //x21 = lin.m_StartPoint.X;
                //y21 = lin.m_StartPoint.Y;
                //x22 = lin.m_EndPoint.X;
                //y22 = lin.m_EndPoint.Y;

                //u = (x11 - x21) / ((x22 - x21) - (x12 - x11));
                //ptInt1.X = x11 + u * (x12 - x11);
                //ptInt1.Y = y11 + u * (y12 - y11);
                //nRet = 1;
            }
            else if (m_Kind == 1 && lin.m_Kind == 1)
            {
                A = m_CenterPoint.distanceTo(m_StartPoint);
                B = lin.m_CenterPoint.distanceTo(lin.m_StartPoint);
                a = m_CenterPoint.X;
                b = m_CenterPoint.Y;
                c = lin.m_CenterPoint.X;
                d = lin.m_CenterPoint.Y;

                P  = ((A * A - B * B) - (a * a + b * b - c * c - d * d)) / (2 * d - 2 * b);
                Q  = (c - a) / (d - b);
                AA = 1 + Q * Q;
                BB = 2 * b * Q - 2 * P * Q - 2 * a;
                CC = P * P - 2 * b * P - A * A + a * a + b * b;
                if (BB * BB - 4 * AA * CC > 0)
                {
                    X1       = (BB * -1 + Math.Sqrt(BB * BB - 4 * AA * CC)) / (2 * AA);
                    X2       = (BB * -1 - Math.Sqrt(BB * BB - 4 * AA * CC)) / (2 * AA);
                    Y1       = P - Q * X1;
                    Y2       = P - Q * X2;
                    ptInt1.X = X1; ptInt1.Y = Y1;
                    ptInt2.X = X2; ptInt2.Y = Y2;
                    nRet     = 2;
                }
                else
                {
                    nRet = 0;
                }
            }

            return(nRet);
        }