# How to get axis rotations from UnitQuaternion in Rotations.jl

**URL:** <https://discourse.julialang.org/t/how-to-get-axis-rotations-from-unitquaternion-in-rotations-jl/46490>\
**Category:** General Usage\
**Created:** [September 12, 2020, 12:55am UTC](https://discourse.julialang.org/t/how-to-get-axis-rotations-from-unitquaternion-in-rotations-jl/46490 "2020-09-12T00:55:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pauljurczak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauljurczak/32/921_2.png) [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Post date:** [September 12, 2020, 12:55am UTC](https://discourse.julialang.org/t/how-to-get-axis-rotations-from-unitquaternion-in-rotations-jl/46490/1 "2020-09-12T00:55:14Z")

</div>

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

```julia
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?

---

<div class="post-metadata">

**Author:** ![elsuizo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elsuizo/32/89_2.png) [@elsuizo](https://discourse.julialang.org/u/elsuizo)\
**Post date:** [September 12, 2020, 1:43am UTC](https://discourse.julialang.org/t/how-to-get-axis-rotations-from-unitquaternion-in-rotations-jl/46490/2 "2020-09-12T01:43:48Z")

</div>

with the method `rotation_axis()`

```julia
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

```

---

<div class="post-metadata">

**Author:** ![pauljurczak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pauljurczak/32/921_2.png) [@pauljurczak](https://discourse.julialang.org/u/pauljurczak)\
**Post date:** [September 12, 2020, 3:12pm UTC](https://discourse.julialang.org/t/how-to-get-axis-rotations-from-unitquaternion-in-rotations-jl/46490/3 "2020-09-12T15:12:46Z")

</div>

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
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.
