# Quaternion to Euler angles

**URL:** <https://discourse.julialang.org/t/quaternion-to-euler-angles/119740>\
**Category:** Performance\
**Tags:** question, package, rotations\
**Created:** [September 23, 2024, 11:38am UTC](https://discourse.julialang.org/t/quaternion-to-euler-angles/119740 "2024-09-23T11:38:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 23, 2024, 11:38am UTC](https://discourse.julialang.org/t/quaternion-to-euler-angles/119740/1 "2024-09-23T11:38:53Z")

</div>

How can I convert a quaternion into Euler angles?

Not working:

```julia
using Rotations
q = Float32[0.51791805, 0.48140272, -0.4814214, -0.5179244]
RotXYZ(q)

```

This fails with a dimension mismatch error.

See: [Euler Angles · Rotations.jl](https://juliageometry.github.io/Rotations.jl/stable/3d_euler/)

---

<div class="post-metadata">

**Author:** ![jipolanco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jipolanco/32/12129_2.png) [@jipolanco](https://discourse.julialang.org/u/jipolanco)\
**Post date:** [September 23, 2024, 11:45am UTC](https://discourse.julialang.org/t/quaternion-to-euler-angles/119740/2 "2024-09-23T11:45:03Z")

</div>

That’s probably because `RotXYZ` expects a rotation? This works for me:

```julia
using Rotations
q = QuatRotation(0.51791805, 0.48140272, -0.4814214, -0.5179244)
RotXYZ(q)

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 23, 2024, 11:47am UTC](https://discourse.julialang.org/t/quaternion-to-euler-angles/119740/3 "2024-09-23T11:47:59Z")

</div>

> [@jipolanco](#):
>
> `QuatRotation`

Nice, one step further. But I want to get three angles, roll, pitch and yaw? How can I calculate them?

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [September 23, 2024, 11:49am UTC](https://discourse.julialang.org/t/quaternion-to-euler-angles/119740/4 "2024-09-23T11:49:46Z")

</div>

`Rotations.params`

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 23, 2024, 11:51am UTC](https://discourse.julialang.org/t/quaternion-to-euler-angles/119740/5 "2024-09-23T11:51:50Z")

</div>

Thanks, this works:

```julia
julia> Rotations.params(RotXYZ(q))
3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
 -0.18252027034759521
 -1.5686432299864785
 -1.754975438117981

```

Now I only need to check if this is really roll, pitch and yaw.
