Exemplo n.º 1
0
        // Token: 0x060002B7 RID: 695 RVA: 0x0000B15C File Offset: 0x0000935C
        public static double[] GetRoots(Line3 line, Torus3 torus, out int quantity)
        {
            double num  = torus.OuterRadius * torus.OuterRadius;
            double num2 = torus.InnerRadius * torus.InnerRadius;
            double num3 = line.Direction.Dot(line.Direction);
            double num4 = line.Origin.Dot(line.Direction);
            double num5 = line.Origin.Dot(line.Origin) - (num + num2);

            double[] array = new double[5];
            double   z     = line.Origin.Z;
            double   z2    = line.Direction.Z;

            double[] array2 = array;
            int      num6   = 0;
            double   num7   = num5;
            double   num8   = num7 * num7;
            double   num9   = 4.0 * num;
            double   num10  = num2;
            double   num11  = z;

            array2[num6] = num8 - num9 * (num10 - num11 * num11);
            array[1]     = 4.0 * num4 * num5 + 8.0 * num * z2 * z;
            array[2]     = 2.0 * num3 * num5 + 4.0 * num4 * num4 + 4.0 * num * z2 * z2;
            array[3]     = 4.0 * num3 * num4;
            double[] array3 = array;
            int      num12  = 4;
            double   num13  = num3;

            array3[num12] = num13 * num13;
            PolynomialRoots polynomialRoots = new PolynomialRoots(1E-08);

            polynomialRoots.FindB(new Polynomial1(array), 6);
            quantity = polynomialRoots.Count;
            return(polynomialRoots.Roots);
        }
Exemplo n.º 2
0
        // Token: 0x060000C0 RID: 192 RVA: 0x00004D20 File Offset: 0x00002F20
        internal static IEnumerable <double> GetPolynomialRoots(Line3 line, Circle3 circle)
        {
            Vector3 vector = circle.Center - line.Origin;
            double  num    = line.Direction.Dot(vector);
            Vector3 origin = line.Origin + num * line.Direction;

            line = new Line3(origin, line.Direction);
            Vector3 vector2       = line.Origin - circle.Center;
            double  squaredLength = vector2.SquaredLength;
            double  num2          = vector2.Dot(line.Direction);
            double  num3          = circle.Normal.Dot(line.Direction);
            double  num4          = vector2.Dot(circle.Normal);
            double  num5          = num2;
            double  num6          = num2 - num3 * num4;
            double  num7          = 1.0;
            double  num8          = num3;
            double  num9          = num7 - num8 * num8;
            double  num10         = num4;
            double  num11         = squaredLength - num10 * num10;
            double  num12         = num6;
            double  num13         = num9;
            double  num14         = circle.Radius * circle.Radius;
            double  num15         = num5;
            double  num16         = num15 * num15;
            double  num17         = 2.0 * num5 * 1.0;
            double  num18         = num6;
            double  num19         = num18 * num18;
            double  num20         = num9;
            double  num21         = num20 * num20;
            double  num22         = 2.0 * num6 * num9;
            double  num23         = 2.0 * num12;

            double[] coefficients = new double[]
            {
                num16 *num11 - num19 *num14,
                     num17 *num11 + num16 *num23 - num22 *num14,
                1.0 *num11 + num17 *num23 + num16 *num13 - num21 *num14,
                1.0 *num23 + num17 *num13,
                1.0 *num13
            };
            PolynomialRoots polynomialRoots = new PolynomialRoots(1E-05);
            polynomialRoots.FindB(new Polynomial1(coefficients), 6);
            List <double> list = new List <double>();
            for (int i = 0; i < polynomialRoots.Count; i++)
            {
                list.Add(polynomialRoots.GetRoot(i) + num);
            }
            return(list);
        }