コード例 #1
0
ファイル: Matrix4fTests.cs プロジェクト: GeirGrusom/ModGL
        public void GetRow_ReturnsCorrectRow(int index)
        {
            // Arrange
            var vectors = new Vector4f[4];
            vectors[index] = new Vector4f(1, 2, 3, 4);
            var mat = new Matrix4f(vectors[0], vectors[1], vectors[2], vectors[3]);

            // Act
            var theRow = mat.Row(index);

            // Assert
            Assert.That(theRow, Is.EqualTo(new Vector4f(1, 2, 3, 4)));
        }
コード例 #2
0
ファイル: Matrix.cs プロジェクト: GeirGrusom/ModGL
        public Matrix4f Multiply(Matrix4f rhs)
        {
            Contract.Requires(rhs != null, "rhs cannot be null.");
            Contract.EndContractBlock();

            if (rhs == null)
                throw new ArgumentNullException("rhs");

            var result = new float[4, 4];
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    result[j, i] = System.Numerics.VectorMath.DotProduct(Column(j), rhs.Row(i));
                }
            }
            return new Matrix4f(
                new Vector4f(result[0, 0], result[1, 0], result[2, 0], result[3, 0]),
                new Vector4f(result[0, 1], result[1, 1], result[2, 1], result[3, 1]),
                new Vector4f(result[0, 2], result[1, 2], result[2, 2], result[3, 2]),
                new Vector4f(result[0, 3], result[1, 3], result[2, 3], result[3, 3]));
        }