JuliaGeometry / JuliaGeometry/Rotations.jl

AngleAxis(UnitQuaternion) produces NaN derivatives

Open
#139 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

differentiation
Dominant language
Julia
Stars
188
Forks
45
PR merge metrics
No merged PRs in 30d

Description

Similar to #96, constructing an AngleAxis from a UnitQuaternion produces NaN derivative elements when using ForwardDiff:

julia> using Rotations

julia> using ForwardDiff: Dual

julia> q = UnitQuaternion(Dual(1.0, 0.0), Dual(0.0, 0.0), Dual(0.0, 0.0), Dual(0.0, 0.0))
3×3 UnitQuaternion{Dual{Nothing,Float64,1}} with indices SOneTo(3)×SOneTo(3)(Dual{Nothing}(1.0,0.0), Dual{Nothing}(0.0,0.0), Dual{Nothing}(0.0,0.0), Dual{Nothing}(0.0,0.0)):
 Dual{Nothing}(1.0,0.0)  Dual{Nothing}(0.0,0.0)  Dual{Nothing}(0.0,0.0)
 Dual{Nothing}(0.0,0.0)  Dual{Nothing}(1.0,0.0)  Dual{Nothing}(0.0,0.0)
 Dual{Nothing}(0.0,0.0)  Dual{Nothing}(0.0,0.0)  Dual{Nothing}(1.0,0.0)

julia> AngleAxis(q)
3×3 AngleAxis{Dual{Nothing,Float64,1}} with indices SOneTo(3)×SOneTo(3)(Dual{Nothing}(0.0,NaN), Dual{Nothing}(1.0,NaN), Dual{Nothing}(0.0,NaN), Dual{Nothing}(0.0,NaN)):
 Dual{Nothing}(1.0,NaN)  Dual{Nothing}(0.0,NaN)  Dual{Nothing}(0.0,NaN)
 Dual{Nothing}(0.0,NaN)  Dual{Nothing}(1.0,NaN)  Dual{Nothing}(0.0,NaN)
 Dual{Nothing}(0.0,NaN)  Dual{Nothing}(0.0,NaN)  Dual{Nothing}(1.0,NaN)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the AngleAxis(q) example with ForwardDiff and inspect the AngleAxis(UnitQuaternion) conversion entry point. Trace the zero-angle handling and verify that the conversion preserves finite derivative elements instead of producing NaN values.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.