예제 #1
0
파일: ApplyMath.cs 프로젝트: secondii/Yutai
        public static long GetInterSectPointofTwoLinesect(GPoint ptFirstLnBeg, double dAngle1, GPoint ptSecondLnBeg,
                                                          double dAngle2, ref GPoint ptInsect)
        {
            dAngle1 = ApplyMath.MakeAngleTo2P(dAngle1);
            dAngle2 = ApplyMath.MakeAngleTo2P(dAngle2);
            long result;

            if (Math.Abs(dAngle1 - 90.0) < 1E-08 || Math.Abs(dAngle1 - 270.0) < 1E-08)
            {
                if (Math.Abs(dAngle2 - 90.0) < 1E-08 || Math.Abs(dAngle2 - 270.0) < 1E-08)
                {
                    result = 0L;
                }
                else
                {
                    double num = (ptFirstLnBeg.X - ptSecondLnBeg.X) / Math.Cos(dAngle2 * 0.017453292519943295);
                    ptInsect.X = ptFirstLnBeg.X;
                    ptInsect.Y = ptSecondLnBeg.Y + num * Math.Sin(dAngle2 * 0.017453292519943295);
                    result     = 1L;
                }
            }
            else if (Math.Abs(dAngle2 - 90.0) < 1E-08 || Math.Abs(dAngle2 - 270.0) < 1E-08)
            {
                double num2 = (ptSecondLnBeg.X - ptFirstLnBeg.X) / Math.Cos(dAngle1 * 0.017453292519943295);
                ptInsect.X = ptSecondLnBeg.X;
                ptInsect.Y = ptFirstLnBeg.Y + num2 * Math.Sin(dAngle1 * 0.017453292519943295);
                result     = 1L;
            }
            else if (Math.Abs(Math.Tan(dAngle1 * 0.017453292519943295) - Math.Tan(dAngle2 * 0.017453292519943295)) < 1E-08)
            {
                result = 0L;
            }
            else
            {
                double num3 = (ptSecondLnBeg.X - ptFirstLnBeg.X) / Math.Cos(dAngle1 * 0.017453292519943295);
                double num  = (ptFirstLnBeg.Y - ptSecondLnBeg.Y + num3 * Math.Sin(dAngle1 * 0.017453292519943295)) /
                              (Math.Sin(dAngle2 * 0.017453292519943295) -
                               Math.Tan(dAngle1 * 0.017453292519943295) * Math.Cos(dAngle2 * 0.017453292519943295));
                double num2 = num3 + num * Math.Cos(dAngle2 * 0.017453292519943295) / Math.Cos(dAngle1 * 0.017453292519943295);
                ptInsect.X = ptFirstLnBeg.X + num2 * Math.Cos(dAngle1 * 0.017453292519943295);
                ptInsect.Y = ptFirstLnBeg.Y + num2 * Math.Sin(dAngle1 * 0.017453292519943295);
                result     = 1L;
            }
            return(result);
        }
예제 #2
0
파일: ApplyMath.cs 프로젝트: secondii/Yutai
        public static long GetInterSectPointofTwoLinesect(GPoint ptFirstLnBeg, GPoint ptFirstLnEnd, GPoint ptSecondLnBeg,
                                                          GPoint ptSecondLnEnd, ref GPoint ptInsect)
        {
            double angleToPt  = ptFirstLnBeg.GetAngleToPt(ptFirstLnEnd);
            double angleToPt2 = ptSecondLnBeg.GetAngleToPt(ptSecondLnEnd);

            return(ApplyMath.GetInterSectPointofTwoLinesect(ptFirstLnBeg, angleToPt, ptSecondLnBeg, angleToPt2,
                                                            ref ptInsect));
        }