예제 #1
0
 /// <summary>
 /// Converts a <see cref="Fusee.Math.Core.Matrix4D"/> to an Array of floats. The row major order storage of the
 /// original matrix is kept. This way the returned array can be used in environments taking row major order matrices
 /// (e.g. OpenGL). Use ToArray[]ColOrder for converting the original matrix to environments taking column major order
 /// matrices (like e.g. DirectX).
 /// </summary>
 /// <param name="value">The matrix value to convert.</param>
 /// <returns>A float array containing 16 values in row major order [m11, m12, m13, ...].</returns>
 public static float[] Matrix4DToArrayFloatRowOrder(Fusee.Math.Core.Matrix4D value)
 {
     return(new float[] { (float)value[0, 0], (float)value[0, 1], (float)value[0, 2], (float)value[0, 3],
                          (float)value[1, 0], (float)value[1, 1], (float)value[1, 2], (float)value[1, 3],
                          (float)value[2, 0], (float)value[2, 1], (float)value[2, 2], (float)value[2, 3],
                          (float)value[3, 0], (float)value[3, 1], (float)value[3, 2], (float)value[3, 3] });
 }
예제 #2
0
 /// <summary>
 /// Converts a <see cref="Fusee.Math.Core.Matrix4D"/> to an Array of double values in the somewhat awkward Cinema 4D Matrix layout.
 /// This is a 3 rows, 4 columns matrix stored as column vectors with the "offset" vector first (although internally the C4D Matrix arithmetics
 /// is rather row major order oriented). Anyway, the layout of the resulting array will be [m14, m24, m34, m11, m21, m31, m12, m22, m32, m13, m23, m33].
 /// The "projection part" of the original 4x4 matrix is ignored.
 /// </summary>
 /// <param name="value">The matrix value to convert.</param>
 /// <returns>A double array containing 12 double values in the Cinema 4D matrix layout described above.</returns>
 public static double[] Matrix4DToArrayDoubleC4DLayout(Fusee.Math.Core.Matrix4D value)
 {
     return(new double[] { value[0, 3], value[1, 3], value[2, 3],
                           value[0, 0], value[1, 0], value[2, 0],
                           value[0, 1], value[1, 1], value[2, 1],
                           value[0, 2], value[1, 2], value[2, 2] });
 }
예제 #3
0
 /// <summary>
 /// Converts a <see cref="Fusee.Math.Core.Matrix4D"/> to an Array of double values. The row major order storage of the
 /// original matrix is converted to column major order (the matrix is transposed before exporting it to an Array).
 /// This way the returned array can be used in environments taking column major order
 /// matrices (like e.g. DirectX). Use ToArray[]RowOrder for converting the original matrix to environments taking
 /// row major order matrices (e.g. OpenGL).
 /// </summary>
 /// <param name="value">The matrix value to convert.</param>
 /// <returns>A double array containing 16 values in column major order [m11, m21, m31, ...].</returns>
 public static double[] Matrix4DToArrayDoubleColOrder(Fusee.Math.Core.Matrix4D value)
 {
     return(new double[] { value[0, 0], value[1, 0], value[2, 0], value[3, 0],
                           value[0, 1], value[1, 1], value[2, 1], value[3, 1],
                           value[0, 2], value[1, 2], value[2, 2], value[3, 2],
                           value[0, 3], value[1, 3], value[2, 3], value[3, 3] });
 }
예제 #4
0
        /// <summary>
        /// Copys a <see cref="Fusee.Math.Core.Matrix4D"/> to an existing array of double values in the somewhat awkward Cinema 4D Matrix layout.
        /// This is a 3 rows, 4 columns matrix stored as column vectors with the "offset" vector first (although internally the C4D Matrix arithmetics
        /// is rather row major order oriented). Anyway, the layout of the resulting array will be [m14, m24, m34, m11, m21, m31, m12, m22, m32, m13, m23, m33].
        /// The "projection part" of the original 4x4 matrix is ignored.
        /// </summary>
        /// <param name="value">The matrix value to convert.</param>
        /// <returns>A double array containing 12 double values in the Cinema 4D matrix layout described above.</returns>
        public static unsafe void Matrix4DToArrayDoubleC4DLayout(Fusee.Math.Core.Matrix4D value, double *pDst)
        {
            pDst[0] = value[0, 3];
            pDst[1] = value[1, 3];
            pDst[2] = value[2, 3];

            pDst[3] = value[0, 0];
            pDst[4] = value[1, 0];
            pDst[5] = value[2, 0];

            pDst[6] = value[0, 1];
            pDst[7] = value[1, 1];
            pDst[8] = value[2, 1];

            pDst[9]  = value[0, 2];
            pDst[10] = value[1, 2];
            pDst[11] = value[2, 2];
        }