Пример #1
0
        public static int smethod_1(PointF center, float radius, Class477.Struct48 line, out PointF intersection1, out PointF intersection2)
        {
            float num  = line.pointF_1.X - line.pointF_0.X;
            float num2 = line.pointF_1.Y - line.pointF_0.Y;
            float num3 = num * num + num2 * num2;
            float num4 = 2f * (num * (line.pointF_0.X - center.X) + num2 * (line.pointF_0.Y - center.Y));
            float num5 = (line.pointF_0.X - center.X) * (line.pointF_0.X - center.X) + (line.pointF_0.Y - center.Y) * (line.pointF_0.Y - center.Y) - radius * radius;
            float num6 = num4 * num4 - 4f * num3 * num5;

            if ((double)num3 <= 1E-07 || num6 < 0f)
            {
                intersection1 = new PointF(float.NaN, float.NaN);
                intersection2 = new PointF(float.NaN, float.NaN);
                return(0);
            }
            float num7;

            if (num6 == 0f)
            {
                num7          = -num4 / (2f * num3);
                intersection1 = new PointF(line.pointF_0.X + num7 * num, line.pointF_0.Y + num7 * num2);
                intersection2 = new PointF(float.NaN, float.NaN);
                return(1);
            }
            num7          = (float)(((double)(-(double)num4) + Math.Sqrt((double)num6)) / (double)(2f * num3));
            intersection1 = new PointF(line.pointF_0.X + num7 * num, line.pointF_0.Y + num7 * num2);
            num7          = (float)(((double)(-(double)num4) - Math.Sqrt((double)num6)) / (double)(2f * num3));
            intersection2 = new PointF(line.pointF_0.X + num7 * num, line.pointF_0.Y + num7 * num2);
            return(2);
        }
Пример #2
0
        // Token: 0x06002AA8 RID: 10920 RVA: 0x000A4A28 File Offset: 0x000A2C28
        public static float?smethod_2(PointF p, RectangleF rec)
        {
            PointF end = rec.smethod_7();

            Class477.Struct48 ab     = new Class477.Struct48(p, end);
            PointF?           pointF = null;

            if (p.Y <= rec.Top)
            {
                pointF = Class477.smethod_3(ab, rec);
                if (pointF == null)
                {
                    if (p.X < rec.Left)
                    {
                        pointF = Class477.smethod_4(ab, rec);
                    }
                    else
                    {
                        pointF = Class477.smethod_5(ab, rec);
                    }
                }
            }
            else if (p.Y >= rec.Bottom)
            {
                pointF = Class477.smethod_6(ab, rec);
                if (pointF == null)
                {
                    if (p.X < rec.Left)
                    {
                        pointF = Class477.smethod_4(ab, rec);
                    }
                    else
                    {
                        pointF = Class477.smethod_5(ab, rec);
                    }
                }
            }
            else if (p.X <= rec.Left)
            {
                pointF = Class477.smethod_4(ab, rec);
            }
            else
            {
                if (p.X < rec.Right)
                {
                    return(null);
                }
                pointF = Class477.smethod_5(ab, rec);
            }
            if (pointF == null)
            {
                return(null);
            }
            return(new float?(Class477.smethod_9(p, pointF.Value)));
        }
Пример #3
0
        public static PointF?smethod_7(Class477.Struct48 AB, Class477.Struct48 CD)
        {
            double num  = (double)(AB.pointF_0.Y - CD.pointF_0.Y);
            double num2 = (double)(CD.pointF_1.X - CD.pointF_0.X);
            double num3 = (double)(AB.pointF_0.X - CD.pointF_0.X);
            double num4 = (double)(CD.pointF_1.Y - CD.pointF_0.Y);
            double num5 = (double)(AB.pointF_1.X - AB.pointF_0.X);
            double num6 = (double)(AB.pointF_1.Y - AB.pointF_0.Y);
            double num7 = num5 * num4 - num6 * num2;
            double num8 = num * num2 - num3 * num4;

            if (num7 == 0.0)
            {
                if (num8 != 0.0)
                {
                    return(null);
                }
                if (AB.pointF_0.X >= CD.pointF_0.X && AB.pointF_0.X <= CD.pointF_1.X)
                {
                    return(new PointF?(AB.pointF_0));
                }
                if (CD.pointF_0.X >= AB.pointF_0.X && CD.pointF_0.X <= AB.pointF_1.X)
                {
                    return(new PointF?(CD.pointF_0));
                }
                return(null);
            }
            else
            {
                double num9 = num8 / num7;
                if (num9 < 0.0 || num9 > 1.0)
                {
                    return(null);
                }
                double num10 = (num * num5 - num3 * num6) / num7;
                if (num10 >= 0.0 && num10 <= 1.0)
                {
                    return(new PointF?(new PointF((float)((double)AB.pointF_0.X + num9 * num5), (float)((double)AB.pointF_0.Y + num9 * num6))));
                }
                return(null);
            }
        }
Пример #4
0
 private static PointF?smethod_6(Class477.Struct48 AB, RectangleF rec)
 {
     return(Class477.smethod_7(AB, new Class477.Struct48(rec.smethod_12(), rec.smethod_13())));
 }