From b2712b6db7c184aff47436f387f2012cf77f4f67 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 23 Jul 2017 17:29:51 +0200 Subject: [PATCH] Corrected issue on QuaternionFromVector3ToVector3() --- src/raymath.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/raymath.h b/src/raymath.h index 855f97b00..cd45c0b55 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -1126,13 +1126,15 @@ RMDEF Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to) q.x = cross.x; q.y = cross.y; q.z = cross.y; - q.w = 1.0f + cos2Theta; - - QuaternionNormalize(&q); + q.w = 1.0f + cos2Theta; // NOTE: Added QuaternioIdentity() - Quaternion result = QuaternionNlerp(q, QuaternionIdentity(), 0.5f); + // Normalize to essentially nlerp the original and identity to 0.5 + QuaternionNormalize(&q); - return result; + // Above lines are equivalent to: + //Quaternion result = QuaternionNlerp(q, QuaternionIdentity(), 0.5f); + + return q; } // Returns a quaternion for a given rotation matrix