Exemple #1
0
        public void When_Calculating_Determinant_Of_Matrix_Double_With_Result_Is_Returned()
        {
            //Arrange
            Matrix4 matrixOne = new Matrix4(1.0, 2.0, 0.0, 3.0, 3.0, 2.0, 1.0, 2.0, 1.0, 0.0, 1.0, 1.0, 2.0, 1.0, 3.0, 3.0);

            //Act
            double result = matrixOne.Determinant();

            //Assert
            Assert.AreEqual(9.0, result);
        }
Exemple #2
0
        public Matrix4 Inverse()
        {
            Matrix4 matrixOne = new Matrix4(xx, xy, xz, xw, yx, yy, yz, yw, zx, zy, zz, zw, wx, wy, wz, ww);

            Matrix4 adjOne = matrixOne.Adjoint();

            double detOne = matrixOne.Determinant();

            return new Matrix4( adjOne.xx / detOne, adjOne.xy / detOne, adjOne.xz / detOne, adjOne.xw / detOne,
                                adjOne.yx / detOne, adjOne.yy / detOne, adjOne.yz / detOne, adjOne.yw / detOne,
                                adjOne.zx / detOne, adjOne.zy / detOne, adjOne.zz / detOne, adjOne.zw / detOne,
                                adjOne.wx / detOne, adjOne.wy / detOne, adjOne.wz / detOne, adjOne.ww / detOne);
        }