Hello. I use FQuat to rotate the object along the Y axis. Everything works great. But…
I need to convert the Y-axis angle to a value from 0 to 360 degrees. How to do it?
I tried FQuat::Euler and it also returns a maximum of 90 degrees for the Y axis.
The math is a bit beyond me, but it looks like if your Quat points to a position where the equivalent Rotator would be gimbal locked, you’re going to get a -90 or a +90 in the Pitch, which is the Y component of the vector returned by Euler().
Outside of gimbal lock, it does (UnrealMath.cpp, FQuat::Rotator() )
RotatorFromQuat.Pitch = FMath::FastAsin(2.f*(SingularityTest)) * RAD_TO_DEG;
RotatorFromQuat.Yaw = FMath::Atan2(YawY, YawX) * RAD_TO_DEG;
RotatorFromQuat.Roll = FMath::Atan2(-2.f*(W*X+Y*Z), (1.f-2.f*(FMath::Square(X) + FMath::Square(Y)))) * RAD_TO_DEG;
Actually, you can just Quat.Rotator() if you don’t need it as a vector, but want it just as a Rotator.