Skip to content

Commit 895088a

Browse files
Merge pull request #677 from ForrestTrepte/fix/transformVectorUnitTests_issue675
fix #675 by implementing unit tests for TransformPoint and Inverse
2 parents 9616cf6 + 2aae9de commit 895088a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Assets/HoloToolkit-UnitTests/Editor/Utilities/Extensions/VectorExtensionsTests.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,26 @@ public void Vector3_RotateAround_Euler()
6868
[Test]
6969
public void Vector3_TransformPoint()
7070
{
71-
throw new NotImplementedException();
71+
Vector3 point = new Vector3(1f, 2f, 3f);
72+
Vector3 scale = new Vector3(2f, 3f, 4f); // scaled point: (2, 6, 12)
73+
Quaternion rotation = Quaternion.AngleAxis(180f, Vector3.up); // scaled rotated point: (-2, 6, -12)
74+
Vector3 translation = new Vector3(3f, 4f, 5f); // translated scaled rotated point: (1, 10, -7)
75+
Vector3 expected = new Vector3(1, 10, -7);
76+
Vector3 result = point.TransformPoint(translation, rotation, scale);
77+
Assert.That(Vector3.Distance(result, expected), Is.LessThan(0.00001f));
7278
}
7379

7480
[Test]
7581
public void Vector3_InverseTransformPoint()
7682
{
77-
throw new NotImplementedException();
83+
// Perform the same transformation as Vector3_TransformPoint in reverse.
84+
Vector3 point = new Vector3(1, 10, -7);
85+
Vector3 scale = new Vector3(2f, 3f, 4f);
86+
Quaternion rotation = Quaternion.AngleAxis(180f, Vector3.up);
87+
Vector3 translation = new Vector3(3f, 4f, 5f);
88+
Vector3 expected = new Vector3(1f, 2f, 3f);
89+
Vector3 result = point.InverseTransformPoint(translation, rotation, scale);
90+
Assert.That(Vector3.Distance(result, expected), Is.LessThan(0.00001f));
7891
}
7992

8093
[Test]

0 commit comments

Comments
 (0)