Rotation in x, y axises follow Right Hand Rule

The UE4 Coordinate is Left Handed.
(Let the Axis position direction facing you, so clockwise and counter-closewise are defined. Or use left hand thumb face axis positive direction and then other four fingers direction is the positive (clockwise direction, left handedness rotation). If follow your right hand then it is counter-clockwise direciton, and right handedness rotation)

The z axis rotation seems correct, it follows Left Hand Rule. Clockwise rotation is positive.
But x, y axis rotations follow Right Hand Rule. Clockwise rotation is negative.

It is all fine in Unity.

6 Likes

Orignal expressions


    
     FQuat RotationQuat;
     RotationQuat.W = CR*CP*CY + SR*SP*SY;
     RotationQuat.X = CR*SP*SY - SR*CP*CY;
     RotationQuat.Y = -CR*SP*CY - SR*CP*SY;
     RotationQuat.Z = CR*CP*SY - SR*SP*CY;

It is clearly that X, Y’s signs have been fliped.

The conversion from Quaterion to Euler Angle is the same. X, Y components in Quaterinon have been fliped, too according to orignal expressions.

1 Like

I never noticed that before. I got curious. If you open up a half professional modelling program (I popped open Modo for example since its stock Y up like Unity) and Y,X and Z clockwise are all neg, whereas Blender Y CW is +, X CW is -, and Z CW is -, opposite as you suggest UE4’s rots are which brings us to the industry standard, Maya Y (up) CW is -, X CW is -, Z CW is + just like UE4 uses. So that shows a possible connection/reason.

It will be fine.
But almost every 3D software, Game Engine, and VR Engine using either Left Hand Coordinate with Left Hand Rotation Rule(X Clocksise +, Y Clockwise +, Z Clockwise +) or Right Hand Coordinate with Right Hand Rotation Rule (X CounterClockwise +, Y CounterClockwise +, Z CounterClockwise +). These systems are more nature and friendly for most human beings. Mixing Different Rotation is OK, but it is odd to most people and no 3d software adopt it.

Sorry to wake up this old subject, but it came up in a Google search and I don’t want others to be confused.

No, Unreal does not mix rotations. The math is actually the same (the numbers are the exact same) in left-handed and right-handed systems.

  • The X vector, rotated positive around Z, yields the Y vector. This is the same in left-handed and right-handed coordinate systems. In a left-handed coordinate system, this yields the left-hand rotation rule.

The two other cardinal rotations of this basic rule also hold:

  • The Y vector, rotated positive around X, yields the Z vector. In a left-handed coordinate system, this yields the left-handed rotation rule.
  • The Z vector, rotated positive around Y, yields the X vector. In a left-handed coordinate system, this yields the left-handed rotation rule.
    The only case you will be confused is if you somehow use the wrong hand or wrong rule when interpreting the coordinate systems.

You can’t look at the implementation of a mathematical operation, and tell whether the coordinate system the user chooses to use is left-handed or right-handed.
The difference between left-handed and right-handed coordinate systems is ONLY when translating to/from a physical (real-world) context.

The math rules are absolutely the same, same numbers, same order, same everything, in a left-handed and right-handed system. The “mirroring” only happens when you choose to interpret the output numbers one way versus the other.

1 Like

(haha, I’m here too cuz I was confused and Google led me here)

The way it confused me was that I was trying to remember which direction positive rotations are relative to the positive directions of each axis, and that’s how they appear inconsistent. If the +X or +Y axes are pointed directly at your eye, positive rotations are counterclockwise. If the +Z axis is pointed directly at your eye, a positive rotation is clockwise. I’m not suggesting it’s wrong, just saying that that /apparent/ inconsistency is what’s confusing (and, for me, hard to remember :slight_smile: ).

2 Likes

It doesn’t seem to be correct. X vector rotated 90 degrees around Z, does yields Y, BUT:
The Y vector, rotated positive around X, yields negative Z vector
The Z vector, rotated positive around Y, yields negative X vector

I need to work with quaternions and this brought some confusion. Obviously the coded maths works fine, it’s just a bit strange that indeed the left-hand rule is not consistently applied here. This is also visible in Henry Read’s formulas in #2 post.

See, pictures attached:

Identity (0 rotations)


Yaw = 90 degrees (rot around Z)

Roll = 90 degrees (rot around X)

Pitch = 90 degrees (rot around Y)

3 Likes

It seems that perhaps in UE5.1.0, EpicGames updated the DocComments to accurately reflect the Rotator implementation.
Please see the following URLs.

https://github.com/EpicGames/UnrealEngine/commit/0b635787f74ad136a5c40663fe1c74e211608ef8#

(Commit Comment)
Positive angles are left-handed around Z, right-handed around +Y, and right-handed around +X.

https://github.com/EpicGames/UnrealEngine/commit/0b635787f74ad136a5c40663fe1c74e211608ef8#diff-2c5da1cee70a70d751b11b8dbdcb53dfd4193216884c121ead3353c9ebe29c38R31

Rotator treats yaw as left-handed but pitch and roll as right-handed.

2 Likes

Looking at it again, I think the comment about Roll on the engine is incorrect in my opinion.
The comment is written as follows.

Rotation around the forward axis (around X axis), Tilting your head, (0=Straight, +Clockwise, -CCW)

I think the correct comment should be as follows.

Rotation around the forward axis (around X axis), Tilting your head, (0=Straight, +CCW, -Clockwise)


The reason I think this way is because Rotator treats Roll as a right-handed system as it is written in here.

Rotator treats yaw as left-handed but pitch and roll as right-handed.

And in a right-handed system, positive rotation is counterclockwise about the axis of rotation.
Please see Left- vs. Right-Handed Coordinate Systems .

I believe generally people say clockwise/counter-clockwise “rotation about an axis” to mean the direction of rotation while looking along the axis in a positive direction, which matches UE’s documentation rather than your referenced link.

Putting it all together in that way, UE is “right-handed” “clockwise” around X and Y, and “left-handed” “counter-clockwise” around Z. I noticed this behavior in UE5 and actually couldn’t believe it, except that UE has an oddball coordinate system to begin with.

So, yes, UE absolutely does mix the rotations. I think I know why, and that is to have a sort of “right-ish up-ish” positive rotation for how UE interprets roll, pitch, and yaw as X, Y, and Z axes. A positive roll is like leaning to the right (a right-handed rotation along X), a positive pitch is like turning upward (a right-handed rotation along Y), and a positive yaw is like turning to the right (a left-handed rotation along Z).

It’s confusing because it’s inconsistent. :woozy_face: