Aug 09, 2012

One day, I was playing around with OpenGL and came across this concept of transformations. Transformations in OpenGL are done via matrices, but earlier versions of OpenGL abstracts that and gives the coder a few functions that they can use. I will just say a few words about the background on how OpenGL works and move on to why we did this project. If you don't feel like reading the background, you can skip over to the project section.


In computer graphics, the concept of a 3D cartesian coordinate system is used consistently. One of the cases is in 3D transformations and rotations that are done relative to an axis system. In OpenGL, there are two conceptual axis: the global axis and the local axis. Think of the global axis as the world - there is only one at any given time. When you create an object, let's say a sphere, it has its own local axis.

One thing that depends on these axis is transformations. Two types of transformations in OpenGL are viewing and modeling transformation. Behind the scenes, these are actually transformation matrices. Modeling transformations are used to alter the position, rotation, and dimensions of an object. This transformation can be done relative to the global axis or the local axis.

For viewing transformations, there's another concept, called the camera. It's not really a camera. The idea behind it is a view to the scene. So imagine you are in the computer, and you are setting up a movie scene. You stand in one position and view the scene.

In the image above, there's only a certain amount of scene you can see. That space is called the viewing volume. There are two planes, called the near and far clip plane, that limits your view. In viewing transformations, the "camera" or view is moved. This is usually relative to the global axis.

The Project

So you're probably wondering why I mentioned all of this OpenGL stuff. Well, because of the different axis and transformations, it's sometimes difficult to imagine what will happen if you move one object there and rotate it about its local axis. Then you move it to another position and rotate it about the global axis. That is why I have decided to make a physical axis.

The last image is the finished product of the project. There are two black "cameras", two world axis, and four local axis (smaller ones). This way, I can use the local axis as an imaginary object, move it to a specific octant, rotate it in certain directions, and check if that is what I wanted in my code.