Conversation
By converting straight from RotationVec->QuatRotation, and using an implementation that exploits `sinc` to handle θ ≈ 0, we get continuous & differentiable behavior.
hyrodium
reviewed
Oct 14, 2023
Collaborator
hyrodium
left a comment
There was a problem hiding this comment.
Thank you for the PR! I commented two suggestions.
Codecov Report
@@ Coverage Diff @@
## master #272 +/- ##
==========================================
+ Coverage 90.42% 90.50% +0.08%
==========================================
Files 17 17
Lines 1660 1664 +4
==========================================
+ Hits 1501 1506 +5
+ Misses 159 158 -1
📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today! |
Collaborator
|
A type instability was introduced in this PR. Before this PR julia> using Rotations
julia> QuatRotation(RotationVec(0f0, 0f0, 0f0))
3×3 QuatRotation{Float32} with indices SOneTo(3)×SOneTo(3)(QuaternionF32(1.0, 0.0, 0.0, 0.0)):
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
julia> QuatRotation(RotationVec(0f0, 0f0, 2f0))
3×3 QuatRotation{Float32} with indices SOneTo(3)×SOneTo(3)(QuaternionF32(0.540302, 0.0, 0.0, 0.841471)):
-0.416147 -0.909297 0.0
0.909297 -0.416147 0.0
0.0 0.0 1.0After this PR julia> using Rotations
julia> QuatRotation(RotationVec(0f0, 0f0, 0f0))
3×3 QuatRotation{Float64} with indices SOneTo(3)×SOneTo(3)(QuaternionF64(1.0, 0.0, 0.0, 0.0)):
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
julia> QuatRotation(RotationVec(0f0, 0f0, 2f0))
3×3 QuatRotation{Float32} with indices SOneTo(3)×SOneTo(3)(QuaternionF32(0.540302, 0.0, 0.0, 0.841471)):
-0.416147 -0.909297 0.0
0.909297 -0.416147 0.0
0.0 0.0 1.0 |
hyrodium
requested changes
Oct 24, 2023
hyrodium
approved these changes
Nov 10, 2023
Collaborator
hyrodium
left a comment
There was a problem hiding this comment.
I'll merge this PR in a few days if there are no objections.
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.
By converting straight from RotationVec->QuatRotation,
and using an implementation that exploits
sincto handle θ ≈ 0,we get continuous & differentiable behavior.
Requires JuliaDiff/ForwardDiff.jl#669 before tests will pass.
What this fixes: currently, near the origin the Hessian is zero (which is wrong), because
*(::RotationVec, ::SVector{3})expands only to linear order. But the fix is aimed at being broader than this specific case (otherwise, we could have just implemented a second-order approximation).Note: please check whether the relaxation of the
adjointtest is reasonable, perhaps exact equality is necessary? If so I'll need to come up with a fix.