Why is Minecraft's pitch and yaw system so weird?

Discussion in 'Spigot Plugin Development' started by EggyRepublic, Jan 9, 2020.

1. EggyRepublic

Normally, I'd imagine a player's yaw to start at 0 towards positive X and increase as you rotate counter-clockwise and a player's pitch to increase when you look up. That enables converting between vectors and angles to be done by plugging numbers into trig functions without the need for inverting stuff and adding translations.

However, why do Minecraft insist on having yaw be zero at positive Z and increase clockwise, and pitch be negative as you look up? What was the reasoning behind this, am I missing something important?

• Useful x 1
2. CoolLord22

After quite a bit of digging this is all I could find;

In order to orient it in the XZ plane (rather than a ZX) it has to be rotated, hence why there's that extra 90 degree rotation we see, and a flip of the Z on the axes.

and finally this resource from apple:

based on this model, when the phone is tilted downwards, your pitch is positive (same with MC character...) and if your phone is rotated towards the right (negative X) you experience a positive yaw, both consistent with MC. It might just honestly be an initial reference frame issue as MC doesn't use a regular cartesian coordinate system

I myself still am a bit confused on how this works out, but the images do seem to support each other when looking at how the math is done.

• Like x 1
3. Hextaine

As far as I can tell, the pitch and yaw are set like that just so that 0 pitch and 0 yaw perfectly point the player's head north at an angle perpendicular to the ground. Generally the 0 pitch and yaw of a system will point the entity in the direction for which it should rest (e.g. a plane with 0 pitch and 0 yaw sits on it's wheels, parallel to the ground). If it's making computations difficult, there's always the option of offsetting the value while computing then reversing it when computations are complete since addition and subtraction are reversible and commutative. It makes things slightly annoying which direction is positive, but I suppose Mojang had to pick a direction and math isn't too difficult when you remember to account for a negative sign at the beginning.

• Useful x 1
4. hamoodrex

Usually in physics the Z axis represents front and back or K vector