public void Matrix3x2MultiplyTest3() { Matrix3x2 a = GenerateMatrixNumberFrom1To6(); Matrix3x2 b = GenerateMatrixNumberFrom1To6(); Matrix3x2 expected = new Matrix3x2(); expected.M11 = a.M11 * b.M11 + a.M12 * b.M21; expected.M12 = a.M11 * b.M12 + a.M12 * b.M22; expected.M21 = a.M21 * b.M11 + a.M22 * b.M21; expected.M22 = a.M21 * b.M12 + a.M22 * b.M22; expected.M31 = a.M31 * b.M11 + a.M32 * b.M21 + b.M31; expected.M32 = a.M31 * b.M12 + a.M32 * b.M22 + b.M32; Matrix3x2 actual; actual = Matrix3x2.Multiply(a, b); Assert.Equal(expected, actual); // Sanity check by comparison with 4x4 multiply. a = Matrix3x2.CreateRotation(MathHelper.ToRadians(30)) * Matrix3x2.CreateTranslation(23, 42); b = Matrix3x2.CreateScale(3, 7) * Matrix3x2.CreateTranslation(666, -1); actual = Matrix3x2.Multiply(a, b); Matrix4x4 a44 = new Matrix4x4(a); Matrix4x4 b44 = new Matrix4x4(b); Matrix4x4 expected44 = Matrix4x4.Multiply(a44, b44); Matrix4x4 actual44 = new Matrix4x4(actual); Assert.True(MathHelper.Equal(expected44, actual44), "Matrix3x2.Multiply did not return the expected value."); }
public void Matrix3x2CreateTranslationTest1() { Vector2 position = new Vector2(2.0f, 3.0f); Matrix3x2 expected = new Matrix3x2( 1.0f, 0.0f, 0.0f, 1.0f, 2.0f, 3.0f); Matrix3x2 actual = Matrix3x2.CreateTranslation(position); Assert.Equal(expected, actual); }
public void Matrix3x2InvertTranslationTest() { Matrix3x2 mtx = Matrix3x2.CreateTranslation(23, 42); Matrix3x2 actual; Assert.True(Matrix3x2.Invert(mtx, out actual)); Matrix3x2 i = mtx * actual; Assert.True(MathHelper.Equal(i, Matrix3x2.Identity)); }
public void Matrix3x2CreateTranslationTest2() { Single xPosition = 2.0f; Single yPosition = 3.0f; Matrix3x2 expected = new Matrix3x2( 1.0f, 0.0f, 0.0f, 1.0f, 2.0f, 3.0f); Matrix3x2 actual = Matrix3x2.CreateTranslation(xPosition, yPosition); Assert.Equal(expected, actual); }
public void Matrix3x2InvertAffineTest() { Matrix3x2 mtx = Matrix3x2.CreateRotation(2) * Matrix3x2.CreateScale(23, -42) * Matrix3x2.CreateTranslation(17, 53); Matrix3x2 actual; Assert.True(Matrix3x2.Invert(mtx, out actual)); Matrix3x2 i = mtx * actual; Assert.True(MathHelper.Equal(i, Matrix3x2.Identity)); }
public void Matrix3x2CreateSkewCenterTest() { Single skewX = 1, skewY = 2; Vector2 center = new Vector2(23, 42); Matrix3x2 skewAroundZero = Matrix3x2.CreateSkew(skewX, skewY, Vector2.Zero); Matrix3x2 skewAroundZeroExpected = Matrix3x2.CreateSkew(skewX, skewY); Assert.True(MathHelper.Equal(skewAroundZero, skewAroundZeroExpected)); Matrix3x2 skewAroundCenter = Matrix3x2.CreateSkew(skewX, skewY, center); Matrix3x2 skewAroundCenterExpected = Matrix3x2.CreateTranslation(-center) * Matrix3x2.CreateSkew(skewX, skewY) * Matrix3x2.CreateTranslation(center); Assert.True(MathHelper.Equal(skewAroundCenter, skewAroundCenterExpected)); }
public void Matrix3x2CreateScaleCenterTest3() { Vector2 scale = new Vector2(3, 4); Vector2 center = new Vector2(23, 42); Matrix3x2 scaleAroundZero = Matrix3x2.CreateScale(scale.X, scale.Y, Vector2.Zero); Matrix3x2 scaleAroundZeroExpected = Matrix3x2.CreateScale(scale.X, scale.Y); Assert.True(MathHelper.Equal(scaleAroundZero, scaleAroundZeroExpected)); Matrix3x2 scaleAroundCenter = Matrix3x2.CreateScale(scale.X, scale.Y, center); Matrix3x2 scaleAroundCenterExpected = Matrix3x2.CreateTranslation(-center) * Matrix3x2.CreateScale(scale.X, scale.Y) * Matrix3x2.CreateTranslation(center); Assert.True(MathHelper.Equal(scaleAroundCenter, scaleAroundCenterExpected)); }
public void Matrix3x2CreateScaleCenterTest2() { Single scale = 5; Vector2 center = new Vector2(23, 42); Matrix3x2 scaleAroundZero = Matrix3x2.CreateScale(scale, Vector2.Zero); Matrix3x2 scaleAroundZeroExpected = Matrix3x2.CreateScale(scale); Assert.True(MathHelper.Equal(scaleAroundZero, scaleAroundZeroExpected)); Matrix3x2 scaleAroundCenter = Matrix3x2.CreateScale(scale, center); Matrix3x2 scaleAroundCenterExpected = Matrix3x2.CreateTranslation(-center) * Matrix3x2.CreateScale(scale) * Matrix3x2.CreateTranslation(center); Assert.True(MathHelper.Equal(scaleAroundCenter, scaleAroundCenterExpected)); }
public void Matrix3x2CreateRotationCenterTest() { Single radians = MathHelper.ToRadians(30.0f); Vector2 center = new Vector2(23, 42); Matrix3x2 rotateAroundZero = Matrix3x2.CreateRotation(radians, Vector2.Zero); Matrix3x2 rotateAroundZeroExpected = Matrix3x2.CreateRotation(radians); Assert.True(MathHelper.Equal(rotateAroundZero, rotateAroundZeroExpected)); Matrix3x2 rotateAroundCenter = Matrix3x2.CreateRotation(radians, center); Matrix3x2 rotateAroundCenterExpected = Matrix3x2.CreateTranslation(-center) * Matrix3x2.CreateRotation(radians) * Matrix3x2.CreateTranslation(center); Assert.True(MathHelper.Equal(rotateAroundCenter, rotateAroundCenterExpected)); }