Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/DQ.cpp
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -39,13 +39,18 @@ 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() to match the MATLAB implementation in PR #77
(https://github.com/dqrobotics/cpp/pull/77).
*/

#include <dqrobotics/DQ.h>
#include <sstream>
#include <stdexcept> //for range_error
#include <vector>
#include <cmath>
#include <limits>

namespace DQ_robotics{

Expand Down Expand Up @@ -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<double>::epsilon())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed implementation seems to match MATLAB literaly.
https://github.com/dqrobotics/matlab/blob/master/%40DQ/rotation_axis.m

return k_; // DQ(0,0,0,1). This is only a convention;
else
{
Expand Down
Loading