Cartesian Coordinate System
In a Cartesian coordinate system there are three axes which are at right angles with each other. The three axes intersect at their origin. The three axes are generally defined as:
- X – axis to indicate a displacement in a positive direction to the right and a displacement in a negative direction to the left;
- Y – axis where a positive displacement is up and a displacement in a negative direction is down;
- Z – axis for a displacement in a positive direction is forward and a displacement in a negative direction is backwards.
We can represent a point in in 3 D space with the aid of a Cartesian coordinate system. This is done by writing the displacement of the point along each of the three axes in the following format (x, y, z). The x is the displacement along the x – axis, also known as the x coordinate, y along the y – axis, also known as the y coordinate and z along the z – axis, also known as the z coordinate. So if we want to describe a point located one unit to the right, two units up and three units forward it is written as (1, 2, 3). I started by pointing a point, but it is also possible to represent a vector as well as a vertex on a Cartesian coordinate system using the (x, y, z) format. A vector is something that has quantity as well as direction. A vertex contains positional as well as directional values or quantities.
Objects in 3D Space
An Object in computer graphics and especially video games is something like a car, a person or a weapon. It is generally something that plays an active part in a scene. Any object in 3D space can be broken down into triangles. Each triangle can be represented by three vertices (vertices is the plural of vertex). As mentioned before vertex is a point in space that has positional as well as directional information. If we change the vertices that represent a triangle we also change that triangle. If we change all the triangles which complements an object we also change the object in 3D space. It can therefore be said that a change in the vertices caused a change in the object in 3D space. Vertex processing is the process wherey each vertex of an object is transformed from 3D in virtual space to an image on a 2D coordinate system. This 2D image can be displayed on a computer screen or printed by a printer. Vertex processing is done in a vertex shader. The modern trend is to have vertex shaders that are programmable. This allows for greater flexibility in the rendering and display of the objects by a computer. Vertex processing does provide for the following steps:
Transformation can be done by translation, scaling and rotation.
Let's take the vertex (1, 2, 3) in 3D space described by a Cartesian coordinate system. If we move this vertex one unit to the right it will end up at (2, 2, 3). We have done this mathematically by adding the one unit of movement to the x coordinate. Translation is that addition. Another method of achieving this mathematically is to make use of a matrix and homogeneous coordinates. This particular matrix is called a translation matrix. The translation is then achieved by multiplying the vertex (1, 2, 3) with the translation matrix.This will work for any vertex (x, y, z). If we do the same for all three the vertices representing the triangle the whole triangle can be moved one unit to the right along the x -axis. By using the correct matrix we can translate a vertex to anywhere we want. This also means we can translate any triangle where we want. By translating all the triangles of an object we can translate the object itself.
Scaling is achieved by multiplying the vertex. Consider vertex (1, 2, 3) again and multiply the x coordinate with three. The result would be (3, 2, 3). This means we have moved vertex (1, 2, 3) three units to the right or in a positive direction along the x – axis. Once again the same effect could have achieved with a scaling matrix. By doing the same with all three vertices of the triangle the whole triangle can be scaled three units to the right. Similarly by scaling all the triangles of an object three units to the right the object itself can be scaled three units to the right.
The rotation of a vertex is achieved by using the cosine and sine mathematical functions. This could also be achieved with a rotational matrix. Typically the vertex is rotated around one axis at a time. For instance the vertex may be rotated by 10 degrees around the x – axis then another 20 degrees around the y – axis and lastly 30 degrees around the z – axis. By rotating subsequently around the x, y and z – axis any required rotation of a vertex in 3D space can be achieved. Just as before if all the vertices of the triangle is rotated in the same manner the triangle as a whole can be rotated. Further by rotating the all the triangles that an object is composed of the object itself can be rotated through any angle in 3D space (1).
- Samyn, K. (not dated). Matrices for 3D applications – Translation & Rotation. Retrieved November 12, 2009, from knol.google.com website: http://knol.google.com/k/matrices-for-3d-applications-translation-rotation