-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add support for ^(::Rotation, ::Real)
#164
Comments
Should it just overload |
Didn't know, |
Further testing it with decimal numbers I have noticed |
Right.
However what we need is further specialization for our types. This is defined already for e.g.
function Base.:^(r::Rotation{3}, p::Real)
return convert(typeof(r), convert(AngleAxis, r) ^ p)
end
function Base.:^(r::Rotation{2}, p::Real)
return convert(typeof(r), convert(Angle2d, r) ^ p)
end
function Base.:^(r::Rotation{3}, p::Integer)
return convert(typeof(r), convert(AngleAxis, r) ^ p)
end
function Base.:^(r::Rotation{2}, p::Integer)
return convert(typeof(r), convert(Angle2d, r) ^ p)
end (the last two are for disambiguation - we could continue to use power-by-squaring here but some method needs to exist). @lieskjur would you feel up to creating a PR? Contributions are always appreciated :) |
I would consider a hybrid approach. After some tinkering I managed to shave off a couple ns from scaling quaternion rotations in comparison to the generic method approach (mostly did it out of interest in how it could be done without the dependency).
generic approach:
type specific:
I'm not sure the increase in performance justifies the duplicit code though. Maybe it would be worth exploring the same for other types but I'd say that is not a major priority based on the minor improvement in speed. One more caveat is that special methods for
Sure, it will just take some time. In Julia doc |
Well in Rotations.jl rotations are represented as matrices, which multiply vectors. The natural “scaling” operator for rotations is (On a technical level, we say we are working in the Lie group not the Lie algebra.) If this isn’t covered in the README then it should be. I don’t think we need additional docstrings though? |
^(::Rotation, ::Real)
fixed by #266 |
Hi, recently I've found a need for scaling rotations described by unit quaternions, by which I mean produce a rotation along the same axis only with a different angle. I've written a small function for this purpose
not wanting to override the current
function (*)(q::Q, w::Real) where Q<:UnitQuaternion
. Would any one else see use in adding such a method to the package?The text was updated successfully, but these errors were encountered: