コード例 #1
0
ファイル: FPlane.cs プロジェクト: yongyoung888/UnrealCS
        /**
         * Get the result of transforming the plane by a Matrix.
         *
         * @param M The matrix to transform plane with.
         * @return The result of transform.
         */
        public FPlane TransformBy(FMatrix M)
        {
            FMatrix tmpTA = M.TransposeAdjoint();
            float   DetM  = M.Determinant();

            return(this.TransformByUsingAdjointT(M, DetM, tmpTA));
        }
コード例 #2
0
ファイル: FPlane.cs プロジェクト: zwywilliam/USharp
        /// <summary>
        /// Get the result of transforming the plane by a Matrix.
        /// </summary>
        /// <param name="m">The matrix to transform plane with.</param>
        /// <returns>The result of transform.</returns>
        public FPlane TransformBy(FMatrix m)
        {
            FMatrix tmpTA = m.TransposeAdjoint();
            float   detM  = m.Determinant();

            return(TransformByUsingAdjointT(m, detM, tmpTA));
        }
コード例 #3
0
        public void TestDeterminant()
        {
            // 10
            FMatrix <int> testOneMat = new FMatrix <int>(1, 1, 10);
            int?          oneDet     = FMatrix <int> .Determinant(testOneMat);

            Assert.IsTrue(oneDet.HasValue);
            Assert.AreEqual(oneDet.Value, 10);

            // 1 2
            // 3 4
            FMatrix <int> mat    = new FMatrix <int>(2, 2, -1);
            int           number = 1;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    mat.matrix[i][j] = number;
                    number++;
                }
            }
            Assert.IsTrue(mat.matrix[0][0] == 1);
            Assert.IsTrue(mat.matrix[0][1] == 2);
            Assert.IsTrue(mat.matrix[1][0] == 3);
            Assert.IsTrue(mat.matrix[1][1] == 4);
            int?det = FMatrix <int> .Determinant(mat);

            Assert.IsTrue(det.HasValue);
            Assert.AreEqual(det.Value, -2);

            // -1 -2
            // -3 -4
            FMatrix <int> mat3 = new FMatrix <int>(2, 2, -1);

            number = 1;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    mat3.matrix[i][j] = number;
                    number++;
                }
            }
            int?det3 = FMatrix <int> .Determinant(mat3);

            Assert.IsTrue(det3.HasValue);
            Assert.AreEqual(det3.Value, -2);

            // 1 2 5
            // 3 4 6
            // 9 8 7
            FMatrix <int> mat2 = new FMatrix <int>(3, 3, 0);

            mat2[0][0] = 1;
            mat2[0][1] = 2;
            mat2[0][2] = 5;
            mat2[1][0] = 3;
            mat2[1][1] = 4;
            mat2[1][2] = 6;
            mat2[2][0] = 9;
            mat2[2][1] = 8;
            mat2[2][2] = 7;
            int?det2 = FMatrix <int> .Determinant(mat2);

            Assert.IsTrue(det2.HasValue);
            Assert.AreEqual(det2.Value, -14);
        }