public void Matrix3x2CreateSkewIdentityTest() { Matrix3x2 expected = Matrix3x2.Identity; Matrix3x2 actual = Matrix3x2.CreateSkew(0, 0); Assert.Equal(expected, actual); }
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 Matrix3x2CreateSkewXYTest() { Matrix3x2 expected = new Matrix3x2(1, -0.414213562373095f, 1, 1, 0, 0); Matrix3x2 actual = Matrix3x2.CreateSkew(MathHelper.Pi / 4, -MathHelper.Pi / 8); Assert.True(MathHelper.Equal(expected, actual)); Vector2 result = Vector2.Transform(new Vector2(0, 0), actual); Assert.True(MathHelper.Equal(new Vector2(0, 0), result)); result = Vector2.Transform(new Vector2(1, 0), actual); Assert.True(MathHelper.Equal(new Vector2(1, -0.414213562373095f), result)); result = Vector2.Transform(new Vector2(0, 1), actual); Assert.True(MathHelper.Equal(new Vector2(1, 1), result)); result = Vector2.Transform(new Vector2(1, 1), actual); Assert.True(MathHelper.Equal(new Vector2(2, 0.585786437626905f), result)); }
public void Matrix3x2CreateSkewYTest() { Matrix3x2 expected = new Matrix3x2(1, -0.414213562373095f, 0, 1, 0, 0); Matrix3x2 actual = Matrix3x2.CreateSkew(0, -MathHelper.Pi / 8); Assert.True(MathHelper.Equal(expected, actual)); expected = new Matrix3x2(1, 0.414213562373095f, 0, 1, 0, 0); actual = Matrix3x2.CreateSkew(0, MathHelper.Pi / 8); Assert.True(MathHelper.Equal(expected, actual)); Vector2 result = Vector2.Transform(new Vector2(0, 0), actual); Assert.True(MathHelper.Equal(new Vector2(0, 0), result)); result = Vector2.Transform(new Vector2(1, 0), actual); Assert.True(MathHelper.Equal(new Vector2(1, 0.414213568f), result)); result = Vector2.Transform(new Vector2(-1, 0), actual); Assert.True(MathHelper.Equal(new Vector2(-1, -0.414213568f), result)); result = Vector2.Transform(new Vector2(10, 3), actual); Assert.True(MathHelper.Equal(new Vector2(10, 7.14213568f), result)); }