JuliaSpace / ReferenceFrameRotations.jl

A toolbox to represent 3D rotations of coordinate frames for Julia language.
MIT License
59 stars 13 forks source link

Add ClockwiseAngle for 2D applications #22

Open juliohm opened 3 years ago

juliohm commented 3 years ago

I know the package only implements 3D rotations, but it would be nice to add this tiny struct for convenience and have conversion methods with DCM. Something as simple as

struct ClockwiseAngle{T}
  a::T
end

function Base.convert(::Type{<:DCM}, cw::ClockwiseAngle)
    s, c = sincos(cw.a)
    @SMatrix [c s; -s c]
end

I can submit a PR for that if you feel that it is useful.

juliohm commented 3 years ago

This is where I am placing temporary definitions while we sort out what to do:

https://github.com/JuliaGeometry/Meshes.jl/blob/master/src/rotations.jl

ronisbr commented 2 years ago

The same think can be accomplished by:

@view angle_to_dcm(0.5, :Z)[1:2, 1:2]

Isn't it enough?

juliohm commented 2 years ago

Yes, but now we are forcing users to handle the dimension of the problem explicitly. The vision I have for these rotations in geometric processing is dimension-agnostic. The fact that DCM{2} is a view of DCM{3} is an implementation detail. We should still be able to work with rotations in a N-dimensional space without manual handling of the number of coordinates.

ronisbr commented 2 years ago

We should still be able to work with rotations in a N-dimensional space without manual handling of the number of coordinates.

Hum, I see. It makes sense. We just need to be sure to select a name to this 2D rotation so that the user are 100% sure it will return a 2x2 matrix. We also have clockwise rotations in 3D spaces, for example.