Skip to content

Commit

Permalink
Merge pull request #677 from ForrestTrepte/fix/transformVectorUnitTes…
Browse files Browse the repository at this point in the history
…ts_issue675

fix #675 by implementing unit tests for TransformPoint and Inverse
  • Loading branch information
StephenHodgson committed May 24, 2017
2 parents 9616cf6 + 2aae9de commit 895088a
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -68,13 +68,26 @@ public void Vector3_RotateAround_Euler()
[Test]
public void Vector3_TransformPoint()
{
throw new NotImplementedException();
Vector3 point = new Vector3(1f, 2f, 3f);
Vector3 scale = new Vector3(2f, 3f, 4f); // scaled point: (2, 6, 12)
Quaternion rotation = Quaternion.AngleAxis(180f, Vector3.up); // scaled rotated point: (-2, 6, -12)
Vector3 translation = new Vector3(3f, 4f, 5f); // translated scaled rotated point: (1, 10, -7)
Vector3 expected = new Vector3(1, 10, -7);
Vector3 result = point.TransformPoint(translation, rotation, scale);
Assert.That(Vector3.Distance(result, expected), Is.LessThan(0.00001f));
}

[Test]
public void Vector3_InverseTransformPoint()
{
throw new NotImplementedException();
// Perform the same transformation as Vector3_TransformPoint in reverse.
Vector3 point = new Vector3(1, 10, -7);
Vector3 scale = new Vector3(2f, 3f, 4f);
Quaternion rotation = Quaternion.AngleAxis(180f, Vector3.up);
Vector3 translation = new Vector3(3f, 4f, 5f);
Vector3 expected = new Vector3(1f, 2f, 3f);
Vector3 result = point.InverseTransformPoint(translation, rotation, scale);
Assert.That(Vector3.Distance(result, expected), Is.LessThan(0.00001f));
}

[Test]
Expand Down

0 comments on commit 895088a

Please sign in to comment.