From 967b1ce005a7c9c7b9e560db68045d582792c220 Mon Sep 17 00:00:00 2001 From: hearga Date: Tue, 4 Jun 2024 15:30:16 -0400 Subject: [PATCH] Update quat.h If from and to vectors are close to being opposite, it is not handled properly. For example, if from is (0,0,1) and to is (0,0,-1) the dot product is -1 this will imply that the axis will be (0,0,0), the length = 0 and the inversenorm will be infinite. For the solution, note that div is always greater than dot_pd --- include/vsg/maths/quat.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/vsg/maths/quat.h b/include/vsg/maths/quat.h index c2d703d19..e80456b33 100644 --- a/include/vsg/maths/quat.h +++ b/include/vsg/maths/quat.h @@ -119,7 +119,7 @@ namespace vsg value_type dot_pd = vsg::dot(from, to); value_type div = std::sqrt(length2(from) * length2(to)); vsg::dvec3 axis; - if (div - dot_pd < epsilon) + if (div - std::abs(dot_pd) < epsilon) { axis = orthogonal(from); }