public void ConstructorValuesAreAccessibleByIndexer() { Matrix4x2 matrix4x2; matrix4x2 = new Matrix4x2(); for (int x = 0; x < matrix4x2.Columns; x++) { for (int y = 0; y < matrix4x2.Rows; y++) { Assert.Equal(0, matrix4x2[x, y], Epsilon); } } double value = 33.33; matrix4x2 = new Matrix4x2(value); for (int x = 0; x < matrix4x2.Columns; x++) { for (int y = 0; y < matrix4x2.Rows; y++) { Assert.Equal(value, matrix4x2[x, y], Epsilon); } } GenerateFilledMatrixWithValues(out matrix4x2); for (int y = 0; y < matrix4x2.Rows; y++) { for (int x = 0; x < matrix4x2.Columns; x++) { Assert.Equal(y * matrix4x2.Columns + x, matrix4x2[x, y], Epsilon); } } }
public void MemberGetAndSetValuesCorrectly() { Matrix4x2 matrix4x2 = new Matrix4x2(); matrix4x2.M11 = 0; matrix4x2.M21 = 1; matrix4x2.M31 = 2; matrix4x2.M41 = 3; matrix4x2.M12 = 4; matrix4x2.M22 = 5; matrix4x2.M32 = 6; matrix4x2.M42 = 7; Assert.Equal(0, matrix4x2.M11, Epsilon); Assert.Equal(1, matrix4x2.M21, Epsilon); Assert.Equal(2, matrix4x2.M31, Epsilon); Assert.Equal(3, matrix4x2.M41, Epsilon); Assert.Equal(4, matrix4x2.M12, Epsilon); Assert.Equal(5, matrix4x2.M22, Epsilon); Assert.Equal(6, matrix4x2.M32, Epsilon); Assert.Equal(7, matrix4x2.M42, Epsilon); Assert.Equal(matrix4x2[0, 0], matrix4x2.M11, Epsilon); Assert.Equal(matrix4x2[1, 0], matrix4x2.M21, Epsilon); Assert.Equal(matrix4x2[2, 0], matrix4x2.M31, Epsilon); Assert.Equal(matrix4x2[3, 0], matrix4x2.M41, Epsilon); Assert.Equal(matrix4x2[0, 1], matrix4x2.M12, Epsilon); Assert.Equal(matrix4x2[1, 1], matrix4x2.M22, Epsilon); Assert.Equal(matrix4x2[2, 1], matrix4x2.M32, Epsilon); Assert.Equal(matrix4x2[3, 1], matrix4x2.M42, Epsilon); }
public void EqualityOperatorWorksCorrectly() { Matrix4x2 value1 = new Matrix4x2(100); Matrix4x2 value2 = new Matrix4x2(50) * 2; Assert.Equal(value1, value2); Assert.True(value1 == value2, "Equality operator failed."); }
public void ConstantValuesAreCorrect() { Matrix4x2 matrix4x2 = new Matrix4x2(); Assert.Equal(4, matrix4x2.Columns); Assert.Equal(2, matrix4x2.Rows); Assert.Equal(Matrix4x2.ColumnCount, matrix4x2.Columns); Assert.Equal(Matrix4x2.RowCount, matrix4x2.Rows); }
public void AccessorThrowsWhenOutOfBounds() { Matrix4x2 matrix4x2 = new Matrix4x2(); Assert.Throws <ArgumentOutOfRangeException>(() => { matrix4x2[-1, 0] = 0; }); Assert.Throws <ArgumentOutOfRangeException>(() => { matrix4x2[0, -1] = 0; }); Assert.Throws <ArgumentOutOfRangeException>(() => { matrix4x2[4, 0] = 0; }); Assert.Throws <ArgumentOutOfRangeException>(() => { matrix4x2[0, 2] = 0; }); }
public void MuliplyByMatrix4x2ProducesMatrix4x1() { Matrix2x1 matrix1 = new Matrix2x1(3); Matrix4x2 matrix2 = new Matrix4x2(2); Matrix4x1 result = matrix1 * matrix2; Matrix4x1 expected = new Matrix4x1(12, 12, 12, 12); Assert.Equal(expected, result); }
public void MuliplyByMatrix4x1ProducesMatrix4x2() { Matrix1x2 matrix1 = new Matrix1x2(3); Matrix4x1 matrix2 = new Matrix4x1(2); Matrix4x2 result = matrix1 * matrix2; Matrix4x2 expected = new Matrix4x2(6, 6, 6, 6, 6, 6, 6, 6); Assert.Equal(expected, result); }
public static void UniformMatrix4x2(int location, bool transpose, ref Matrix4x2 matrix) { unsafe { fixed(float *matrix_ptr = &matrix.Row0.X) { GL.UniformMatrix4x2(location, 1, transpose, matrix_ptr); } } }
public void MuliplyByMatrix4x4ProducesMatrix4x2() { Matrix4x2 matrix1 = new Matrix4x2(3); Matrix4x4 matrix2 = new Matrix4x4(2); Matrix4x2 result = matrix1 * matrix2; Matrix4x2 expected = new Matrix4x2(24, 24, 24, 24, 24, 24, 24, 24); Assert.Equal(expected, result); }
public void MuliplyByMatrix4x3ProducesMatrix4x2() { Matrix3x2 matrix1 = new Matrix3x2(3); Matrix4x3 matrix2 = new Matrix4x3(2); Matrix4x2 result = matrix1 * matrix2; Matrix4x2 expected = new Matrix4x2(18, 18, 18, 18, 18, 18, 18, 18); Assert.Equal(expected, result); }
public void SetUniform(string name, Matrix4x2 v, bool transpose) { //If the uniform doesn't exist, get it. if (!mUniform.ContainsKey(name)) { mUniform.Add(name, GL.GetUniformLocation(siProgramID, name)); } //Set the uniform. GL.ProgramUniformMatrix4x2(siProgramID, mUniform[name], transpose, ref v); }
public void HashCodeGenerationWorksCorrectly() { HashSet <int> hashCodes = new HashSet <int>(); Matrix4x2 value = new Matrix4x2(1); for (int i = 2; i <= 100; i++) { Assert.True(hashCodes.Add(value.GetHashCode()), "Unique hash code generation failure."); value *= i; } }
public void SimpleSubtractionGeneratesCorrectValues() { Matrix4x2 value1 = new Matrix4x2(100); Matrix4x2 value2 = new Matrix4x2(1); Matrix4x2 result = value1 - value2; for (int y = 0; y < Matrix4x2.RowCount; y++) { for (int x = 0; x < Matrix4x2.ColumnCount; x++) { Assert.Equal(100 - 1, result[x, y], Epsilon); } } }
public void ScalarMultiplicationIsCorrect() { GenerateFilledMatrixWithValues(out Matrix4x2 matrix4x2); for (double c = -10; c <= 10; c += 0.5) { Matrix4x2 result = matrix4x2 * c; for (int y = 0; y < matrix4x2.Rows; y++) { for (int x = 0; x < matrix4x2.Columns; x++) { Assert.Equal(matrix4x2[x, y] * c, result[x, y], Epsilon); } } } }
public void IndexerGetAndSetValuesCorrectly() { Matrix4x2 matrix4x2 = new Matrix4x2(); for (int x = 0; x < matrix4x2.Columns; x++) { for (int y = 0; y < matrix4x2.Rows; y++) { matrix4x2[x, y] = y * matrix4x2.Columns + x; } } for (int y = 0; y < matrix4x2.Rows; y++) { for (int x = 0; x < matrix4x2.Columns; x++) { Assert.Equal(y * matrix4x2.Columns + x, matrix4x2[x, y], Epsilon); } } }
public void AccessorThrowsWhenOutOfBounds() { Matrix4x2 matrix4x2 = new Matrix4x2(); try { matrix4x2[-1, 0] = 0; Assert.Fail("Matrix4x2[-1, 0] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } try { matrix4x2[0, -1] = 0; Assert.Fail("Matrix4x2[0, -1] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } try { matrix4x2[4, 0] = 0; Assert.Fail("Matrix4x2[4, 0] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } try { matrix4x2[0, 2] = 0; Assert.Fail("Matrix4x2[0, 2] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } }
private static void Set(int location, Matrix4x2 value) => GL.UniformMatrix4x2(location, false, ref value);
public void MuliplyByMatrix4x1ProducesMatrix4x2() { Matrix1x2 matrix1 = new Matrix1x2(3); Matrix4x1 matrix2 = new Matrix4x1(2); Matrix4x2 result = matrix1 * matrix2; Matrix4x2 expected = new Matrix4x2(6, 6, 6, 6, 6, 6, 6, 6); Assert.AreEqual(expected, result); }
private void GenerateFilledMatrixWithValues(out Matrix4x2 matrix) { matrix = new Matrix4x2(0, 1, 2, 3, 4, 5, 6, 7); }
public void SimpleSubtractionGeneratesCorrectValues() { Matrix4x2 value1 = new Matrix4x2(100); Matrix4x2 value2 = new Matrix4x2(1); Matrix4x2 result = value1 - value2; for (int y = 0; y < Matrix4x2.RowCount; y++) { for (int x = 0; x < Matrix4x2.ColumnCount; x++) { Assert.AreEqual(100 - 1, result[x, y], Epsilon); } } }
public void SimpleAdditionGeneratesCorrectValues() { Matrix4x2 value1 = new Matrix4x2(1); Matrix4x2 value2 = new Matrix4x2(99); Matrix4x2 result = value1 + value2; for (int y = 0; y < Matrix4x2.RowCount; y++) { for (int x = 0; x < Matrix4x2.ColumnCount; x++) { Assert.Equal(1 + 99, result[x, y], Epsilon); } } }
/// <summary> /// Sets the value of the uniform. /// </summary> /// <param name="value">The value.</param> /// <param name="transpose">Indicates whether to transpose the matrix value before transmitting it to the shader.</param> public unsafe void Set(ref Matrix4x2 value, bool transpose) { this.VerifyAccess(); fixed (Matrix4x2* pValue = &value) { GL.ProgramUniformMatrix4x2(this.Program, this.Location, 1, transpose, (float*)pValue); } }
public void MuliplyByMatrix4x2ProducesMatrix4x3() { Matrix2x3 matrix1 = new Matrix2x3(3); Matrix4x2 matrix2 = new Matrix4x2(2); Matrix4x3 result = matrix1 * matrix2; Matrix4x3 expected = new Matrix4x3(12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12); Assert.Equal(expected, result); }
public void MuliplyByMatrix4x2ProducesMatrix4x1() { Matrix2x1 matrix1 = new Matrix2x1(3); Matrix4x2 matrix2 = new Matrix4x2(2); Matrix4x1 result = matrix1 * matrix2; Matrix4x1 expected = new Matrix4x1(12, 12, 12, 12); Assert.AreEqual(expected, result); }
public void SetUniform(Matrix4x2 matrix, int id) { GL.UniformMatrix4x2(id, true, ref matrix); }
public static void UniformMatrix4x2(int location, bool transpose, ref Matrix4x2 matrix) { unsafe { fixed (float* matrix_ptr = &matrix.Row0.X) { GL.UniformMatrix4x2(location, 1, transpose, matrix_ptr); } } }
public void SetUniform(string uniform, Matrix4x2 value) { GL.UniformMatrix4x2(GL.GetUniformLocation(program, uniform), false, ref value); }
public void Set(ref Matrix4x2 value, bool transpose) { this.Uniform.Set(ref value, transpose); }
public void AccessorThrowsWhenOutOfBounds() { Matrix4x2 matrix4x2 = new Matrix4x2(); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix4x2[-1, 0] = 0; }); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix4x2[0, -1] = 0; }); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix4x2[4, 0] = 0; }); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix4x2[0, 2] = 0; }); }
/// <summary> /// Sets the value of the uniform. /// </summary> /// <remarks>The value will not be transposed.</remarks> /// <param name="value">The value.</param> public void Set(ref Matrix4x2 value) { this.Set(ref value, false); }
public void HashCodeGenerationWorksCorrectly() { HashSet<int> hashCodes = new HashSet<int>(); Matrix4x2 value = new Matrix4x2(1); for (int i = 2; i <= 100; i++) { if (!hashCodes.Add(value.GetHashCode())) { Assert.Fail("Unique hash code generation failure."); } value *= i; } }
public void MemberGetAndSetValuesCorrectly() { Matrix4x2 matrix4x2 = new Matrix4x2(); matrix4x2.M11 = 0; matrix4x2.M21 = 1; matrix4x2.M31 = 2; matrix4x2.M41 = 3; matrix4x2.M12 = 4; matrix4x2.M22 = 5; matrix4x2.M32 = 6; matrix4x2.M42 = 7; Assert.AreEqual(0, matrix4x2.M11, Epsilon); Assert.AreEqual(1, matrix4x2.M21, Epsilon); Assert.AreEqual(2, matrix4x2.M31, Epsilon); Assert.AreEqual(3, matrix4x2.M41, Epsilon); Assert.AreEqual(4, matrix4x2.M12, Epsilon); Assert.AreEqual(5, matrix4x2.M22, Epsilon); Assert.AreEqual(6, matrix4x2.M32, Epsilon); Assert.AreEqual(7, matrix4x2.M42, Epsilon); Assert.AreEqual(matrix4x2[0, 0], matrix4x2.M11, Epsilon); Assert.AreEqual(matrix4x2[1, 0], matrix4x2.M21, Epsilon); Assert.AreEqual(matrix4x2[2, 0], matrix4x2.M31, Epsilon); Assert.AreEqual(matrix4x2[3, 0], matrix4x2.M41, Epsilon); Assert.AreEqual(matrix4x2[0, 1], matrix4x2.M12, Epsilon); Assert.AreEqual(matrix4x2[1, 1], matrix4x2.M22, Epsilon); Assert.AreEqual(matrix4x2[2, 1], matrix4x2.M32, Epsilon); Assert.AreEqual(matrix4x2[3, 1], matrix4x2.M42, Epsilon); }
public void MuliplyByMatrix4x4ProducesMatrix4x2() { Matrix4x2 matrix1 = new Matrix4x2(3); Matrix4x4 matrix2 = new Matrix4x4(2); Matrix4x2 result = matrix1 * matrix2; Matrix4x2 expected = new Matrix4x2(24, 24, 24, 24, 24, 24, 24, 24); Assert.AreEqual(expected, result); }
public void MuliplyByMatrix4x3ProducesMatrix4x2() { Matrix3x2 matrix1 = new Matrix3x2(3); Matrix4x3 matrix2 = new Matrix4x3(2); Matrix4x2 result = matrix1 * matrix2; Matrix4x2 expected = new Matrix4x2(18, 18, 18, 18, 18, 18, 18, 18); Assert.AreEqual(expected, result); }
public void EqualityOperatorWorksCorrectly() { Matrix4x2 value1 = new Matrix4x2(100); Matrix4x2 value2 = new Matrix4x2(50) * 2; Assert.AreEqual(value1, value2); Assert.IsTrue(value1 == value2, "Equality operator failed."); }
public void Set(ref Matrix4x2 value) { this.Uniform.Set(ref value); }