public void ConstructorValuesAreAccessibleByIndexer() { Matrix2x4 matrix2x4; matrix2x4 = new Matrix2x4(); for (int x = 0; x < matrix2x4.Columns; x++) { for (int y = 0; y < matrix2x4.Rows; y++) { Assert.Equal(0, matrix2x4[x, y], Epsilon); } } double value = 33.33; matrix2x4 = new Matrix2x4(value); for (int x = 0; x < matrix2x4.Columns; x++) { for (int y = 0; y < matrix2x4.Rows; y++) { Assert.Equal(value, matrix2x4[x, y], Epsilon); } } GenerateFilledMatrixWithValues(out matrix2x4); for (int y = 0; y < matrix2x4.Rows; y++) { for (int x = 0; x < matrix2x4.Columns; x++) { Assert.Equal(y * matrix2x4.Columns + x, matrix2x4[x, y], Epsilon); } } }
public void MuliplyByMatrix2x4ProducesMatrix2x1() { Matrix4x1 matrix1 = new Matrix4x1(3); Matrix2x4 matrix2 = new Matrix2x4(2); Matrix2x1 result = matrix1 * matrix2; Matrix2x1 expected = new Matrix2x1(24, 24); Assert.Equal(expected, result); }
public void ConstantValuesAreCorrect() { Matrix2x4 matrix2x4 = new Matrix2x4(); Assert.Equal(2, matrix2x4.Columns); Assert.Equal(4, matrix2x4.Rows); Assert.Equal(Matrix2x4.ColumnCount, matrix2x4.Columns); Assert.Equal(Matrix2x4.RowCount, matrix2x4.Rows); }
public void AccessorThrowsWhenOutOfBounds() { Matrix2x4 matrix2x4 = new Matrix2x4(); Assert.Throws <ArgumentOutOfRangeException>(() => { matrix2x4[-1, 0] = 0; }); Assert.Throws <ArgumentOutOfRangeException>(() => { matrix2x4[0, -1] = 0; }); Assert.Throws <ArgumentOutOfRangeException>(() => { matrix2x4[2, 0] = 0; }); Assert.Throws <ArgumentOutOfRangeException>(() => { matrix2x4[0, 4] = 0; }); }
public static void UniformMatrix2x4(int location, bool transpose, ref Matrix2x4 matrix) { unsafe { fixed(float *matrix_ptr = &matrix.Row0.X) { GL.UniformMatrix2x4(location, 1, transpose, matrix_ptr); } } }
public void SetUniform(string name, Matrix2x4 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.ProgramUniformMatrix2x4(siProgramID, mUniform[name], transpose, ref v); }
public void MuliplyByMatrix4x2ProducesMatrix4x4() { Matrix2x4 matrix1 = new Matrix2x4(3); Matrix4x2 matrix2 = new Matrix4x2(2); Matrix4x4 result = matrix1 * matrix2; Matrix4x4 expected = new Matrix4x4(12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12); Assert.Equal(expected, result); }
public void MuliplyByMatrix2x1ProducesMatrix2x4() { Matrix1x4 matrix1 = new Matrix1x4(3); Matrix2x1 matrix2 = new Matrix2x1(2); Matrix2x4 result = matrix1 * matrix2; Matrix2x4 expected = new Matrix2x4(6, 6, 6, 6, 6, 6, 6, 6); Assert.Equal(expected, result); }
public void HashCodeGenerationWorksCorrectly() { HashSet <int> hashCodes = new HashSet <int>(); Matrix2x4 value = new Matrix2x4(1); for (int i = 2; i <= 100; i++) { Assert.True(hashCodes.Add(value.GetHashCode()), "Unique hash code generation failure."); value *= i; } }
public void MuliplyByMatrix2x3ProducesMatrix2x4() { Matrix3x4 matrix1 = new Matrix3x4(3); Matrix2x3 matrix2 = new Matrix2x3(2); Matrix2x4 result = matrix1 * matrix2; Matrix2x4 expected = new Matrix2x4(18, 18, 18, 18, 18, 18, 18, 18); Assert.Equal(expected, result); }
public void SimpleSubtractionGeneratesCorrectValues() { Matrix2x4 value1 = new Matrix2x4(100); Matrix2x4 value2 = new Matrix2x4(1); Matrix2x4 result = value1 - value2; for (int y = 0; y < Matrix2x4.RowCount; y++) { for (int x = 0; x < Matrix2x4.ColumnCount; x++) { Assert.Equal(100 - 1, result[x, y], Epsilon); } } }
public void ScalarMultiplicationIsCorrect() { GenerateFilledMatrixWithValues(out Matrix2x4 matrix2x4); for (double c = -10; c <= 10; c += 0.5) { Matrix2x4 result = matrix2x4 * c; for (int y = 0; y < matrix2x4.Rows; y++) { for (int x = 0; x < matrix2x4.Columns; x++) { Assert.Equal(matrix2x4[x, y] * c, result[x, y], Epsilon); } } } }
public void IndexerGetAndSetValuesCorrectly() { Matrix2x4 matrix2x4 = new Matrix2x4(); for (int x = 0; x < matrix2x4.Columns; x++) { for (int y = 0; y < matrix2x4.Rows; y++) { matrix2x4[x, y] = y * matrix2x4.Columns + x; } } for (int y = 0; y < matrix2x4.Rows; y++) { for (int x = 0; x < matrix2x4.Columns; x++) { Assert.Equal(y * matrix2x4.Columns + x, matrix2x4[x, y], Epsilon); } } }
public void AccessorThrowsWhenOutOfBounds() { Matrix2x4 matrix2x4 = new Matrix2x4(); try { matrix2x4[-1, 0] = 0; Assert.Fail("Matrix2x4[-1, 0] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } try { matrix2x4[0, -1] = 0; Assert.Fail("Matrix2x4[0, -1] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } try { matrix2x4[2, 0] = 0; Assert.Fail("Matrix2x4[2, 0] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } try { matrix2x4[0, 4] = 0; Assert.Fail("Matrix2x4[0, 4] did not throw when it should have."); } catch (ArgumentOutOfRangeException) { } }
private void GenerateFilledMatrixWithValues(out Matrix2x4 matrix) { matrix = new Matrix2x4(0, 1, 2, 3, 4, 5, 6, 7); }
public void AccessorThrowsWhenOutOfBounds() { Matrix2x4 matrix2x4 = new Matrix2x4(); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix2x4[-1, 0] = 0; }); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix2x4[0, -1] = 0; }); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix2x4[2, 0] = 0; }); Assert.Throws<ArgumentOutOfRangeException>(() => { matrix2x4[0, 4] = 0; }); }
private static void Set(int location, Matrix2x4 value) => GL.UniformMatrix2x4(location, false, ref value);
public static void UniformMatrix2x4(int location, bool transpose, ref Matrix2x4 matrix) { unsafe { fixed (float* matrix_ptr = &matrix.Row0.X) { GL.UniformMatrix2x4(location, 1, transpose, matrix_ptr); } } }
public void SetUniform(string uniform, Matrix2x4 value) { GL.UniformMatrix2x4(GL.GetUniformLocation(program, uniform), false, ref value); }
/// <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 Matrix2x4 value, bool transpose) { this.VerifyAccess(); fixed (Matrix2x4* pValue = &value) { GL.ProgramUniformMatrix2x4(this.Program, this.Location, 1, transpose, (float*)pValue); } }
public void MemberGetAndSetValuesCorrectly() { Matrix2x4 matrix2x4 = new Matrix2x4(); matrix2x4.M11 = 0; matrix2x4.M21 = 1; matrix2x4.M12 = 2; matrix2x4.M22 = 3; matrix2x4.M13 = 4; matrix2x4.M23 = 5; matrix2x4.M14 = 6; matrix2x4.M24 = 7; Assert.Equal(0, matrix2x4.M11, Epsilon); Assert.Equal(1, matrix2x4.M21, Epsilon); Assert.Equal(2, matrix2x4.M12, Epsilon); Assert.Equal(3, matrix2x4.M22, Epsilon); Assert.Equal(4, matrix2x4.M13, Epsilon); Assert.Equal(5, matrix2x4.M23, Epsilon); Assert.Equal(6, matrix2x4.M14, Epsilon); Assert.Equal(7, matrix2x4.M24, Epsilon); Assert.Equal(matrix2x4[0, 0], matrix2x4.M11, Epsilon); Assert.Equal(matrix2x4[1, 0], matrix2x4.M21, Epsilon); Assert.Equal(matrix2x4[0, 1], matrix2x4.M12, Epsilon); Assert.Equal(matrix2x4[1, 1], matrix2x4.M22, Epsilon); Assert.Equal(matrix2x4[0, 2], matrix2x4.M13, Epsilon); Assert.Equal(matrix2x4[1, 2], matrix2x4.M23, Epsilon); Assert.Equal(matrix2x4[0, 3], matrix2x4.M14, Epsilon); Assert.Equal(matrix2x4[1, 3], matrix2x4.M24, Epsilon); }
public void Set(ref Matrix2x4 value, bool transpose) { this.Uniform.Set(ref value, transpose); }
public void SimpleAdditionGeneratesCorrectValues() { Matrix2x4 value1 = new Matrix2x4(1); Matrix2x4 value2 = new Matrix2x4(99); Matrix2x4 result = value1 + value2; for (int y = 0; y < Matrix2x4.RowCount; y++) { for (int x = 0; x < Matrix2x4.ColumnCount; x++) { Assert.AreEqual(1 + 99, result[x, y], Epsilon); } } }
public void MuliplyByMatrix2x1ProducesMatrix2x4() { Matrix1x4 matrix1 = new Matrix1x4(3); Matrix2x1 matrix2 = new Matrix2x1(2); Matrix2x4 result = matrix1 * matrix2; Matrix2x4 expected = new Matrix2x4(6, 6, 6, 6, 6, 6, 6, 6); Assert.AreEqual(expected, result); }
/// <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 Matrix2x4 value) { this.Set(ref value, false); }
public void MuliplyByMatrix2x4ProducesMatrix2x3() { Matrix4x3 matrix1 = new Matrix4x3(3); Matrix2x4 matrix2 = new Matrix2x4(2); Matrix2x3 result = matrix1 * matrix2; Matrix2x3 expected = new Matrix2x3(24, 24, 24, 24, 24, 24); Assert.Equal(expected, result); }
public void HashCodeGenerationWorksCorrectly() { HashSet<int> hashCodes = new HashSet<int>(); Matrix2x4 value = new Matrix2x4(1); for (int i = 2; i <= 100; i++) { Assert.True(hashCodes.Add(value.GetHashCode()), "Unique hash code generation failure."); value *= i; } }
public void SetUniform(Matrix2x4 matrix, int id) { GL.UniformMatrix2x4(id, true, ref matrix); }
public void EqualityOperatorWorksCorrectly() { Matrix2x4 value1 = new Matrix2x4(100); Matrix2x4 value2 = new Matrix2x4(50) * 2; Assert.Equal(value1, value2); Assert.True(value1 == value2, "Equality operator failed."); }
public void MuliplyByMatrix2x4ProducesMatrix2x2() { Matrix4x2 matrix1 = new Matrix4x2(3); Matrix2x4 matrix2 = new Matrix2x4(2); Matrix2x2 result = matrix1 * matrix2; Matrix2x2 expected = new Matrix2x2(24, 24, 24, 24); Assert.AreEqual(expected, result); }
public void Set(ref Matrix2x4 value) { this.Uniform.Set(ref value); }