MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / TestLocalToWorld

Method TestLocalToWorld

Source/Engine/Tests/TestTransform.cs:47–74  ·  view source on GitHub ↗

Tests the local space to world space conversion.

()

Source from the content-addressed store, hash-verified

45 /// Tests the local space to world space conversion.
46 /// </summary>
47 [Test]
48 public void TestLocalToWorld()
49 {
50 Transform t1 = new Transform(new Vector3(10, 1, 10), Quaternion.Euler(45, 0, -15), new Float3(1.5f, 0.5f, 0.1f));
51 Transform t2 = new Transform(new Vector3(0, 20, 0), Quaternion.Euler(0, 0, 15), new Float3(1.0f, 2.0f, 1.0f));
52
53 Transform a1 = t1.LocalToWorld(t2);
54 Vector3 a2 = t1.LocalToWorld(t2.Translation);
55
56 Vector3 a3;
57 {
58 Vector3 result;
59 Matrix scale, rotation, scaleRotation;
60 Matrix.Scaling(ref t1.Scale, out scale);
61 Matrix.RotationQuaternion(ref t1.Orientation, out rotation);
62 Matrix.Multiply(ref scale, ref rotation, out scaleRotation);
63 Vector3.Transform(ref t2.Translation, ref scaleRotation, out result);
64 a3 = result + t1.Translation;
65 }
66
67 var a4T = new Vector3[1];
68 t1.LocalToWorld(new Vector3[1] { t2.Translation }, a4T);
69 Vector3 a4 = a4T[0];
70
71 Assert.IsTrue(Vector3.NearEqual(a1.Translation, a2));
72 Assert.IsTrue(Vector3.NearEqual(a2, a3));
73 Assert.IsTrue(Vector3.NearEqual(a2, a4));
74 }
75
76 /// <summary>
77 /// Tests the world space to local space conversion.

Callers

nothing calls this directly

Calls 8

EulerMethod · 0.45
LocalToWorldMethod · 0.45
ScalingMethod · 0.45
RotationQuaternionMethod · 0.45
MultiplyMethod · 0.45
TransformMethod · 0.45
IsTrueMethod · 0.45
NearEqualMethod · 0.45

Tested by

no test coverage detected