public void A_translation_matrix_should_translate_each_component_of_the_point() { var matrix = new Matrix( 1, 0, 0, 1, 0, 1, 0, 3, 0, 0, 1, -2, 0, 0, 0, 1); Assert.Equal(new Point(2, 5, 1), matrix * new Point(1, 2, 3)); }
public void A_scaling_matrix_should_scale_each_component_of_the_point() { var matrix = new Matrix( 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1); Assert.Equal(new Point(2, 6, 12), matrix * new Point(2, 3, 4)); }
public void The_zero_vector_should_result_in_the_zero_vector() { var matrix = new Matrix( 1, 3, 4, 15, 0, 5, 0, 2, 0, 0, 3, 5, 0, 0, 0, 1); Assert.Equal(Vector.Zero, matrix * Vector.Zero); }
public void The_resulting_matrix_should_contain_the_elements_of_the_original_matrix_with_the_rows_and_columns_interchanged() { var expectedTranspose = new Matrix( 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15, 4, 8, 12, 16 ); Assert.Equal(expectedTranspose, MatrixHelper.SequentialMatrix.Transpose()); }
public void A_translation_matrix_should_result_in_the_same_vector() { var vector = new Vector(1, 2, 3); var matrix = new Matrix( 1, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 3, 0, 0, 0, 1); Assert.Equal(vector, matrix * vector); }
public static Matrix operator *(Matrix left, Matrix right) { var result = new Matrix(); for (var row = 0; row < 4; row++) { for (var col = 0; col < 4; col++) { result[row, col] = left[row, 0] * right[0, col] + left[row, 1] * right[1, col] + left[row, 2] * right[2, col] + left[row, 3] * right[3, col]; } } return result; }