当前位置: 首页>>代码示例>>C#>>正文


C# Matrix3x3.AdaptiveDeterminant方法代码示例

本文整理汇总了C#中BEPUutilities.Matrix3x3.AdaptiveDeterminant方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix3x3.AdaptiveDeterminant方法的具体用法?C# Matrix3x3.AdaptiveDeterminant怎么用?C# Matrix3x3.AdaptiveDeterminant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BEPUutilities.Matrix3x3的用法示例。


在下文中一共展示了Matrix3x3.AdaptiveDeterminant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AdaptiveInvert

        /// <summary>
        /// Inverts the largest nonsingular submatrix in the matrix, excluding 2x2's that involve M13 or M31, and excluding 1x1's that include nondiagonal elements.
        /// </summary>
        /// <param name="matrix">Matrix to be inverted.</param>
        /// <param name="result">Inverted matrix.</param>
        public static void AdaptiveInvert(ref Matrix3x3 matrix, out Matrix3x3 result)
        {
            int submatrix;
            float determinantInverse = 1 / matrix.AdaptiveDeterminant(out submatrix);
            float m11, m12, m13, m21, m22, m23, m31, m32, m33;
            switch (submatrix)
            {
                case 0: //Full matrix.
                    m11 = (matrix.M22 * matrix.M33 - matrix.M23 * matrix.M32) * determinantInverse;
                    m12 = (matrix.M13 * matrix.M32 - matrix.M33 * matrix.M12) * determinantInverse;
                    m13 = (matrix.M12 * matrix.M23 - matrix.M22 * matrix.M13) * determinantInverse;

                    m21 = (matrix.M23 * matrix.M31 - matrix.M21 * matrix.M33) * determinantInverse;
                    m22 = (matrix.M11 * matrix.M33 - matrix.M13 * matrix.M31) * determinantInverse;
                    m23 = (matrix.M13 * matrix.M21 - matrix.M11 * matrix.M23) * determinantInverse;

                    m31 = (matrix.M21 * matrix.M32 - matrix.M22 * matrix.M31) * determinantInverse;
                    m32 = (matrix.M12 * matrix.M31 - matrix.M11 * matrix.M32) * determinantInverse;
                    m33 = (matrix.M11 * matrix.M22 - matrix.M12 * matrix.M21) * determinantInverse;
                    break;
                case 1: //Upper left matrix, m11, m12, m21, m22.
                    m11 = matrix.M22 * determinantInverse;
                    m12 = -matrix.M12 * determinantInverse;
                    m13 = 0;

                    m21 = -matrix.M21 * determinantInverse;
                    m22 = matrix.M11 * determinantInverse;
                    m23 = 0;

                    m31 = 0;
                    m32 = 0;
                    m33 = 0;
                    break;
                case 2: //Lower right matrix, m22, m23, m32, m33.
                    m11 = 0;
                    m12 = 0;
                    m13 = 0;

                    m21 = 0;
                    m22 = matrix.M33 * determinantInverse;
                    m23 = -matrix.M23 * determinantInverse;

                    m31 = 0;
                    m32 = -matrix.M32 * determinantInverse;
                    m33 = matrix.M22 * determinantInverse;
                    break;
                case 3: //Corners, m11, m31, m13, m33.
                    m11 = matrix.M33 * determinantInverse;
                    m12 = 0;
                    m13 = -matrix.M13 * determinantInverse;

                    m21 = 0;
                    m22 = 0;
                    m23 = 0;

                    m31 = -matrix.M31 * determinantInverse;
                    m32 = 0;
                    m33 = matrix.M11 * determinantInverse;
                    break;
                case 4: //M11
                    m11 = 1 / matrix.M11;
                    m12 = 0;
                    m13 = 0;

                    m21 = 0;
                    m22 = 0;
                    m23 = 0;

                    m31 = 0;
                    m32 = 0;
                    m33 = 0;
                    break;
                case 5: //M22
                    m11 = 0;
                    m12 = 0;
                    m13 = 0;

                    m21 = 0;
                    m22 = 1 / matrix.M22;
                    m23 = 0;

                    m31 = 0;
                    m32 = 0;
                    m33 = 0;
                    break;
                case 6: //M33
                    m11 = 0;
                    m12 = 0;
                    m13 = 0;

                    m21 = 0;
                    m22 = 0;
                    m23 = 0;

                    m31 = 0;
//.........这里部分代码省略.........
开发者ID:Indiefreaks,项目名称:igf,代码行数:101,代码来源:Matrix3x3.cs

示例2: AdaptiveInvert

        /// <summary>
        /// Inverts the largest nonsingular submatrix in the matrix, excluding 2x2's that involve M1.Z or M3.X, and excluding 1x1's that include nondiagonal elements.
        /// </summary>
        /// <param name="matrix">Matrix to be inverted.</param>
        /// <param name="result">Inverted matrix.</param>
        public static void AdaptiveInvert(ref Matrix3x3 matrix, out Matrix3x3 result)
        {
            int submatrix;
            float determinantInverse = 1 / matrix.AdaptiveDeterminant(out submatrix);
            float m11, m12, m13, m21, m22, m23, m31, m32, m33;
            switch (submatrix)
            {
                case 0: //Full matrix.
                    m11 = (matrix.M2.Y * matrix.M3.Z - matrix.M2.Z * matrix.M3.Y) * determinantInverse;
                    m12 = (matrix.M1.Z * matrix.M3.Y - matrix.M3.Z * matrix.M1.Y) * determinantInverse;
                    m13 = (matrix.M1.Y * matrix.M2.Z - matrix.M2.Y * matrix.M1.Z) * determinantInverse;

                    m21 = (matrix.M2.Z * matrix.M3.X - matrix.M2.X * matrix.M3.Z) * determinantInverse;
                    m22 = (matrix.M1.X * matrix.M3.Z - matrix.M1.Z * matrix.M3.X) * determinantInverse;
                    m23 = (matrix.M1.Z * matrix.M2.X - matrix.M1.X * matrix.M2.Z) * determinantInverse;

                    m31 = (matrix.M2.X * matrix.M3.Y - matrix.M2.Y * matrix.M3.X) * determinantInverse;
                    m32 = (matrix.M1.Y * matrix.M3.X - matrix.M1.X * matrix.M3.Y) * determinantInverse;
                    m33 = (matrix.M1.X * matrix.M2.Y - matrix.M1.Y * matrix.M2.X) * determinantInverse;
                    break;
                case 1: //Upper left matrix, m11, m12, m21, m22.
                    m11 = matrix.M2.Y * determinantInverse;
                    m12 = -matrix.M1.Y * determinantInverse;
                    m13 = 0;

                    m21 = -matrix.M2.X * determinantInverse;
                    m22 = matrix.M1.X * determinantInverse;
                    m23 = 0;

                    m31 = 0;
                    m32 = 0;
                    m33 = 0;
                    break;
                case 2: //Lower right matrix, m22, m23, m32, m33.
                    m11 = 0;
                    m12 = 0;
                    m13 = 0;

                    m21 = 0;
                    m22 = matrix.M3.Z * determinantInverse;
                    m23 = -matrix.M2.Z * determinantInverse;

                    m31 = 0;
                    m32 = -matrix.M3.Y * determinantInverse;
                    m33 = matrix.M2.Y * determinantInverse;
                    break;
                case 3: //Corners, m11, m31, m13, m33.
                    m11 = matrix.M3.Z * determinantInverse;
                    m12 = 0;
                    m13 = -matrix.M1.Z * determinantInverse;

                    m21 = 0;
                    m22 = 0;
                    m23 = 0;

                    m31 = -matrix.M3.X * determinantInverse;
                    m32 = 0;
                    m33 = matrix.M1.X * determinantInverse;
                    break;
                case 4: //M1.X
                    m11 = 1 / matrix.M1.X;
                    m12 = 0;
                    m13 = 0;

                    m21 = 0;
                    m22 = 0;
                    m23 = 0;

                    m31 = 0;
                    m32 = 0;
                    m33 = 0;
                    break;
                case 5: //M2.Y
                    m11 = 0;
                    m12 = 0;
                    m13 = 0;

                    m21 = 0;
                    m22 = 1 / matrix.M2.Y;
                    m23 = 0;

                    m31 = 0;
                    m32 = 0;
                    m33 = 0;
                    break;
                case 6: //M3.Z
                    m11 = 0;
                    m12 = 0;
                    m13 = 0;

                    m21 = 0;
                    m22 = 0;
                    m23 = 0;

                    m31 = 0;
//.........这里部分代码省略.........
开发者ID:d3x0r,项目名称:Voxelarium,代码行数:101,代码来源:Matrix3x3.cs


注:本文中的BEPUutilities.Matrix3x3.AdaptiveDeterminant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。