Exemple #1
0
 // Token: 0x06000325 RID: 805 RVA: 0x00032030 File Offset: 0x00030230
 public static double[][] ChordalNodes(Point3d[,] intPoints)
 {
     double[] array  = SplineMath.ChordalNodesU(intPoints);
     double[] array2 = SplineMath.ChordalNodesU(MatrixMath.Transpose(intPoints));
     return(new double[][]
     {
         array2,
         array
     });
 }
Exemple #2
0
        /// <summary>Evaluates a matrix of basis function values</summary>
        /// <param name="knots">Knot sequence : n+k values t[0], ... , t[n+k-1]</param>
        /// <param name="k">Order of the b-spline</param>
        /// <param name="nodes">Parameter (n) values at which to evaluate, tau[0],...,tau[n-1]</param>
        /// <returns>Matrix (n x n) of basis function values, B(i,k)(nodes[j])</returns>
        /// <remarks>
        /// There are n basis functions, numbered <c>B(0,k), B(1,k), ... , B(n-1,k)</c>.
        /// <para>The i-th basis function B(i,k) is non-zero only for t[i] &lt; t &lt; t[i+k]</para>
        /// <para>In the matrix A : <c>A[j][i] = B(i,k)(tau[j])</c>  (i = 0,1,...,n-1 ; j = 0,1,...,n-1)</para>
        /// </remarks>
        // Token: 0x0600032C RID: 812 RVA: 0x00032398 File Offset: 0x00030598
        public static double[,] BasisMatrix(double[] knots, int k, double[] nodes)
        {
            int num  = knots.Length;
            int num2 = num - k;

            double[,] array = new double[num2, num2];
            for (int i = 0; i < num2; i++)
            {
                for (int j = 0; j < num2; j++)
                {
                    array[j, i] = SplineMath.EvaluateBasisFunction(knots, i, k, nodes[j]);
                }
            }
            return(array);
        }
Exemple #3
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);
        }
Exemple #4
0
        /// <summary>Calculates Greville knots based on given node values</summary>
        /// <param name="nodes">Node values</param>
        /// <param name="m">Degree of curve</param>
        /// <returns>Knot values</returns>
        /// <remarks>
        /// Greville knots give good numerical stability, and also guarantee that the
        /// Schoenberg-Whitney condition is satisfied, so interpolation will work.
        /// </remarks>
        // Token: 0x06000326 RID: 806 RVA: 0x00032064 File Offset: 0x00030264
        public static double[] GrevilleKnots(double[] nodes, int m)
        {
            int num  = m + 1;
            int num2 = nodes.Length;

            double[] array = new double[num2 + num];
            for (int i = 0; i < num; i++)
            {
                array[i] = 0.0;
            }
            for (int j = num; j < num2; j++)
            {
                array[j] = SplineMath.Sum(nodes, j - m, j - 1) / (double)m;
            }
            for (int k = num2; k < num2 + num; k++)
            {
                array[k] = 1.0;
            }
            return(array);
        }
Exemple #5
0
        // Token: 0x06000324 RID: 804 RVA: 0x00031F98 File Offset: 0x00030198
        private static double[] ChordalNodesU(Point3d[,] intPoints)
        {
            int length  = intPoints.GetLength(0);
            int length2 = intPoints.GetLength(1);

            Point3d[] intPoints2 = new Point3d[length2];
            double[,] array = new double[length, length2];
            for (int i = 0; i < length; i++)
            {
                intPoints2 = MatrixMath.GetRow(intPoints, i);
                double[] array2 = SplineMath.ChordalNodes(intPoints2);
                for (int j = 0; j < length2; j++)
                {
                    array[i, j] = array2[j];
                }
            }
            double[] array3 = new double[length2];
            for (int k = 0; k < length2; k++)
            {
                array3[k] = MathEx.Mean(MatrixMath.GetColumn(array, k));
            }
            return(array3);
        }
Exemple #6
0
 /// <summary>Evaluates value of a b-spline basis function</summary>
 /// <param name="knots">Knot sequence : n+k values t[0], ... , t[n+k-1]</param>
 /// <param name="i">Index of basis function (see below)</param>
 /// <param name="k">Order of the b-spline</param>
 /// <param name="t">Parameter value at which to evaluate</param>
 /// <returns>Value of i-th basis function B(i,k)(t)</returns>
 /// <remarks>
 /// There are n basis functions, numbered <c>B(0,k), B(1,k), ... , B(n-1,k)</c>.
 /// <para>The i-th basis function B(i,k) is non-zero only for t[i] &lt; t &lt; t[i+k]</para>
 /// </remarks>
 // Token: 0x0600032D RID: 813 RVA: 0x000323E8 File Offset: 0x000305E8
 public static double EvaluateBasisFunction(double[] knots, int i, int k, double t)
 {
     double[] array = SplineMath.EvaluateBasisFunction(knots, i, k, t, 0);
     return(array[0]);
 }