How to get axis rotations from UnitQuaternion in Rotations.jl

How do I get axis (X, Y, Z) rotations from UnitQuaternion?

julia> RotXYZ(UnitQuaternion(RotX(1)))
3×3 RotXYZ{Float64} with indices SOneTo(3)×SOneTo(3)(1.0, 0.0, 0.0):
 1.0  -0.0        0.0
 0.0   0.540302  -0.841471
 0.0   0.841471   0.540302

It looks like they are contained in (1.0, 0.0, 0.0) above, but how to access it?

1 Like

with the method rotation_axis()

julia> rot = RotXYZ(UnitQuaternion(RotX(1)))
3×3 RotXYZ{Float64} with indices SOneTo(3)×SOneTo(3)(1.0, 0.0, 0.0):
 1.0  -0.0        0.0
 0.0   0.540302  -0.841471
 0.0   0.841471   0.540302

julia> rotation_axis(rot)
3-element StaticArrays.SArray{Tuple{3},Float64,1,3} with indices SOneTo(3):
 1.0
 0.0
 0.0
2 Likes

On the second view, it’s not what I’m looking for. Maybe I didn’t make it clear, but I’m looking for roll, pitch and yaw angle components of 3D rotation. rotation_axis is not that, because in the case below:

julia> rotation_axis(UnitQuaternion(RotX(0)))
3-element SArray{Tuple{3},Float64,1,3} with indices SOneTo(3):
 1.0
 0.0
 0.0

(0, 0, 0) is the rotation about X, Y, Z axes.

1 Like