Exemple #1
0
 public static void GetIntersections(
     Circle2D circle,
     Arc2D arc,
     out Point2D[] intersections,
     out bool overlap)
 {
     Arc2D.GetIntersections(circle, arc, 8.88178419700125E-16, out intersections, out overlap);
 }
Exemple #2
0
 public static bool GetIntersections(
     Arc2D arc1,
     Arc2D arc2,
     out Point2D[] intersections,
     out Arc2D[] overlappingArcs)
 {
     return(Arc2D.GetIntersections(arc1, arc2, 8.88178419700125E-16, out intersections, out overlappingArcs));
 }
Exemple #3
0
            public Class92(Arc2D arc)
            {
                double num1 = arc.endAngle - arc.startAngle;

                if (num1 < 0.0 || num1 > 2.0 * System.Math.PI)
                {
                    double num2 = System.Math.Floor(num1 / (2.0 * System.Math.PI));
                    num1 -= 2.0 * num2 * System.Math.PI;
                }
                int num3 = (int)System.Math.Ceiling(2.0 * num1 / System.Math.PI) + 1;

                if (num3 >= 5)
                {
                    num3 = 4;
                    num1 = 2.0 * System.Math.PI;
                }
                double num4 = num1 / (double)num3;

                this.point2D_0 = new Point2D[1 + 3 * num3];
                double   startAngle = arc.StartAngle;
                Vector2D u          = arc.Radius * new Vector2D(System.Math.Cos(startAngle), System.Math.Sin(startAngle));

                this.point2D_0[0] = arc.Center + u;
                int num5 = 0;

                for (int index = 0; index < num3; ++index)
                {
                    startAngle += num4;
                    Vector2D v = arc.Radius * new Vector2D(System.Math.Cos(startAngle), System.Math.Sin(startAngle));
                    this.point2D_0[num5 + 3] = arc.Center + v;
                    double lengthSquared = u.GetLengthSquared();
                    double num2          = lengthSquared + Vector2D.DotProduct(u, v);
                    double num6          = Vector2D.CrossProduct(u, v);
                    double num7          = 4.0 / 3.0 * (System.Math.Sqrt(2.0 * lengthSquared * num2) - num2) / num6;
                    this.point2D_0[num5 + 1] = new Point2D(arc.Center.X + u.X - num7 * u.Y, arc.Center.Y + u.Y + num7 * u.X);
                    num5 += 3;
                    this.point2D_0[num5 - 1] = new Point2D(arc.Center.X + v.X - num7 * v.Y, arc.Center.Y + v.Y + num7 * v.X);
                    u = v;
                }
            }
Exemple #4
0
        private static void smethod_0(
            Arc2D arc1,
            Arc2D arc2,
            double precision,
            out Arc2D[] overlappingArcs)
        {
            overlappingArcs = (Arc2D[])null;
            double num1  = MathUtil.NormalizeAngleTwoPi(arc1.startAngle);
            double num2  = MathUtil.NormalizeAngleTwoPi(arc1.endAngle);
            double num3  = MathUtil.NormalizeAngleTwoPi(arc2.startAngle);
            double num4  = MathUtil.NormalizeAngleTwoPi(arc2.endAngle);
            bool   flag1 = false;

            if (num1 > num2)
            {
                flag1 = true;
            }
            bool flag2 = false;

            if (num3 > num4)
            {
                flag2 = true;
            }
            if (flag1)
            {
                if (flag2)
                {
                    List <Arc2D> arc2DList = new List <Arc2D>(2);
                    arc2DList.Add(new Arc2D(arc1.center, arc1.radius, System.Math.Max(num1, num3), System.Math.Min(num2, num4)));
                    double startAngle = System.Math.Min(num1, num3);
                    double endAngle   = System.Math.Max(num2, num4);
                    if (startAngle < endAngle - precision)
                    {
                        arc2DList.Add(new Arc2D(arc1.center, arc1.radius, startAngle, endAngle));
                    }
                    if (arc2DList.Count <= 0)
                    {
                        return;
                    }
                    overlappingArcs = arc2DList.ToArray();
                }
                else
                {
                    List <Arc2D> arc2DList = new List <Arc2D>(2);
                    if (num3 < num2 - precision)
                    {
                        arc2DList.Add(new Arc2D(arc1.center, arc1.radius, num3, System.Math.Min(num2, num4)));
                    }
                    if (num4 > num1 + precision)
                    {
                        arc2DList.Add(new Arc2D(arc1.center, arc1.radius, System.Math.Max(num1, num3), num4));
                    }
                    if (arc2DList.Count <= 0)
                    {
                        return;
                    }
                    overlappingArcs = arc2DList.ToArray();
                }
            }
            else if (flag2)
            {
                List <Arc2D> arc2DList = new List <Arc2D>(2);
                if (num1 < num4 - precision)
                {
                    arc2DList.Add(new Arc2D(arc1.center, arc1.radius, num1, System.Math.Min(num2, num4)));
                }
                if (num2 > num3 + precision)
                {
                    arc2DList.Add(new Arc2D(arc1.center, arc1.radius, System.Math.Max(num1, num3), num2));
                }
                if (arc2DList.Count <= 0)
                {
                    return;
                }
                overlappingArcs = arc2DList.ToArray();
            }
            else
            {
                double startAngle = System.Math.Max(num1, num3);
                double endAngle   = System.Math.Min(num2, num4);
                if (startAngle >= endAngle - precision)
                {
                    return;
                }
                overlappingArcs = new Arc2D[1]
                {
                    new Arc2D(arc1.center, arc1.radius, startAngle, endAngle)
                };
            }
        }
Exemple #5
0
        public static void GetIntersections(
            Circle2D circle,
            Arc2D arc,
            double precision,
            out Point2D[] intersections,
            out bool overlap)
        {
            intersections = (Point2D[])null;
            overlap       = false;
            Vector2D vector2D1 = arc.center - circle.Center;
            double   length    = vector2D1.GetLength();

            if (System.Math.Abs(length) <= precision)
            {
                if (!MathUtil.AreApproxEqual(circle.Radius, arc.radius, precision))
                {
                    return;
                }
                overlap = true;
            }
            else
            {
                Vector2D vector2D2 = vector2D1 / length;
                double   num1      = length;
                double   num2      = num1 * num1;
                double   num3      = circle.Radius * circle.Radius;
                double   num4      = arc.radius * arc.radius;
                double   num5      = num2 - num4 + num3;
                double   d         = (4.0 * num2 * num3 - num5 * num5) / (4.0 * num2);
                if (d < -precision)
                {
                    return;
                }
                double num6 = num5 / (2.0 * num1);
                if (d <= precision)
                {
                    Point2D point = circle.Center + num6 * vector2D2;
                    if (!arc.ContainsAngleProjection(point))
                    {
                        return;
                    }
                    intersections = new Point2D[1] {
                        point
                    };
                }
                else
                {
                    double a = System.Math.Sqrt(d);
                    if (MathUtil.AreApproxEqual(a, 0.0, precision))
                    {
                        Point2D point = circle.Center + num6 * vector2D2;
                        if (!arc.ContainsAngleProjection(point))
                        {
                            return;
                        }
                        intersections = new Point2D[1] {
                            point
                        };
                    }
                    else
                    {
                        Vector2D       vector2D3   = new Vector2D(vector2D2.Y, -vector2D2.X);
                        List <Point2D> point2DList = new List <Point2D>(2);
                        Point2D        point1      = circle.Center + num6 * vector2D2 + a * vector2D3;
                        if (arc.ContainsAngleProjection(point1))
                        {
                            point2DList.Add(point1);
                        }
                        Point2D point2 = circle.Center + num6 * vector2D2 - a * vector2D3;
                        if (arc.ContainsAngleProjection(point2))
                        {
                            point2DList.Add(point2);
                        }
                        if (point2DList.Count <= 0)
                        {
                            return;
                        }
                        intersections = point2DList.ToArray();
                    }
                }
            }
        }
Exemple #6
0
        public static bool GetIntersections(
            Arc2D arc1,
            Arc2D arc2,
            double precision,
            out Point2D[] intersections,
            out Arc2D[] overlappingArcs)
        {
            intersections   = (Point2D[])null;
            overlappingArcs = (Arc2D[])null;
            Vector2D vector2D1 = arc2.center - arc1.center;
            double   length    = vector2D1.GetLength();

            if (System.Math.Abs(length) <= precision)
            {
                if (MathUtil.AreApproxEqual(arc1.radius, arc2.radius, precision))
                {
                    Arc2D.smethod_0(arc1, arc2, precision, out overlappingArcs);
                }
            }
            else
            {
                Vector2D vector2D2 = vector2D1 / length;
                double   num1      = length;
                double   num2      = num1 * num1;
                double   num3      = arc1.radius * arc1.radius;
                double   num4      = arc2.radius * arc2.radius;
                double   num5      = num2 - num4 + num3;
                double   d         = (4.0 * num2 * num3 - num5 * num5) / (4.0 * num2);
                if (d >= -precision)
                {
                    double num6 = num5 / (2.0 * num1);
                    if (d <= precision)
                    {
                        Point2D point = arc1.center + num6 * vector2D2;
                        if (arc1.ContainsAngleProjection(point) && arc2.ContainsAngleProjection(point))
                        {
                            intersections = new Point2D[1] {
                                point
                            }
                        }
                        ;
                    }
                    else
                    {
                        double a = System.Math.Sqrt(d);
                        if (MathUtil.AreApproxEqual(a, 0.0, precision))
                        {
                            Point2D point = arc1.center + num6 * vector2D2;
                            if (arc1.ContainsAngleProjection(point) && arc2.ContainsAngleProjection(point))
                            {
                                intersections = new Point2D[1] {
                                    point
                                }
                            }
                            ;
                        }
                        else
                        {
                            Vector2D       vector2D3   = new Vector2D(vector2D2.Y, -vector2D2.X);
                            List <Point2D> point2DList = new List <Point2D>(2);
                            Point2D        point1      = arc1.center + num6 * vector2D2 + a * vector2D3;
                            if (arc1.ContainsAngleProjection(point1) && arc2.ContainsAngleProjection(point1))
                            {
                                point2DList.Add(point1);
                            }
                            Point2D point2 = arc1.center + num6 * vector2D2 - a * vector2D3;
                            if (arc1.ContainsAngleProjection(point2) && arc2.ContainsAngleProjection(point2))
                            {
                                point2DList.Add(point2);
                            }
                            if (point2DList.Count > 0)
                            {
                                intersections = point2DList.ToArray();
                            }
                        }
                    }
                }
            }
            if (intersections == null)
            {
                return(overlappingArcs != null);
            }
            return(true);
        }