Beispiel #1
0
        /// <summary>B-spline interpolation (1D -- real-valued)</summary>
        /// <param name="intValues">The n values to interpolate, q[0],...,q[n-1]</param>
        /// <param name="nodes">The n parameter values at which to interpolate, tau[0],...,tau[n-1]</param>
        /// <param name="knots">Knot sequence : n-k values t[0], ... , t[n+k-1]</param>
        /// <returns>The n "poles" (ordinate values) p[0],...,p[n-1] of the interpolating b-spline</returns>
        /// <remarks>
        ///  This function does 1-D (i.e. real-valued) interpolation.
        ///  To do 3D interpolation, you would have to call it three times -- for x, y, and z.
        ///  However, it is much more efficient to call
        /// <see cref="M:Snap.Math.SplineMath.BsplineInterpolation(Snap.Position[],System.Double[],System.Double[])">the other BsplineInterpolation overload</see>,
        ///  which receives positions as input.
        /// </remarks>
        // Token: 0x06000329 RID: 809 RVA: 0x0003215C File Offset: 0x0003035C
        public static double[] BsplineInterpolation(double[] intValues, double[] nodes, double[] knots)
        {
            int num  = intValues.Length;
            int num2 = knots.Length;
            int k    = num2 - num;

            double[,] a = SplineMath.BasisMatrix(knots, k, nodes);
            int[]  index = new int[num];
            double d     = 1.0;

            LinearAlgebra.LUDecomposition(a, index, d);
            double[] array = new double[num];
            intValues.CopyTo(array, 0);
            LinearAlgebra.BackSubstitution(a, index, array);
            return(array);
        }
Beispiel #2
0
        /// <summary>Fills in missing information for principal moments and principal axes</summary>
        /// <returns>Results with principal moments and principal axes added/corrected</returns>
        internal void CompleteResults()
        {
            double[,] array = new double[3, 3];
            array[0, 0]     = MomentsOfInertia[0];
            array[1, 1]     = MomentsOfInertia[1];
            array[2, 2]     = MomentsOfInertia[2];
            array[0, 1]     = -ProductsOfInertia[2];
            array[0, 2]     = -ProductsOfInertia[1];
            array[1, 2]     = -ProductsOfInertia[0];
            double   mass   = Mass;
            Vector3d vector = Centroid.ToVector3d();
            double   num    = Math.Pow(vector.GetLength(), 2);

            double[,] array2 = new double[3, 3];
            array2[0, 0]     = array[0, 0] - mass * (num - vector.X * vector.X);
            array2[1, 1]     = array[1, 1] - mass * (num - vector.Y * vector.Y);
            array2[2, 2]     = array[2, 2] - mass * (num - vector.Z * vector.Z);
            array2[0, 1]     = array[0, 1] + mass * vector.X * vector.Y;
            array2[1, 0]     = array2[0, 1];
            array2[0, 2]     = array[0, 2] + mass * vector.X * vector.Z;
            array2[2, 0]     = array2[0, 2];
            array2[1, 2]     = array[1, 2] + mass * vector.Y * vector.Z;
            array2[2, 1]     = array2[1, 2];
            LinearAlgebra.EigenSystemResult[] array3 = LinearAlgebra.EigenSystem(array2);
            PrincipalMoments = new double[]
            {
                array3[0].Eigenvalue,
                array3[1].Eigenvalue,
                array3[2].Eigenvalue
            };
            PrincipalAxes = new Vector3d[]
            {
                array3[0].Eigenvector.ToVector3d(),
                array3[1].Eigenvector.ToVector3d(),
                array3[2].Eigenvector.ToVector3d()
            };
            for (int i = 0; i < 3; i++)
            {
                PrincipalAxes[i] = PrincipalAxes[i].Reverse();
            }
            InertiaTensor = array2;
        }