Sunday, October 3, 2010

Confusion Coordinate System!

I spent my previous two days figuring out whats wrong with my spherical coordinate system. I checked and rechecked nothing seems wrong with the formula. It looks okay compared to the things we found on the website. But still I cant figure out whats happened to the program. Apparently, my program has become the victim of most common mistake in cartesian coordinate system interpretation. I've been through this confusion back then, I cant believe its happening again. Maybe because I use Maya a lot. Here is the problem.

Most people interpret y axis in cartesian coordinate system as an up value. And z axis as a depth value. So if you draw, for example a flying aeroplane, you're playing around with y value to calculate how high is the plane, x and z value to define the position. While you can change the coordinate system, Maya's default coordinate system works like something defined above. And those interpretation  comes to all 'begineer' programmer that not aware of those problem. 

Apparently Mathematician has another kind of coordinate system. Check the wiki for  example. It defines the cartesian coordinate system like this. Notice something weird? Yes, the z value is pointing up. Not like the one we found in Maya. Apparently, Maya's step brother Max, has the 'mathematician' coordinate system.  

OpenGL on the other hand, does not define how we can treat the coordinate system. There is no definition of up in 3D perspective OpenGL. The confusion appears a lot is that people most of the time, treat OpenGL as 3D graphic engine. But OpenGL is not JUST a 3D graphic engine. Basically it draws pixel to your 2D screen. And in 2D coordinate system, there are only x and y axis. The other z axis, is defined by "Depth". When interpreted to 3D scenery, the y value looks like an up value. But nowhere in OpenGL documentation that defines it. 

This dualism is very confusing, especially if you're dealing with coordinate system conversion. It took times for me to figure out what happened with the formula. Even Nvidia once has a sample program that become the victim of this dualism. For now, its safe to use this standard to your program: 
Remember, no axis is defined as up, depth or left. Its an open standard.. yet!
 I really hope programmer and mathematician can sit down and discuss this matter, then come up with something solid to be used. 

No comments: