Physics2D tests (#129)

* Quaternion: Fix singularity on Z axis when converting to euler angles

* CollisionComponent2D: Add method to retrieve AABB

* Collider2D: Fix constructor for Box with Vector2

* Physics2D: Fix rotation (Chipmunk works with radian and Nazara degrees) and copy constructor of RigidBody2D

* Colider2D: Add New for convex and tests for the new classes
This commit is contained in:
Gawaboumga
2017-08-20 21:47:23 +02:00
committed by Jérôme Leclercq
parent 9806231b5c
commit 41a1b5d493
12 changed files with 860 additions and 37 deletions

View File

@@ -481,11 +481,11 @@ namespace Nz
T test = x * y + z * w;
if (test > F(0.499))
// singularity at north pole
return EulerAngles<T>(FromDegrees(F(90.0)), FromRadians(F(2.0) * std::atan2(x, w)), F(0.0));
return EulerAngles<T>(F(0.0), FromRadians(F(2.0) * std::atan2(x, w)), FromDegrees(F(90.0)));
if (test < F(-0.499))
// singularity at south pole
return EulerAngles<T>(FromDegrees(F(-90.0)), FromRadians(F(-2.0) * std::atan2(x, w)), F(0.0));
return EulerAngles<T>(F(0.0), FromRadians(F(-2.0) * std::atan2(x, w)), FromDegrees(F(-90.0)));
return EulerAngles<T>(FromRadians(std::atan2(F(2.0) * x * w - F(2.0) * y * z, F(1.0) - F(2.0) * x * x - F(2.0) * z * z)),
FromRadians(std::atan2(F(2.0) * y * w - F(2.0) * x * z, F(1.0) - F(2.0) * y * y - F(2.0) * z * z)),