From b21d7f234b8ca1e8887830f7b4d65edeba22e3ac Mon Sep 17 00:00:00 2001 From: The4codeblocks <72419529+The4codeblocks@users.noreply.github.com> Date: Fri, 23 Jan 2026 11:08:10 -0500 Subject: [PATCH] [raymath] `QuaternionFromVector3ToVector3()`, math is wrong (#5508) * the math in QuaternionFromVector3ToVector3 is wrong * fix styling --- src/raymath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/raymath.h b/src/raymath.h index 7b58d410e..91c858e2a 100644 --- a/src/raymath.h +++ b/src/raymath.h @@ -2369,7 +2369,7 @@ RMAPI Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to) result.x = cross.x; result.y = cross.y; result.z = cross.z; - result.w = 1.0f + cos2Theta; + result.w = sqrtf(cross.x*cross.x + cross.y*cross.y + cross.z*cross.z + cos2Theta*cos2Theta) + cos2Theta; // sqrtf(Vector3DotProduct(cross, cross) + cos2Theta * cos2Theta) + cos2Theta // QuaternionNormalize(q); // NOTE: Normalize to essentially nlerp the original and identity to 0.5