- Home /
Unity is a Left-Handed Coordinate System? Why?
I just noticed the unity default axis is a left-handed coordinate system. Interesting.
This would explain for some interesting sign conventions in various cross-product as well as cross-product quantities -- torque/moment of inertia, angular velocity.
My question then is: why is Unity a left-handed coordinate system? Are there design, performance, or other benefits for this? Why not a right-handed system (OpenGL is right-handed..)
That's more of an observation than a question :) But yes, Unity uses a left-handed coordinate system.
Unity is a game engine and not a modeling app. You're often thinking of things in the engine as active characters, ins$$anonymous$$d of as things that you are observing, as the creator. The concept of hands doesn't help understand this; ins$$anonymous$$d, think of eyes.
well, this explains for the interesting sign convention in cross products -- torque/moment of inertia, that sort of stuff..
It's not like there's a standard. OpenGL uses right handed, DirectX uses left handed. $$anonymous$$odelling apps are split between the two.
Answer by Jesse Anders · Dec 20, 2010 at 06:00 PM
To reinforce what's already been said, there is no standard with respect to coordinate-system handedness in games and graphics; neither left-handed nor right-handed is more standard or 'correct' than the other.
There's a common misconception that Direct3D is left-handed and OpenGL is right-handed, but that's not actually true (not to the best of my knowledge at least). The two APIs are usually presented that way in references and tutorials, but you can easily use either handedness with either API. The DirectX math library offers both right- and left-handed versions of all functions for which handedness matters, and as for OpenGL, the option of uploading your own transform matrices has been available since the earliest versions of the API (and in newer versions of OpenGL, even the few convenience functions that used a right-handed system have been deprecated or removed, as I understand it).
As for the cross product (for example), note that it does not differ mathematically between left- and right-handed coordinate systems. The result may differ when visualized, but mathematically the operation is the same.
To respond to Jessy's comment above:
Unity was made by Western people. The convention for such people is that right is the positive direction. Put that together with what I said above; when you think left-to-right, then X being positive from the vantage point of the game object (which is often a character or camera), is the way to go.
Despite the fact that OpenGL doesn't actually enforce a specific handedness, just about every OpenGL reference and tutorial ever created uses a right-handed system, so apparently it's not quite so clear that left-handed is 'the way to go' (if that's what you're implying).
Also, view space is only one of many spaces that may be of interest to developers. For example, in some contexts a right-handed system with +z up may be preferred because this results in the standard Cartesian XY coordinate system corresponding to the ground plane and z increasing with altitude. Other APIs (such as the Unreal engine) use a left-handed system, but with +z up rather than +y. There are many different conventions that are commonly used, and none of them is more 'correct' than the others (although certain conventions certainly may seem more correct to some as a result of the individual's background and personal preference).
@Fattie: Regarding your PS: The XY plane in front of you and z goes into the distance is... left-handed :D In a right-handed system z goes towards you, like in OpenGL (I know you can change it, but OpenGL is initialized right-handed, the mathematical way ;) )
Actually, many if not most modelling programs use Z-up (for example 3D$$anonymous$$ax and Blender), while many rendering engines stick to Y-up. As with right and left handedness, there is no absolute standard that everyone adheres to. There are 6 possible rudimentary permutations (left/right times X/Y/Z up), and so there even might be some ridiculous software that uses X as an up vector. $$anonymous$$ost other softwares use any of the remaining 4 permutations, probably subdivided into even more subconcepts (+Z is front, -Z is front, +X is front, ...).
There are even optimisations depending on the type of game. For example a game like warcraft or C&C all movement happens on the ground plane. It's more natural to have x-y on flat on the ground and z up (or down). Next thing is AABB testing. You usually test each axis seperately you should test those axis first which are more likely to move. So in a C&C game you would test z at last.
Depending on the engine implementation, which can't be changed, you might just want to flip your world by 90° and you get a slightly improved AABB testing x)
The way the models are created and the way they are displayed / imported should also be seperated. Unity and/or the modelling app already convert the model during export / import. However, a little bit more control over that procedure would be nice ;)
Answer by AmazingFactory · Feb 21, 2012 at 01:15 AM
Maths = Right Handed Physics = Right Handed OpenGL = Right Handed XNA = Right Handed
DirectX = Left Handed // well only cube map sampling is hard coded to left handed Unity = Left Handed // and not configurable
Right handed (or configurable) would be the smart choice.
I hope so! I wish they used Radians consistently ... you have to double check every "angle" parameter. After 7 days of evaluating Unity I think it is quicker to write the game using SlimDX or XNA. Unity is proving more of a hindrance than a help (if you are a programmer anyway) The API is a mess.
Answer by Paulius-Liekis · Dec 20, 2010 at 09:16 AM
Neither left-handed or right-handed is a standard, so there is nothing wrong in Unity using left-handed.
i come from orthodox physics. everything is right-handed. so i guess it was surprising to find that unity is left-handed
You hear that? Real life uses right-handed coordinates! Take that, standards.
On this point, Ina is correct and Paulus is wrong. Battle of the votes! :)
Pointless comment. There are standards, of course, just more than one. https://xkcd.com/927/
Answer by FrojoS · Aug 22, 2012 at 01:51 PM
I have a really stupid question: Where is the documentation for the Unity3D coordinate system convention?
Ideally, I would like to have an official document, that I can cite in a technical report, which contains:
coordinate system: left handed
gravity convention: in which direction is gravity pointing? Seems like its negative y.
Euler Angles: which order of rotation (there are 64 different possibilities!). Seems like its Kardan, with z -> y -> x, all counter clockwise.
Quaternions: Is w rotating clock wise or counterclockwise around the xyz vector?
Units: SI? Seems like the unit translation is ment to be 1 meter.
Gravity points in whatever direction you tell it to. Units are whatever you say they are.
Yes, basically you can scale the units as you wish, but some things force a special orientation / scale. Gravity can of course point in any direction, that's why we can change the vector. But afaik the CharacterController for example can't be rotated. Also Physics simulation is calculated on the basis of 1u == 1m.
However, most of this is documented. Sometimes nor where you would expect it. The documentation is a but messy, but most information is there like eulerangles multiplication order and the recommended unit scale.
The documentation folder is around 200$$anonymous$$B as of Unity 3.5 (and 350+$$anonymous$$B currently for Unity 4). There's a huge amount of information available if you care to read it. It's not always organized optimally, and some functionality is under-documented (occasionally to the point of having no real info, which is annoying to be sure), but clai$$anonymous$$g Unity is "essentially undocumented" is disingenuous at best.
Stop whining, Unity has more actually useful docs than all of the (few) engines/framework I've used. I agree I'm not as advanced as you guys and even I will sometimes have difficulty finding the exact info I'm looking for, but I always do, quickly - now try this with Unreal3.
Answer by Ming · Oct 25, 2011 at 12:01 AM
If you are right-handed, then the front-side of a triangle should also be right-handed. That is, the vertices (0, 1, 2) should wind counter-clockwise. Why? If you take Vector01 X Vector02, you get the normal which determines the front of the face for front-facing/back-facing checks. If you are left-handed, the non-commutative cross product becomes Vector02 X Vector01 to get the normal.
If you add the UVs to the triangle, I would prefer the U to go along positive X and V to go along positive Y. This leads to a right-handed coordinate system to produce a non-mirrored image.
I believe that this coordination between 2D and 3D elements makes right-handed preferred over left-handed. Additionally, physics are typically done in right-handed systems which further adds to the preference.
Your answer
Follow this Question
Related Questions
Math Optimization: Normalize 2 Answers
Converting an Azimuthal Coordinate to Vector3D? 1 Answer
Check if position is inside area? 2 Answers
More simple vector math... 2 Answers
How to get up vector of rotation? 1 Answer