From 6f61bb4d2edbbb6b79fcb11596e91ceae48cae8c Mon Sep 17 00:00:00 2001 From: Olivier Sohn Date: Sat, 21 Oct 2017 21:17:55 +0200 Subject: [PATCH] Fix rotation when vectors are in the same direction #690 --- glm/gtx/quaternion.inl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index 5595ec38..f57082fa 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -184,8 +184,10 @@ namespace glm T cosTheta = dot(orig, dest); vec<3, T, Q> rotationAxis; - if(cosTheta >= static_cast(1) - epsilon()) - return quat(); + if(cosTheta >= static_cast(1) - epsilon()) { + // orig and dest point in the same direction : return identity quaternion. + return quat(1, 0, 0, 0); + } if(cosTheta < static_cast(-1) + epsilon()) {