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

upgrade mean of rotations to new LinearAlgebra syntax #90

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/euler_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ for axis in [:X, :Y, :Z]
@eval begin
struct $RotType{T} <: Rotation{3,T}
theta::T
$RotType{T}(theta) where {T} = new{T}(theta)
$RotType{T}(theta::Real) where {T} = new{T}(theta)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems unrelated and would break e.g. interop with SymPy.Sym. Please revert.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops! haha I left that in by accident. There are some problems with mean() in its current form that I was trying to address. Namely that you cannot take the mean of two or three axis rotations. I'll file an issue for that!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and I'll definitely add a test. I'm a little slammed right now but in a day or two!

$RotType{T}(r::$RotType) where {T} = new{T}(r.theta)
end

Expand Down
6 changes: 3 additions & 3 deletions src/mean.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function Statistics.mean(qvec::AbstractVector{Quat{T}}, method::Integer = 0) whe
Qi = @SVector [q.w, q.x, q.y, q.z] # convert types to ensure we don't get quaternion multiplication
M .+= Qi * (Qi')
end
evec = eigfact(Symmetric(M), 4:4)
Qbar = Quat(evec.vectors[1], evec.vectors[2], evec.vectors[3], evec.vectors[4]) # This will renormalize the quaternion...
vectors = eigvecs(Symmetric(M))
Qbar = Quat(vectors[1], vectors[2], vectors[3], vectors[4]) # This will renormalize the quaternion...
#else
# error("I haven't coded this")
#end
Expand All @@ -47,5 +47,5 @@ function Statistics.mean(qvec::AbstractVector{Quat{T}}, method::Integer = 0) whe
end

function Statistics.mean(vec::AbstractVector{R}) where R<:Rotation
R(mean(convert(Vector{Quat{eltype(R)}}, vec)))
R(Statistics.mean(convert(Vector{Quat{eltype(R)}}, vec)))
end