コード例 #1
0
ファイル: PolynomialRoots.cs プロジェクト: mh-soft/mh-master
        // Token: 0x060004F1 RID: 1265 RVA: 0x0001A4B8 File Offset: 0x000186B8
        private static bool AllRealPartsNegative(int degree, double[] coeff)
        {
            if (coeff[degree - 1] <= 0.0)
            {
                return(false);
            }
            if (degree == 1)
            {
                return(true);
            }
            double[] array = new double[degree];
            array[0] = 2.0 * coeff[0] * coeff[degree - 1];
            for (int i = 1; i <= degree - 2; i++)
            {
                array[i] = coeff[degree - 1] * coeff[i];
                if ((degree - i) % 2 == 0)
                {
                    array[i] -= coeff[i - 1];
                }
                array[i] *= 2.0;
            }
            array[degree - 1] = 2.0 * coeff[degree - 1] * coeff[degree - 1];
            int num = degree - 1;

            while (num >= 0 && array[num] == 0.0)
            {
                num--;
            }
            for (int i = 0; i <= num - 1; i++)
            {
                coeff[i] = array[i] / array[num];
            }
            return(PolynomialRoots.AllRealPartsNegative(num, coeff));
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: PolynomialRoots.cs プロジェクト: mh-soft/mh-master
        // Token: 0x060004F0 RID: 1264 RVA: 0x0001A3E4 File Offset: 0x000185E4
        public bool AllRealPartsPositive(Polynomial1 poly)
        {
            int degree = poly.Degree;

            double[] array = new double[degree + 1];
            int      num   = 0;

            foreach (double num2 in poly.Coefficients)
            {
                array[num++] = num2;
            }
            int i;

            if (array[degree] != 1.0)
            {
                double num3 = 1.0 / array[degree];
                for (i = 0; i < degree; i++)
                {
                    array[i] *= num3;
                }
                array[degree] = 1.0;
            }
            int num4 = -1;

            i = degree - 1;
            while (i >= 0)
            {
                array[i] *= (double)num4;
                i--;
                num4 = -num4;
            }
            return(PolynomialRoots.AllRealPartsNegative(degree, array));
        }
コード例 #4
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);
        }