Skip to main content
6 votes

How to express and verify euler rotation limits in Unity

Euler angles aren't necessarily a good way of expressing limits over arbitrary ranges, as their behaviour close to zero is very different from their behaviour away from zero. Below I've visualized ...
DMGregory's user avatar
  • 135k
6 votes
Accepted

Euler angle and Quaternion conversion become weird when yaw is bigger than 90 degrees

Your current code assumes it's always going to get Euler angles where x is between ±90° and z is close to 0. Meanwhile, glm wants to return Euler angles that are standardized so that y is between ±90°,...
DMGregory's user avatar
  • 135k
4 votes

GLM conversion from euler angles to quaternion and back does not hold

The results are not what you expect, but they are not wrong. It’s just that for a given orientation there are at least two “paths” through Euler angles that lead there. For instance, the identity ...
sam hocevar's user avatar
  • 23.9k
3 votes

Order of rotation in Euler angles

Order does matter. For fps games it should generally be yaw -> pitch -> roll. When using matrices, note that multiplication order might be the complete opposite. Think about it, doing the pitch first ...
Bálint's user avatar
  • 14.9k
2 votes
Accepted

Using Euler angles to rotate object 360 degrees

Final code is easier than the one I posted. I just didn't think about doing it this way. ...
Solipsis's user avatar
2 votes

Gravity vector and forward vector to local heading (yaw), pitch and roll

I will try to break down the step-by-step questions I'd take to solve this problem, with the hope it helps you to understand how to go about solving vector-related problems in the future. Note: I'll ...
Jimmy's user avatar
  • 9,029
2 votes
Accepted

Why does the pitch affect the x component of the front vector?

"Why does pitch affect the x component?" Short answer: because you could be looking left or right. Now, you may say if yaw is zero (or ±π), then ...
DMGregory's user avatar
  • 135k
2 votes
Accepted

How to check whether an angle lies within a specific negative to positive range?

Doing math on Euler angles can get you into trouble. Under the hood, Unity uses quaternions to have simpler & more uniform rotational behaviour. It converts to Euler angles when it needs to ...
DMGregory's user avatar
  • 135k
1 vote
Accepted

How to clamp rotation on a specific axis?

It's generally not safe to use Euler angles as the input to a computation. Many different Euler angle representations map to the same resulting orientation, and the values need to wrap around ...
DMGregory's user avatar
  • 135k
1 vote
Accepted

Get object rotation around the x axis

Remember, Euler angles are a fiction, made for ease of data input in the scene editor. They're not stored under the hood, so when you read an Euler angle triplet, it's converted on the fly from the ...
DMGregory's user avatar
  • 135k
1 vote
Accepted

NVidia Physx get yaw pitch roll from rigid body orientation

The solution was found here And here is the code : ...
Mike F's user avatar
  • 93
1 vote
Accepted

Character rotation jitters when looking around

This line extracts just 2 imaginary components out of a 4-dimensional quaternion: ...
DMGregory's user avatar
  • 135k
1 vote

Euler Angles of Any Great Circle from hit.point of a sphere

I'm going to assume you're using Unity's coordinate system and Euler angle conventions. I'm also going to assume you have a "reference" great circle model as a child of the sphere, which in ...
DMGregory's user avatar
  • 135k
1 vote

Convert 3D direction vectors to yaw/pitch/roll angles

This is related to the problem of converting from Cartesian Coordinates to Spherical Coordinates. Note that the reverse operation is not unique: there are many possible angle triplets that produce the ...
DMGregory's user avatar
  • 135k
1 vote
Accepted

360 degree Shooting using Pythagoras problem Unity 2D C#

transform.rotation is a Quaternion, not a collection of angles. Accessing individual components of a quaternion is almost never ...
DMGregory's user avatar
  • 135k
1 vote

How can I use a redundant axis of rotation to prevent gimbal-lock & calculate a position for that axis?

My first thought is that we could solve this by gradient descent. Assuming we did a good job aligning our pointer to the target & minimizing gimbal lock last frame, then this frame we should be ...
DMGregory's user avatar
  • 135k
1 vote

How to express and verify euler rotation limits in Unity

Maintain your own layer that operates on euler angles, and keeps current values of these stored every frame. Unity derives the quaternion form for the purposes of allowing the renderer and physics to ...
Engineer's user avatar
  • 30k
1 vote

Why does the pitch affect the x component of the front vector?

Yaw is applied first, then pitch, you can see this on the following gif (I first rotate the pitch, then I do the same but I change the yaw too):
Bálint's user avatar
  • 14.9k
1 vote

How is a gimbal connected with Euler rotation angles?

The issue not because Euler angles can't represent all orientations (they can) but because they don't interpolate between two orientations cleanly. The analogy with the physical gimbal lock isn't 100% ...
Jimmy's user avatar
  • 9,029

Only top scored, non community-wiki answers of a minimum length are eligible