UNIT- III CG NOTES
UNIT- III CG NOTES
UNIT – II : 2D TRANSFORMATION
COORDINATE REPRESENTATIONS:
Modeling Coordinates:
World Coordinates:
Once individual object shapes have been specified, we can place the
objects into appropriate positions within the scene using reference frame
called world coordinates.
Device Coordinates:
(xmc , ymc) -> (xwc ,ywc) -> (xnc , ync) -> (xdc , ydc)
Two dimensional Geometric Transformation
2d Transformation in Computer Graphics is utilized to modify the position,
orientation, or size of objects within a two-dimensional space. These
transformations involve applying mathematical operations to the coordinates of
points or vertices in order to achieve the desired changes.
Basic Transformation:
Translation
Rotation
Scaling
Translation
o The translate one distance pair (tx , ty,) is called a translation vector or shift
vector.
o We can express the translation equations 1 as a single matrix equation by
using column vectors to represent coordinate positions and the translation
vector:
-------->2
o Polygons are used to translate the vector to coordinate the position of each
vertex, regenerate the polygon new set of vertex coordinates and the current
attribute settings.
o Figure 5.2 illustrates the application of a specified translation vector to move
an object from one position to an other.
o This method used to translate curved objects.
o To change the position of a circle or ellipse, we translate the center and
redraw the figure in the new location.
o To translate the Spline curves displace and coordinate positions define the
objects, then reconstruct the curve paths using the translated coordinate
points.
ROTATION
o A two-dimensional rotation is applied to an object by repositioning it along a
circular path in the xy plane.
o To generate a rotation, we specify a rotation angle Ɵ and the position (xr , yr)
of the rotation point (or pivot point) about which the object is to be rotated
(Fig. 5-3).
o Positive values for the rotation angle define counterclockwise
Rotations about the pivot point, as in Fig. 5-3, and negative values
rotate objects in the clockwise direction.
x’ = x cos Ɵ - y sin Ɵ
P’ = R.P --------------------> 4
--------> 5
P’T = ( R.P )T
= P T . RT
o For a rotation matrix, the transpose is obtained by simply changing the sign
of the sine terms.
x’ = xr + (x – xr ) cos Ɵ - (y – yr ) sin Ɵ
SCALING
o A scaling transformation alters the size of an object. (or) scaling refers
to the process of resizing objects in a 2D or 3D space.
o This operation can be carried out for polygons by multiplying the coordinate
values (x, y) of each vertex by scaling factors sX, and sY, to produce the
transformed coordinates (x', y'):
--------------------> 2
Or
P’ = S.P -----------> 3
o Unequal values for sx, and sy, result in a differential scaling that is often
used in design applications, where pictures are constructed from a few basic
shapes that can be adjusted by scaling and positioning transformations (Fig.
5-6).
o We can control the location of a scaled object by choosing a position, called
o the fixed point, that is to remain unchanged after the scaling transformation.
Coordinates for the fixed point (xf, yf) can be chosen as one of the vertices,
the object centroid, or any other position (Fig. 5-8).
o A polygon is then scaled relative to the fixed point by scaling the distance
from each vertex to the fixed point. For a vertex
o with coordinates (x, y).i, the scaled coordinates( x ' , y ') are calculated as
x’ = xf + (x – xf)sx , y’ = yf + (y – yf)sy -------------->4
P’=T(tx, ty).P---->4
T(tx, ty) -> in 3 by 3 translation matrix, inverse the translation matrix tx, ty in
negative -tx, -ty
R= cos Ɵ -sin Ɵ
Sin Ɵ cos Ɵ
X’ cos Ɵ -sin Ɵ 0 x
Y’ = sin Ɵ cos Ɵ 0 . y --------->5
1 0 0 1 1
P’ = R (Ɵ).P ----------> 6
X’ sx 0 0 x
Y’ = 0 sy 0 . y --------->6
1 0 0 1 1
(or)
P’ = s(sx,sy).P ------------->8
COMPOSITE TRANSFORMATION
Translation
Two translation vectors (tx1, ty1) and (tx2, ty2) coordinate position P, the final
transformed location P’ is calculated as
ROTATIONS
P’= R(Ɵ2).{R(Ɵ1).P}
= {R(Ɵ2).R(Ɵ1).P -----> 3
final rotated coordinates can be calculated with the composite rotation matrix as,
SCALING
---------> 6
Generate rotations about selected pivot point (xr , yr) to perform the following
sequence of translate-rotate-translate operations.
The composite matrix for this sequence is obtained with the concatenation
Which can be expressed in the form
Where T(-xr, -yr) = T -1 (xr , yr) a rotate function can be set up to accept
parameters for pivot-point coordinates.
A Selected fixed position (xf, yf) using a scaling function that can only scale
relative to the coordinate origin.
1. Translate object so that the fixed point coincides with the coordinate
origin.
2. Scale the object with respect to the coordinate origin.
3. Use the inverse translation of step 1 to return the object to its original
position.
CONCATENATION PROPERTIES
Matrix multiplication is associative.
Three matrices A,B,C the matrix product A.B.C (first multiply A and B or by
first multiplying B and C)
A.B.C=(A.B).C=A.(B.C) ---->1
OTHER TRANSFORMATION
REFLECTION
A Reflection is a transformation that produces a mirror image of an
object.
The mirror image for a two-dimensional reflection is generated to an
axis of reflection by rotating the object 1800 about the reflection axis
Reflection about the line y=0 , the x axis, is accomplished with the
transformation matrix
1 0 0
0 -1 0
0 0 1 ------------>1
A reflection about the y axis flips x coordinates while keeping y
coordinates the same. The matrix for this transformation is
-1 0 0
0 1 0
0 0 1 -------->2
-1 0 0
0 -1 0
0 0 1 ------->3
Reflection of an object about the y axis
SHEAR
1 sh 0
0 1 0
0 0 1 ----------->1
-->3
A shear parameter value of ½ relative to the line yref= -1.
Reflection line y = -x
-->3
2D VIEWING
Also, by varying the size of viewports, we can change the size and
proportions of displayed objects.
We achieve zooming effects by successively mapping different-sized
windows on a fixed-size viewport.
As the windows are made smaller, we zoom in on some part of a scene to
view details that are not shown with larger windows.
The graphics package is largely device-independent. Once the scene has
been transferred to normalized coordinates.
when all coordinate transformations are completed, viewport clipping can
be performed in normalized coordinates or in device coordinates.
ADVANTAGE
This allows us to reduce computations by concatenating the various
transformation matrices.
Clipping procedures are of fundamental importance in computer graphics.
They are used not only in viewing transformations, but also in window-
manager systems, in and drawing packages to eliminate parts of a picture
inside or outside of a designated screen area, and in many other applications.
This coordinate system provides the reference frame for specifying the
world coordinate window We set up the viewing coordinate system using
the procedures First, a viewing-coordinate origin is selected at some world
position: Po = (x0, y0).
Then we need to establish the orientation, or rotation, of this reference
frame. One way to do this is to specify world vector V that defines the
viewing y, direction. Vector V is called the view up vector.
Given V, we can calculate the components of unit vectors v = (vx,Vy) and
T -> translation matrix that takes the viewing origin point Po to the
world origin.
R -> rotation matrix that aligns the axes of the two reference
frames.
WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION
xʋ - xʋmin = xѠ - xѠmin
------------------> 1
yʋ - yʋmin = yѠ - yѠmin
o (sx = sy) -> scaling factors proportions are maintained in the same size.
o Character strings can be handled in two ways when they are mapped to a
viewport.
o The simplest mapping maintains a constant character size,the viewport
area may be enlarged or reduced relative to the window.
o Character size can be changed,but Character fonts cannot be changed.
o From normalized coordinates,object descriptions are mapped to the
display devices.
o Workstation Transformation:
o Number of output devices can be open in a particular application ,
and another window-to-viewport transformation can be performed
for each open output device. This mapping,called the workstation
transformation.