# Axis orientation

This topic is 884 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm wondering what the general rule involving the direction of absolute axes in 3D space. I most commonly see Z being the vertical axis, but I have seen some examples of this not being the case. It of course also depends on the game. If you had six degrees of freedom in a space game, where would you even begin to plot the axes?

##### Share on other sites

By default, with no camera logic or anything, the hardware itself assumes that x is across the screen to the right, y is either up or down the screen, and z is either into or out of the screen.

On top of that, you can build any convention that you like.

Often games use a right handed coord system -- hold up your thumb and first two fingers, with thumb point right, index pointing up, and middle finger pointing towards you -- that's X, Y and Z.

Other games use right handed with Z as up -- thumb right, index finger away from you, middle finger up.

Other games use left handed coordinate system... z up, z in, z out, etc...

There's no "standard" :(

Back in the 80's and early 90's, 3d level editors were usually just 2d applications with a top down view, which would show a floor-plan with X/Y axis, which meant that Z became up and down. That convention is still popular with a lot of level designers, or anyone who's used CAD software.

Nowadays, Z defaults to in/out of the screen as I said at the start, so other games keep that convention and use Y as up and down in the world...

Then you've also got to define your rotational conventions. Is a positive X-axis rotation clockwise when looking from the origin out along +X, or anti-clockwise? :lol:

Edited by Hodgman

##### Share on other sites

My vector class has some behavior where the last component can be ignored / assumed to be 0 when converting to different number of dimension (2D <=> 3D, and yes, this should be an explicit conversion to avoid mistakes). So based on that, I would make the choice based on which dimension is the one I most often ignore (which axis is not present in the usual 2D logic).

So for most games, the up axis would be most convenient as the z axis.

Of course, its pretty trivial to change that convention, but then it doesnt scale nicely to the Nth dimension...

(this also applies to matrices - if I want to ignore z axis, its just easy to grab the 2x2 corner of a 3x3 rotation matrix, for example)

Edited by Waterlimon

##### Share on other sites

In my experience you end up with a bunch of headaches unless you pick one convention and use it everywhere. The most mathematically consistent to me is the right-handed coordinate system where X+ = right, Y+ = up, Z+ = back. This way the X,Y axes match the viewport coordinate system. Z-up has never made much sense to me because it requires an extra rotation about the X axis to bring the world into camera space.

##### Share on other sites

My vector class has some behavior where the last component can be ignored / assumed to be 0 when converting to different number of dimension (2D <=> 3D, and yes, this should be an explicit conversion to avoid mistakes). So based on that, I would make the choice based on which dimension is the one I most often ignore (which axis is not present in the usual 2D logic).

Yes, as a pet peeve, Unity will silently convert for you, and I've wasted time trying to figure out my errors.

##### Share on other sites

In my experience you end up with a bunch of headaches unless you pick one convention and use it everywhere. The most mathematically consistent to me is the right-handed coordinate system where X+ = right, Y+ = up, Z+ = back. This way the X,Y axes match the viewport coordinate system. Z-up has never made much sense to me because it requires an extra rotation about the X axis to bring the world into camera space.

There is nothing more mathematically consistent about that convention than about any other. What's most natural depends on what you are doing. Z-up makes sense if your primary view of the world is from the top, like in StarCraft.

##### Share on other sites

In my experience you end up with a bunch of headaches unless you pick one convention and use it everywhere. The most mathematically consistent to me is the right-handed coordinate system where X+ = right, Y+ = up, Z+ = back. This way the X,Y axes match the viewport coordinate system. Z-up has never made much sense to me because it requires an extra rotation about the X axis to bring the world into camera space.

There is nothing more mathematically consistent about that convention than about any other. What's most natural depends on what you are doing. Z-up makes sense if your primary view of the world is from the top, like in StarCraft.

I was referring to the right-handedness which is ubiquitous is math and physics, left-handed is just weird because its not consistent with the standard definition of the cross product.

Edited by Aressera

##### Share on other sites

Just to make things even more fun, often you find conventions apply to particular fields.

Like in aerodynamics they have a convention which nearly all applications stick to.

This may not be the same as the physics system in your game, which itself may be different to the one used in the renderer.

It can end up causing you to melt into a quivering wreck in the corner of the office. Whimpering quietly while forming coordinate sets with both hands and trying to rotate one to match the other like an apprentice magic user trying to complete a difficult spell.

You just have to look at any third party software you are using and work it out carefully.

##### Share on other sites

Most places I've worked at (as well as my own code) use right-handed coordinates, with: +X = right, +Y = up, +Z = back.

Edited by 0r0d

1. 1
2. 2
3. 3
Rutin
21
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 10
• ### Forum Statistics

• Total Topics
633653
• Total Posts
3013151
×