Modeling, Transformations, Viewing

Modeling

Representation of geometry

Modeling is an often cumbersome process requiring manual measurement of lengths breadths, position etc. of real objects. Digitizers are now commercially available that can be used to sample a real object at a large number of points. Such representation is typically followed by a conversion to a more continuous representation, e.g. polygons or surfaces. Similarly, CT scans, MRI and ultrasound help acquire images of various parts of human body. Construction of models from images is a useful techniques. It has been extensively used for medical models and is a hot research topic.

It is not always that you want to model an existing object. In fact, one vaunted power of computer graphics is its ability to show non-existing or conceptual models. A number of modeling tools exist that provide ``intuitive'' interfaces to generate models. For example, Bézier surfaces (see definition in the text) can be represented just be its control point and just manipulating its control points. More sophisticated techniques exist.

Hierarchical modeling

Modeling and representing each piece of geometry in an environment separately can be a difficult and time consuming process. Organizing models into a hierarchy often alleviates these problems. Instead of modeling each chair in a classroom separately, we can model one chair and then transform and place it different positions Or to construct a robot, one could design a left hand -- place it at the left shoulder and then reflect it and place it at the right shoulder to model the right hand. The hand itself consist of an a palm that is attached to a fore-arm, which itself is attached to the upper-arm. The palm would consist of a number of fingers appropriately attached to it. Thus the model looks like a tree. A transformation is associated with each node of the tree which places the part of the model represented by its subtree in a bigger model, a bigger environment. Once we perform all the transformation up till the root, you have the position of each piece in the ``world'': we go from modeling to world coordinates.

Note that a number of objects at the leaf nodes look exactly like some others. For example in the class-room all chairs look alike. In fact each chair may itself consist of parts that look alike. Instead of storing a detailed representation of each object at the leaf, we can just store one copy and maintain pointers to that copy at the leaf node. This helps reduce memory requirements. Another advantage of hierarchical modeling is its easy modification. If we want throw away the old chairs in the class-room and buy new ones, all we need to do is replace the master copy of the chair and all other copies -- all instances automatically get updated.

Transformations

Common operations are translation and rotation -- these are rigid body transformations. Other transformations are scaling, reflection, shearing etc. Each operation can be written in terms of matrix multiplication, representing the transformation as a 4x4 homogeneous matrix and the vertices as a 4x1 homogeneous matrix:
[Transformed point] = [Transformation Matrix] X [Original point]
The most standard homogeneous representation of a 3D points [x, y, z] is [x, y, z, 1]. For vectors we use [x, y, z, 0] to ensure that multiplying them with a translation matrix leaves them unchanged. In general, we can get the 3D point by dividing each coordinate by the fourth coordinate (also called the homogeneous coordinate). When the homogeneous coordinate equals zero, interesting thing happen -- but we will not talk about those in this course.

The derivation of these matrices is not repeated here but the matrix themselves are reproduced. We use the right-handed coordinate system, i.e. if you curl your right hand fingers from positive X towards positive Y, your thumb points towards positive Z.

Matrices

Translate Rotate (by ø about X axis) Scale Reflect (about YZ plane) Shear (perpendicular to Z axis)
100tx
010ty
001tz
0001
1000
0cos(ø)-sin(ø)0
0sin(ø)cos(ø)0
0001
sx000
0sy00
00sz0
0001
-1000
0100
0010
0001
10a0
01b0
0010
0001
The translation matrix above corresponds to a translation by the vector [tx, ty, tz, 0]. The rotation matrix rotates a point about the X axis. All (pure) rotation matrices are orthonormal -- the magnitude of each row (or column) is 1 and the dot product of any pair of rows (or columns) is 0. Thus a rotation matrix can also represent an orthonormal basis. (The top left 3x3 submatrix is a basis for the three dimensional Euclidean space) The scaling matrix scales a point [x, y, z] to [sxx, syy, szz]. Operations can be composed. Thus a rotation followed by a translation of point p can be written as the matrix expression: R.T.p. Since matrix operations are associative, we can first multiply R.T (or any sequence of matrices) and use the result M as a composite matrix to multiply each desired point by. Note that transformations need not be commutative in general, since matrix multiplication is not commutative. Thus the order in which we carry out the transformations matters. However, check that the rigid body motions: translation and rotation are additive. Scaling is multiplicative, Reflection is a special type of scaling. Shearing is not commutative.

General transformations

While most transformations we will need in this course can be described in terms of rotation, translation etc., we may need more general axis of rotation, or more general direction of scale. In the transformation matrices listed above the major restriction comes from the fact that the origin and the orthonormal basis vectors at the origin are first class citizens. We can change this by creating an appropriately positioned and oriented set of orthonormal basis vectors and transform about that. Another way of looking at the same thing, sometimes more intuitive, is to first move the object to the origin (and sometimes, re-orient it), perform the transformation and finally move it back (after un-orienting it). Moving a point to the origin is simple it involves translating by the vector from the point to the origin. A general re-orientation can be done as follows.

Take a row of a generic rotation matrix R and transform it by R. What happens? Multiplying R to the first row results in [1, 0, 0, 0]. Similarly the other two rows generate [0, 1, 0, 0] and [0, 0, 0, 1] respectively. This means that if we rotate the three vectors (rows), we align them with our basis vectors -- the primary axes. In other words we convert from the original basis coordinates to a new set of coordinates which corresponds exactly to the basis given by the rows. That is to say any coordinate in the original basis can be rotated by R to obtain its representation in the basis given by the three rows. Confusing enough? Try a few examples and it will straighten itself out. To go back from the new basis to the original basis we can use R-1, which is the same as RT.

Viewing

Parameters commonly used to specify viewing:

To transform from the world coordinates to viewing coordinates (or camera coordinates) we use the general transformation stuff we learned about in the previous section. The VCS provides the rotation matrix and VRP provides the translation required to achieve our transformation. This transformation simplifies the projection equation. (For example, we know that the projection is along the Z axis and the view plane is perpendicular to it etc. Note that more general projections are possible, for which projection plane is not perpendicular to Z axis, but the basic math remains the same.) Let us project a point (x,y,z) on to the view plane Z=zv.

Can we write these in terms of matrix multiplication? It is equivalent to multiplying with the following matrix.