public void TestStaticFn_TransformMatix44_i ()
{
Single pi; Maths.Pi (out pi);
Single piOver2 = pi / (Single) 2;
Single minusPi = -pi;
Vector4 v1 = new Vector4 (10, 50, -20, 100);
Matrix44 rotmati = Matrix44.Identity;
Matrix44 rotmat1; Matrix44.CreateRotationX(ref pi, out rotmat1);
Matrix44 rotmat2; Matrix44.CreateRotationY(ref piOver2, out rotmat2);
Matrix44 rotmat3; Matrix44.CreateRotationZ(ref minusPi, out rotmat3);
Matrix44 rotmat4 = rotmat1 * rotmat2 * rotmat3;
var tests = new Tuple<Vector4, Matrix44, Vector4>[]
{
//vector -> transform -> expected
new Tuple<Vector4, Matrix44, Vector4>(
v1, rotmati, v1),
new Tuple<Vector4, Matrix44, Vector4>(
v1, rotmat1, new Vector4 (10, -50, 20, 100)),
new Tuple<Vector4, Matrix44, Vector4>(
v1, rotmat2, new Vector4 (-20, 50, -10, 100)),
new Tuple<Vector4, Matrix44, Vector4>(
v1, rotmat3, new Vector4 (-10, -50, -20, 100)),
new Tuple<Vector4, Matrix44, Vector4>(
v1, rotmat4, new Vector4 (-20, 50, -10, 100))
};
foreach (var test in tests)
{
Vector4 vec = test.Item1;
Matrix44 trans = test.Item2;
Vector4 expected = test.Item3;
Vector4 result;
Vector4.Transform (ref vec, ref trans, out result);
AssertEqualWithinReason(result, expected);
}
}