From 316e1b89143280c830a74043022d7e4b0bd1111d Mon Sep 17 00:00:00 2001 From: Juancho Date: Tue, 10 Nov 2026 22:56:11 +0000 Subject: [PATCH 1/2] [DQ.cpp] Fix rotation_axis() to match the Matlab implementation --- src/DQ.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/DQ.cpp b/src/DQ.cpp index 7043a68..7191e94 100644 --- a/src/DQ.cpp +++ b/src/DQ.cpp @@ -1,5 +1,5 @@ /** -(C) Copyright 2011-2023 DQ Robotics Developers +(C) Copyright 2011-2026 DQ Robotics Developers This file is part of DQ Robotics. @@ -39,6 +39,10 @@ This file is part of DQ Robotics. 4. Marcos da Silva Pereira (marcos.si.pereira@gmail.com) - Translated the Q4 and the Q8 methods from the MATLAB implementation in PR #56 (https://github.com/dqrobotics/cpp/pull/56). + +5. Juan Jose Quiroz Omana (juanjqogm@gmail.com) + - Fixed rotation_axis() for rotation angles close to 2*pi, using the same guard as the MATLAB + implementation, in PR # (https://github.com/dqrobotics/cpp/pull/). */ #include @@ -46,6 +50,7 @@ This file is part of DQ Robotics. #include //for range_error #include #include +#include namespace DQ_robotics{ @@ -689,7 +694,7 @@ DQ DQ::rotation_axis() const{ } double phi = rotation_angle()/2.0; - if(phi == 0.0) + if (sin(phi) <= std::numeric_limits::epsilon()) return k_; // DQ(0,0,0,1). This is only a convention; else { From 4aea03e642ae0f51392d155dec9684f9b465b11a Mon Sep 17 00:00:00 2001 From: Juancho Date: Tue, 10 Nov 2026 23:13:09 +0000 Subject: [PATCH 2/2] [DQ.cpp] Updated the PR number in the contribution section --- src/DQ.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DQ.cpp b/src/DQ.cpp index 7191e94..9b335c8 100644 --- a/src/DQ.cpp +++ b/src/DQ.cpp @@ -41,8 +41,8 @@ This file is part of DQ Robotics. (https://github.com/dqrobotics/cpp/pull/56). 5. Juan Jose Quiroz Omana (juanjqogm@gmail.com) - - Fixed rotation_axis() for rotation angles close to 2*pi, using the same guard as the MATLAB - implementation, in PR # (https://github.com/dqrobotics/cpp/pull/). + - Fixed rotation_axis() to match the MATLAB implementation in PR #77 + (https://github.com/dqrobotics/cpp/pull/77). */ #include