To avoid gimbal lock, I use quaternions for my rotations. For example, to roll I use this function:

FQuat rollRot(float multiplier)
    return FQuat::FindBetweenVectors(mesh->GetUpVector(), mesh->GetRightVector() * multiplier + mesh->GetUpVector() );

It works fine as long as I don't need the current "roll" value.

I cannot just take the x Euler angle of my rotations. For example, in these cases I would expect roll value of 10, but it is 90 and 180:

Example 1 Example 2


1 Answer 1


If you had no roll, your local right vector would point along \$\text{world up} \times \text{local forward}\$ (ie. flat along the horizontal plane, while staying perpendicular to your local forward vector)

So you can compute the angle between your actual local right vector and this one to get your roll angle. The z component of your local right vector gives you the sign of the angle.

  • \$\begingroup\$ It seems like solution. A good example why math is needed) Thanks \$\endgroup\$
    – Olexy
    Apr 5, 2022 at 11:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .