Пример #1
0
        /// <summary>
        /// 计算赤平投影中,面投影圆弧的圆心(设定大圆圆心为600,600半径480,上半球投影)
        /// </summary>
        /// <param name="trend">面倾向</param>
        /// <param name="dip">面倾角</param>
        /// <returns>返回圆弧圆心点</returns>
        public Circle CalArc(double trend, double dip)
        {
            TdPoint P1 = new TdPoint();
            TdPoint P2 = new TdPoint();
            TdPoint Ps = new TdPoint();

            P1.X = (600 + 480 * Math.Sin((trend + 90) * 3.14 / 180));
            P1.Y = (600 - 480 * Math.Cos((trend + 90) * 3.14 / 180));
            P2.X = (600 + 480 * Math.Sin((trend - 90) * 3.14 / 180));
            P2.Y = (600 - 480 * Math.Cos((trend - 90) * 3.14 / 180));
            Ps.X = (600 + 480 * Math.Sin((trend + 180) * 3.14 / 180) * (1 - dip / 90.0));
            Ps.Y = (600 - 480 * Math.Cos((trend + 180) * 3.14 / 180) * (1 - dip / 90.0));

            TdLine  l1   = CalMidLine(P1, Ps);
            TdLine  l2   = CalMidLine(P2, Ps);
            TdPoint Pc   = CalIPoint(l1, l2);
            double  dist = Distance(Pc, P1);

            Circle c = new Circle();

            c.X = Pc.X;
            c.Y = Pc.Y;
            c.R = dist;
            return(c);
        }
Пример #2
0
        /// <summary>
        /// 计算量直线交点
        /// </summary>
        /// <param name="L1">直线1</param>
        /// <param name="L2">直线2</param>
        /// <returns>返回交点</returns>
        public TdPoint CalIPoint(TdLine L1, TdLine L2)
        {
            TdPoint p = new TdPoint();

            if (L1.C == 1 && L2.C == 1)//两直线都有有斜率
            {
                p.X = (L1.B - L2.B) / (L2.A - L1.A);
                p.Y = (L1.B * L2.A - L2.B * L1.A) / (L2.A - L1.A);
            }
            else
            {
                if (L1.C == 0)
                {
                    p.X = -L1.B;
                    p.Y = L2.A * p.X + L2.B;
                }
                else
                {
                    if (L2.C == 0)
                    {
                        p.X = -L2.B;
                        p.Y = L1.A * p.X + L1.B;
                    }
                }
            }
            return(p);
        }
Пример #3
0
        /// <summary>
        /// 计算中垂线参数
        /// </summary>
        /// <param name="P1">点1</param>
        /// <param name="P2">点2</param>
        /// <returns>返回中垂线参数</returns>
        public TdLine CalMidLine(TdPoint P1, TdPoint P2)
        {
            TdLine line = new TdLine(); //返回的中垂线

            TdLine L = new TdLine();    //两点所在直线

            if (P1.X != P2.X)
            {
                L.A = (P2.Y - P1.Y) / (P2.X - P1.X);
                L.C = 1;
                L.B = P1.Y - L.A * P1.X;
            }
            else
            {
                L.A = 1;
                L.C = 0;
                L.B = -P1.X;
            }

            TdPoint MidPoint = new TdPoint();//两点的中点

            MidPoint.X = (P2.X + P1.X) / 2;
            MidPoint.Y = (P2.Y + P1.Y) / 2;

            if (L.C == 1)     //直线有斜率
            {
                if (L.A != 0) //斜率不为0
                {
                    line.A = -1 / L.A;
                    line.B = MidPoint.Y - line.A * MidPoint.X;
                    line.C = 1;
                }
                else
                {
                    line.C = 0;
                    line.A = 1;
                    line.B = -MidPoint.X;
                }
            }
            else
            {
                line.C = 1;
                line.A = 0;
                line.B = MidPoint.Y;
            }
            return(line);
        }
Пример #4
0
        /// <summary>
        /// 计算直线参数
        /// </summary>
        /// <param name="P1">点1</param>
        /// <param name="P2">点2</param>
        /// <returns>返回直线参数</returns>
        public TdLine CalLine(TdPoint P1, TdPoint P2)
        {
            TdLine L = new TdLine();

            if (P1.X != P2.X)
            {
                L.A = (P2.Y - P1.Y) / (P2.X - P1.X);
                L.C = 1;
                L.B = P1.Y - L.A * P1.X;
            }
            else
            {
                L.A = 1;
                L.C = 0;
                L.B = -P1.X;
            }
            return(L);
        }
Пример #5
0
        /// <summary>
        /// 计算直线参数
        /// </summary>
        /// <param name="X1"></param>
        /// <param name="Y1"></param>
        /// <param name="X2"></param>
        /// <param name="Y2"></param>
        /// <returns>返回直线参数</returns>
        public TdLine CalLine(float X1, float Y1, float X2, float Y2)
        {
            TdPoint P1 = new TdPoint(X1, Y1);
            TdPoint P2 = new TdPoint(X2, Y2);
            TdLine  L  = new TdLine();

            if (P1.X != P2.X)
            {
                L.A = (P2.Y - P1.Y) / (P2.X - P1.X);
                L.C = 1;
                L.B = P1.Y - L.A * P1.X;
            }
            else
            {
                L.A = 1;
                L.C = 0;
                L.B = -P1.X;
            }
            return(L);
        }