JuliaGeometry / Rotations.jl

Julia implementations for different rotation parameterizations
https://juliageometry.github.io/Rotations.jl
MIT License
180 stars 44 forks source link

Add `InfinitesimalRotation` #199

Closed hyrodium closed 2 years ago

hyrodium commented 2 years ago

This PR fixes #198.

I've introduced the following types:

Note that this is just a quick fix for exp(log(::UnitQuaternion)) isa Rotation{3}. so, I haven't added enough tests for now.

julia> using Rotations

julia> m = rand(3,3)
3×3 ^[[AMatrix{Float64}:
^[[A^[[A^[[A 0.116692  0.853162  0.436719
 0.189983  0.270279  0.397227
 0.18174   0.268436  0.72791

julia> s = InfinitesimalRotMatrix{3}(m - m')
3×3 InfinitesimalRotMatrix{3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
  0.0        0.663178  0.254978
 -0.663178   0.0       0.12879
 -0.254978  -0.12879   0.0

julia> exp(s)
3×3 RotationVec{Float64} with indices SOneTo(3)×SOneTo(3)(-0.12879, 0.254978, -0.663178):
  0.758369   0.591313  0.274273
 -0.62275    0.781548  0.0369486
 -0.192509  -0.198824  0.960942

julia> log(exp(s))
3×3 InfinitesimalRotationVec{Float64} with indices SOneTo(3)×SOneTo(3)(-0.12879, 0.254978, -0.663178):
  0.0        0.663178  0.254978
 -0.663178   0.0       0.12879
 -0.254978  -0.12879   0.0

julia> log(exp(s)) + s
3×3 InfinitesimalRotMatrix{3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
  0.0        1.32636  0.509957
 -1.32636    0.0      0.25758
 -0.509957  -0.25758  0.0

julia> rotation_angle(exp(log(exp(s)) + s))
1.4441697210115163

julia> rotation_angle(exp(s))
0.7220848605057582

julia> InfinitesimalRotationVec(s)
3×3 InfinitesimalRotationVec{Float64} with indices SOneTo(3)×SOneTo(3)(-0.12879, 0.254978, -0.663178):
  0.0        0.663178  0.254978
 -0.663178   0.0       0.12879
 -0.254978  -0.12879   0.0
codecov[bot] commented 2 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (hotfixes/v1.0.5@1a0ae63). Click here to learn what that means. The diff coverage is n/a.

Impacted file tree graph

@@                Coverage Diff                 @@
##             hotfixes/v1.0.5     #199   +/-   ##
==================================================
  Coverage                   ?   79.53%           
==================================================
  Files                      ?       15           
  Lines                      ?     1451           
  Branches                   ?        0           
==================================================
  Hits                       ?     1154           
  Misses                     ?      297           
  Partials                   ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1a0ae63...259ec0c. Read the comment docs.

hyrodium commented 2 years ago

I'll close this PR because we won't release v1.0.5 (https://github.com/JuliaGeometry/Rotations.jl/issues/198#issuecomment-968210878)