Rotation order?

It’s XYZ or YZX or?

1 Like

It appears to be YZX?

Rotated game object by 45,25,15,

2017-10-06 18_15_48-Rotation order_ - Questions - Defold game engine forum

got its rotation,

	local rotation = go.get_rotation()
	print("tester rotation " .. rotation)
tester rotation [0.396517, 0.247020, 0.035613, 0.883452]

Checked against in this tool for identity quat 0,0,0,1

http://quaternions.online/

Another question do these labels seem appropriate or should z and x be swapped?

– YZX

– yaw = y
– roll = z
– pitch = x

Should 0,0,1 be assumed to be forward? If not what? 1,0,0?

Not totally sure what you mean by “forward”, since we’re discussing rotations here?

World forward I guess. I’m still not expert in 3d gamedev but it seems like most engines have a standard. It seems like editor gizmo suggests that 0,0,1 should be forward but that’s opposite of the direction of the default view.


function M.vector3_up()
	return vmath.vector3(0,1,0)
end

function M.vector3_down()
	return vmath.vector3(0,-1,0)
end

function M.vector3_right()
	return vmath.vector3(-1,0,0)
end

function M.vector3_left()
	return vmath.vector3(1,0,0)
end

function M.vector3_forward()
	return vmath.vector3(0,0,1)
end

function M.vector3_backward()
	return vmath.vector3(0,0,-1)
end

function M.vector3_one()
	return vmath.vector3(1,1,1)
end

function M.vector3_zero()
	return vmath.vector3(0,0,0)
end


Well, “forward” is a subjective term. You can decide what is forward: Up the screen for a top down car game, or right of the screen for a side scroller shoot’em’up.
Sometimes, what is “forward” is decided by the artist: e.g. a 3d character might be facing negative Z, positive Z or…

As for how a unit world transform relates to your physical world (i.e. screen), then yes, each engine/programs have a standard setup. Ours is that the X axis (1,0,0), indicated by the red color in the gizmos, points to the right of the screen. The Y axis (0,1,0), indicated by the green color, points upwards. And since we use right-handed-matrices, that means that the Z axis points out from the screen (i.e. 0,0,1), and it is usually indicated by the blue color (i.e. XYZ maps to RGB for the gizmos). All given the default view of a non rotated camera.

3 Likes

It’s confusing to me because it looks like red should be pointing left, green up, and blue (orange because it’s selected) forward from a reversed view of the default camera direction.