Repository navigation
[DQ.cpp] Fix rotation_axis() to match the Matlab implementation - #77
Merged
Merged
Conversation
juanjqo
marked this pull request as ready for review
November 10, 2026 23:13
mmmarinho
approved these changes
Nov 11, 2026
|
|
||
| double phi = rotation_angle()/2.0; | ||
| if(phi == 0.0) | ||
| if (sin(phi) <= std::numeric_limits<double>::epsilon()) |
Member
There was a problem hiding this comment.
Indeed implementation seems to match MATLAB literaly.
https://github.com/dqrobotics/matlab/blob/master/%40DQ/rotation_axis.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@dqrobotics/developers
Hi @mmmarinho, I spotted a difference between the C++ and MATLAB implementations of
rotation_axis(). The C++ version doesn't check whethersin(phi)is numerically zero when the real part of the rotation is close to -1. MATLAB checksif(sin(phi) <= eps)and returns the conventional axisk_, but C++ only checksif(phi == 0.0).Output:
n = 1kOutput:
Since
log(),Q4(), andQ8()userotation_axis(), this also affects them.This PR adds the same check as the MATLAB version. Please let me know if additional modifications are required.
With this PR, the C++ output matches MATLAB:
Kind regards,
Juancho