コード例 #1
0
        public void TestDeterminant4()
        {
            var m = new Matrix4(
                -2, -8, 3, 5,
                -3, 1, 7, 3,
                1, 2, -9, 6,
                -6, 7, 7, -9);

            Assert.AreEqual(690, m.CoFactor(0, 0), Epsilon);
            Assert.AreEqual(447, m.CoFactor(0, 1), Epsilon);
            Assert.AreEqual(210, m.CoFactor(0, 2), Epsilon);
            Assert.AreEqual(51, m.CoFactor(0, 3), Epsilon);
            Assert.AreEqual(-4071, m.Determinant(), Epsilon);
        }
コード例 #2
0
        public void TestInverse()
        {
            var m = new Matrix4(
                -5, 2, 6, -8,
                1, -5, 1, 8,
                7, 7, -6, -7,
                1, -3, 7, 4);

            var mInverse = m.Inverse();

            var expectedInverse = new Matrix4(
                0.21805, 0.45113, 0.24060, -0.04511,
                -0.80827, -1.45677, -0.44361, 0.52068,
                -0.07895, -0.22368, -0.05263, 0.19737,
                -0.52256, -0.81391, -0.30075, 0.30639);

            Assert.AreEqual(532, m.Determinant(), Epsilon);
            Assert.AreEqual(-160, m.CoFactor(2, 3));
            Assert.AreEqual(-160.0 / 532, mInverse.ValueAt(3, 2));
            Assert.AreEqual(105, m.CoFactor(3, 2));
            Assert.AreEqual(105.0 / 532, mInverse.ValueAt(2, 3));
            Assert.AreEqual(expectedInverse, mInverse);
        }