Пример #1
0
        public static double[] GetIntersectionAngles(Segment2D line, Arc2D arc)
        {
            Vector2D delta    = line.GetDelta();
            double   num1     = delta.X * delta.X + delta.Y * delta.Y;
            Vector2D vector2D = line.Start - arc.Center;
            double   num2     = 2.0 * (vector2D.X * delta.X + vector2D.Y * delta.Y);
            double   num3     = vector2D.X * vector2D.X + vector2D.Y * vector2D.Y - arc.Radius * arc.Radius;
            double   d        = num2 * num2 - 4.0 * num1 * num3;

            if (d < 0.0)
            {
                return(new double[0]);
            }
            double         num4           = System.Math.Sqrt(d);
            double         num5           = (-num2 - num4) / (2.0 * num1);
            List <double>  doubleList     = new List <double>(2);
            AngleIntervalD angleIntervalD = new AngleIntervalD(arc.StartAngle, arc.EndAngle);

            if (num5 >= 0.0 && num5 <= 1.0)
            {
                double x    = vector2D.X + delta.X * num5;
                double num6 = System.Math.Atan2(vector2D.Y + delta.Y * num5, x);
                if (num6 < 0.0)
                {
                    num6 += 2.0 * System.Math.PI;
                }
                if (angleIntervalD.Contains(num6))
                {
                    doubleList.Add(num6);
                }
            }
            if (num4 != 0.0)
            {
                double num6 = (-num2 + num4) / (2.0 * num1);
                if (num6 >= 0.0 && num6 <= 1.0)
                {
                    double x    = vector2D.X + delta.X * num6;
                    double num7 = System.Math.Atan2(vector2D.Y + delta.Y * num6, x);
                    if (num7 < 0.0)
                    {
                        num7 += 2.0 * System.Math.PI;
                    }
                    if (angleIntervalD.Contains(num7))
                    {
                        doubleList.Add(num7);
                    }
                }
            }
            return(doubleList.ToArray());
        }
Пример #2
0
        public bool Overlaps(AngleIntervalD other)
        {
            double num1 = this.double_1 < this.double_0 ? this.double_1 + 2.0 * Math.PI : this.double_1;
            double num2 = other.double_1 < other.double_0 ? other.double_1 + 2.0 * Math.PI : other.double_1;

            if (this.double_0 - 2.0 * Math.PI <= num2 && num1 - 2.0 * Math.PI >= other.double_0 || this.double_0 <= num2 && num1 >= other.double_0)
            {
                return(true);
            }
            if (this.double_0 + 2.0 * Math.PI <= num2)
            {
                return(num1 + 2.0 * Math.PI >= other.double_0);
            }
            return(false);
        }