diff options
| author | Ray <[email protected]> | 2017-05-04 17:41:51 +0200 |
|---|---|---|
| committer | Ray <[email protected]> | 2017-05-04 17:41:51 +0200 |
| commit | 70a7c656684beec828d29d94cc556c3a25ac75b8 (patch) | |
| tree | abaacbef49f6f917d326de62ab1d0135c8495a49 /src/raymath.h | |
| parent | 18b31f67921c28ec71b610fbdca8b13532f11500 (diff) | |
| download | raylib-70a7c656684beec828d29d94cc556c3a25ac75b8.tar.gz raylib-70a7c656684beec828d29d94cc556c3a25ac75b8.zip | |
Return angles as degrees
Diffstat (limited to 'src/raymath.h')
| -rw-r--r-- | src/raymath.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/raymath.h b/src/raymath.h index 83d0531d..1dbebc07 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -1203,6 +1203,7 @@ RMDEF Quaternion QuaternionFromEuler(float roll, float pitch, float yaw) } // Return the Euler angles equivalent to quaternion (roll, pitch, yaw) +// NOTE: Angles are returned in a Vector3 struct and in degrees RMDEF Vector3 QuaternionToEuler(Quaternion q) { Vector3 v = { 0 }; @@ -1210,18 +1211,18 @@ RMDEF Vector3 QuaternionToEuler(Quaternion q) // roll (x-axis rotation) float x0 = 2.0f*(q.w*q.x + q.y*q.z); float x1 = 1.0f - 2.0f*(q.x*q.x + q.y*q.y); - v.x = atan2f(x0, x1); + v.x = atan2f(x0, x1)*RAD2DEG; // pitch (y-axis rotation) float y0 = 2.0f*(q.w*q.y - q.z*q.x); y0 = y0 > 1.0f ? 1.0f : y0; y0 = y0 < -1.0f ? -1.0f : y0; - v.y = asinf(y0); + v.y = asinf(y0)*RAD2DEG; // yaw (z-axis rotation) float z0 = 2.0f*(q.w*q.z + q.x*q.y); float z1 = 1.0f - 2.0f*(q.y*q.y + q.z*q.z); - v.z = atan2f(z0, z1); + v.z = atan2f(z0, z1)*RAD2DEG; return v; } |
