





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Before starting our next lecture just recall equations of three basic transformations i.e. translation, rotation and scaling:
Translation: P= P + T
Rotation: P= R. P
Scaling: P= S. P
In many cases of computer graphics applications we require sequence of transformations. For example in animation on each next move we may have object to be translated than scaled. Similarly in games an object in a particular moment may have to be rotated as well as translated. That means we have to perform sequence of matrix operations but the matrix we have seen in the previous lecture have order which restrict them to be operated in sequence. However, with slight reformulated we can bring them into the form where they can easily be operated in any sequence thus efficiency can be achieved.
Homogeneous Coordinates
Again considering our previous lecture all the three basic transformations covered in that lecture can be expressed by following equation: P= M 1 .P + M (^2)
With coordinate positions P and P’ represented as column vectors. Matrix M1 is a 2 by 2 array containing multiplicative factors, and M 2 is a two-element column matrix containing translation terms. For translation, M 1 is a the identity matrix, For rotation or scaling, M 2 contains the translational terms associated with the pivot point or scaling fixed point. To produce a sequence of transformations with these equations, such as scaling followed by rotation then translation, we must calculate the transformed coordinate’s one step at a time. First, coordinate positions are scaled, then these scaled coordinates are rotated, and finally the rotated coordinates are translated.
Now the question is can we find a way to eliminate the matrix addition associated with translation? Yes, we can but for that M 1 will have to be rewritten as a 3x3 matrix and also the coordinate positions will have to be expressed as a homogeneous coordinate triple:
(x, y) as (x (^) h , y (^) h , h) where
x (^) = xh , y (^) = y (^) h h h We can choose the h as any non-zero value. However, a convenient choice is 1, thus (x, y) has homogeneous coordinates as (x, y, 1). Expressing positions in homogeneous coordinates allows us to represent all geometric transformation equations as matrix
multiplications. Coordinates are represented with three-element column vectors, and transformation operations are written as 3 by 3 matrices.
Translation with Homogeneous Coordinates The translation can now be expressed using homogeneous coordinates as:
Abbreviated as: P = T (tx, ty). P
Rotation with Homogeneous Coordinates The rotation can now be expressed using homogeneous coordinates as:
Abbreviated as: P = R (). P
Scaling with Homogeneous Coordinates The scaling can now be expressed using homogeneous coordinates as:
Abbreviated as: P = S (Sx, Sy). P Matrix representations are standard methods for implementing transformations in graphics systems. In many systems, rotation and scaling functions produce transformations with respect to the coordinate origin as expressed in the equation above. Rotations and scaling relative to other reference positions are then handled as a succession of transformation operations.
Composite Transformations As in the previous section we achieved homogenous matrices for each of the basic transformation, we can find a matrix for any sequence of transformation as a composite transformation matrix by calculating the matrix product of the individual transformations.
or S (sx 2 ,sy 2 ).S(sx 1 ,sy 1 ) = S(sx 1 .sx 2 , sy 1 .sy 2 ) The resulting matrix in the case indicates that successive scaling operations are multiplicative. That is, if we were to triple the size of an object twice in succession, the final size would be nine times that of the original.
General Pivot Point Rotation
With a graphics package that only provides a rotate function for revolving object about the coordinate origin, we can generate rotations about any selected pivot point (x r , y r ) by performing the following sequence of translate-rotate-translate operations:
Translate the object so that the pivot-point positions is moved to the coordinate origin Rotate the object about the coordinate origin Translate the object so that the pivot point is returned to its original position
which can be expressed in the form
T(xr , y (^) r). R(). T(-x (^) r ,-y (^) r) = R(xr , y (^) r , )
where T(-xr , -y (^) r ) = T-1(xr , y (^) r ).
General Fixed Point Scaling Following figure is showing a transformation sequence to produce scaling with respect to a selected fixed point (x (^) f , y (^) f ) using a scaling function that can only scale relative to the coordinate origin.
Translate object so that the fixed point coincides with the coordinate origin Scale the object with respect to the coordinate origin Use the inverse translation of step 1 to return the object to its original position
Concatenating the matrices for these three operations produces the required scaling matrix.
T(xf ,y (^) f).S(sx ,s (^) y).T(-xf ,-y (^) f ) = S(x (^) f ,y (^) f , sx ,s (^) y)
This transformation is automatically generated on systems that provide a scale function that accepts coordinates for the fixed point.
Concatenation Properties Matrix multiplication is associative. For any three matrices A, B and C, the matrix product A. B. C can b3e performed by first multiplying A and B or by first multiplying B and C:
A. B. C = (A. B). C = A. (B. C) Therefore, we can evaluate matrix products using a left-to-right or a right-to-left associative grouping. On the other hand, transformation products may not be commutative. The matrix product A. B is not equal to B. A, in general. This means that if we want to translate and rotate an object, we must be careful about the order in which the composite matrix is evaluated as show in following figure.
Although matrix given before above matrix requires nine multiplications and six additions, the explicit calculations for the transformed coordinates are
x’ = x.rsxx + y.rsxy + trsx y’ = x.rsyx + y.rsyy + trsy
Thus, we only need to perform four multiplications and four additions to transform coordinate positions. This is the maximum number of computations required for any transformation sequence, once the individual matrices have been concatenated and the elements of the composite matrix evaluated. Without concatenation, the individual transformations would be applied one at a time and the number of calculations could be significantly increased. An efficient implementation for the transformation operations, therefore, is to formulate transformation matrices, concatenate any transformation sequence, and calculate transformed coordinates using above equations.
Other Transformations Basic transformations such as translation, rotation, and scaling are included in most graphics packages. Some packages provide a few additional transformations that are useful in certain applications. Two such transformations are reflection and shear.
Reflection A reflection is a transformation that produces a mirror image of an object. The mirror image for a two-dimensional reflection is generated relative to an axis of reflection by rotating the object 180o^ about the reflection axis. We can choose an axis of reflection in the xy plane or perpendicular to the xy plane. When the reflection axis is a line in the xy plane; the rotation path about this axis is in a plane perpendicular to the xy plane. For reflection axes that are perpendicular to the xy plane, the rotation path in the xy plane. Following are examples of some common reflections.
Reflection about the line y=0, the x-axis, relative to axis of reflection can be achieved by rotating the object about axis of reflection by 180o.
The transformation matrix is
Similarly in case of reflection about y-axis the transformation matrix will be, also the reflection is shown in following figure:
Shear A transformation that distorts the shape of an object such that the transformed shape appears as if the object were composed of internal layers that had been caused to slide over each other is called a shear. Two common shearing transformations are those that shift coordinate x values and those that shift y values.
An x direction shear relative to the x axis is produced with the transformation matrix