Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot take the mean of single or two axis euler rotations #91

Closed
colinxs opened this issue Jan 29, 2019 · 1 comment · Fixed by #177
Closed

Cannot take the mean of single or two axis euler rotations #91

colinxs opened this issue Jan 29, 2019 · 1 comment · Fixed by #177
Labels

Comments

@colinxs
Copy link

colinxs commented Jan 29, 2019

Note that mean() is fully broken on master. To reproduce this you'll have to checkout the fix/mean branch on my fork (will be merged after I write a test) and do the following.

julia> r=[RotZ(pi/2) for _ in 1:5000];

julia> mean(r)
ERROR: MethodError: RotZ{Float64}(::Quat{Float64}) is ambiguous. Candidates:
  (::Type{RotZ{T}})(theta) where T in Rotations at /home/colinxs/workspace/Rotations.jl/src/euler_types.jl:17
  (::Type{SA})(a::StaticArrays.StaticArray) where SA<:StaticArrays.StaticArray in StaticArrays at /home/colinxs/.julia/packages/StaticArrays/mcf7t/src/convert.jl:5
Possible fix, define
  (::Type{RotZ{T}})(::StaticArrays.StaticArray)
Stacktrace:
 [1] mean(::Array{RotZ{Float64},1}) at /home/colinxs/workspace/Rotations.jl/src/mean.jl:50
 [2] top-level scope at none:0

julia> r2=[RotXY(0,pi/2) for _ in 1:5000];

julia> mean(r2)
ERROR: Cannot construct a two-axis rotation from a matrix
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] Type at /home/colinxs/workspace/Rotations.jl/src/euler_types.jl:232 [inlined]
 [3] Type at /home/colinxs/.julia/packages/StaticArrays/mcf7t/src/convert.jl:5 [inlined]
 [4] mean(::Array{RotXY{Float64},1}) at /home/colinxs/workspace/Rotations.jl/src/mean.jl:50
 [5] top-level scope at none:0

julia> r3=[RotXYZ(0,0,pi/2) for _ in 1:5000];

julia> mean(r3)
3×3 RotXYZ{Float64}(3.14159, 0.0, 3.14159):
 -1.0          -1.22465e-16   0.0        
 -1.22465e-16   1.0          -1.22465e-16
  1.49976e-32  -1.22465e-16  -1.0        

@andyferris
Copy link
Contributor

Hmm... this is unfortunate - we should fix this.

I'm also wondering if mean should just do the AbstractArray thing (not return a rotation) and we should have some other function for mean rotations (or closest orthogonal matrix or whatever)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants