0% found this document useful (0 votes)
17 views28 pages

UNIT- III CG NOTES

The document discusses 2D transformations in computer graphics, focusing on coordinate representations, including modeling, world, device, and normalized device coordinates. It details basic transformations such as translation, rotation, and scaling, providing mathematical equations and matrix representations for each. Additionally, it covers composite transformations, properties of matrix multiplication, and other transformations like reflection.

Uploaded by

suganthak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views28 pages

UNIT- III CG NOTES

The document discusses 2D transformations in computer graphics, focusing on coordinate representations, including modeling, world, device, and normalized device coordinates. It details basic transformations such as translation, rotation, and scaling, providing mathematical equations and matrix representations for each. Additionally, it covers composite transformations, properties of matrix multiplication, and other transformations like reflection.

Uploaded by

suganthak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

COMPUTER GRAPHICS

UNIT – II : 2D TRANSFORMATION
COORDINATE REPRESENTATIONS:

 General graphics packages are designed to be used with Cartesian


coordinate specifications.
 If coordinate values for a picture are specified in some other reference
frame (Spherical, Hyberbolic) they must be converted to Cartesian
coordinates.
 Special – purpose packages may allow the coordinate frames for an
application.

Modeling Coordinates:

 We can construct the shape of individual objects , such as trees or


furniture in a scene within separate coordinate reference frames called
Modeling Coordinates or sometimes local coordinates or master
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:

 The world- coordinate description of the scene is transferred to one or


more output-device reference frames for display.
 These display coordinate systems are referred to as device coordinates, or
screen coordinates

Normalized device coordinates:

 A graphics system first converts world-coordinate positions to


normalized device coordinates in the range from 0 to 1 before final
conversion to specific device coordinates.
o An initial modeling –coordinate position (xmc , ymc) is transferred to a device
coordinate position (xdc ,ydc ) with the sequence:

(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 A translation is applied to an object by repositioning it along a straight-line


path from one coordinate location to another.

o We translate a two-dimensional point by adding translation distances tx,


and ty, to the original coordinate position (x, y) to move the point to a new
position ( x ' , y') (Fig. 5-1).

x' = x + tx , y' = y + ty --------> 1

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

Two-dimensional translation equations in the matrix


form:
P’ = P + T -------------> 3

o Sometimes, Matrix – transformation equations are expressed in terms of


coordinate row vectors instead of column vectors.

o The matrix representations as P = [ x, y ] and [tx,ty]. The column –vector


representation for a point is standard mathematical notation.

o Many Graphics Packages : GKS (Graphics Kernel System),PHIGS( is a


device-independent interface between the application program and the
graphics subsystem.) use the column-vector representation.

o Translation is a rigid – body transformation (is a movement of the shape


that does not affect the size of the shape) that moves objects without
deformation.

o A straight line segment is translated by applying the transformation


equations 3 to each of the line endpoints and redrawing the line between the
new endpoint positions.

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.

o This transformation can also be described as a rotation about a rotation axis


that is perpendicular to the xy plane and passes through the pivot point.

o We first determine the transformation equations for rotation of a point


position P when the pivot point is at the coordinate origin.

o The angular and coordinate relationships of the original and transformed


point positions are shown in Fig. 5-4. In this figure,

o r - constant distance of the point from the origin.


o ɸ - Original angular position of the point from the horizontal
o Ɵ – Rotation angle

o Using standard trigonometric identities, we can express the transformed


coordinates in terms of angles Ɵ and ɸ as

x’ = r cos(ɸ + Ɵ ) = r cos ɸ cos Ɵ - r sin ɸ sin Ɵ

y’ = r sin (ɸ + Ɵ) = r cos ɸ sin Ɵ + r sin ɸ cos Ɵ -------> 1


The original coordinates of the point in polar coordinates are

X = r cos ɸ, y = r sin ɸ --------> 2

Substituting expressions 2 into 1 , we obtain the transformation equations for


rotating a point at position (x,y) through an angle Ɵ about the origin:

x’ = x cos Ɵ - y sin Ɵ

y’ = x sin Ɵ + y cos Ɵ ---------> 3

with the column – vector representations from translation equation2 for


coordinate positions, we can write the rotation equations in the matrix form:

P’ = R.P --------------------> 4

Where the rotation matrix is

--------> 5

o When coordinate positions are represented as row vectors instead of column


vectors, the matrix product in rotation equation 4 is transposed so that the
transformed row coordinate vector Ix' y'l is calculated as

P’T = ( R.P )T

= P T . RT

o where PT = (x, y), and the transpose RT of matrix R is obtained by


interchanging rows and columns.

o For a rotation matrix, the transpose is obtained by simply changing the sign
of the sine terms.

o Rotation of a point about an arbitrary pivot position is illustrated in


Fig.5.5
o We can generalize 3rd equation to obtain the transformation equations for
rotation of a point about any specified rotation position ( xr,yr)

x’ = xr + (x – xr ) cos Ɵ - (y – yr ) sin Ɵ

y’ = yr + (x – xr ) sin Ɵ + (y – yr ) cos Ɵ ---------> 6

o Rotations are rigid – body transformations that move objects without


deformation.
o Every point on an object is rotated through the same angle.
o A straight line segment is rotated by applying the rotation equations 6 to
each of the line endpoints and redrawing the line between the new endpoint
positions.
o Polygons are rotated by displacing each vertex through the specified rotation
angle and regenerating the polygon using the new vertices.
o A circle or an ellipse for instance can be rotated about a noncentral axis by
moving the center position through the arc that subtends the specified
rotation angle.
o An ellipse can be rotated about its center coordinates by rotating the major
and minor axes.

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'):

x' = x . sx , y' = y . sy --------------> 1


o Scaling factor sx, scales objects in the x direction, while sy scales in the y
direction.

o The transformation equation1 can also be written in the matrix form:

--------------------> 2

Or
P’ = S.P -----------> 3

o Where S is the 2 by 2 Scaling Matrix


o Any positive numeric values can be assigned to the scaling factors sx, and sy.
Values less than 1 reduce the size of objects; values greater than 1 produce
an enlargement.
o Specifying a value of 1 for both sx, and sy, leaves the size of objects
unchanged.
o When sx, and sy, are assigned the same value, a uniform scaling is produced
that maintains relative object proportions.

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

o We can rewrite these scaling transformations to separate. the mdtiplicative


and additive terms:
x’ = x .sx+ xf ( 1 – sx )
y’ = y .sy+ yf ( 1 – sy ) ------------------------> 5

MATRlX RFPRESENtATlONS AND HOMOGENEOUS COORDINATES


 Many graphics applications involves in transformation
o Ex: animation
 For animation we require an object to be translated and rotated at
each increment of the motion
 In design picture construction we perform translations , rotation,
scalings to fit the picture components into proper positions.
 Reformulate the transformation sequences,
 Basic transformation can be expressed in the general matrix form
o P’= M1 . P + M2 -------->1
 P,P’ -> column vectors, M1 – 2 by 2 array contains multiplication factors.
 M2 -> two element column matrix contains translational terms.
 M1-> identify matrix for rotation or scaling
 M2 -> translation terms for pivot point scaling fixed point.
 Cartesian coordinate position (x,y)
 Homogenous coordinate (xh,yh,h)
o X= xh / h
o Y = yh / h -------->2
Homogenous coordinates,geometric transformations equations in form of
matrix multiplications
Coordinate column vectors are 3 by 3 matrix
X’ 1 0 tx x
Y’ = 0 1 ty . y ---->3
1 0 0 1 1
Write it in the translation form

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

Rotation transformation equation

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

Now write down the scaling transformation in multiplication form

X’ sx 0 0 x

Y’ = 0 sy 0 . y --------->6

1 0 0 1 1

(or)

P’ = s(sx,sy).P ------------->8

S(sx,sy) ----> 3 by 3 matrix

Sx, sy ----------> Parameters


Replace the Parameters in multiplicative inverse (1/sx , and 1/sy ) inverse scaling
matrix.

COMPOSITE TRANSFORMATION

 A matrix for any sequence of transformations as a composite


transformation matrix by calculate the product of transformations.
 Transformation matrices also referred as “Concatenation”, or
“Composition”

Translation

Two translation vectors (tx1, ty1) and (tx2, ty2) coordinate position P, the final
transformed location P’ is calculated as

P’ ={ T (tx2, ty2) .T (tx1, ty1).P} ---------------->1

= {T(tx2, ty2). T (tx1, ty1)}.P

P and P’ are represented as homogenous-coordinate column vectors.

Convert it into transformation matrix

T(tx2, ty2). T (tx1, ty1) = T(tx2, + ty2 +tx1 + ty1) --->2

Which demonstrates two successive translations are additive

ROTATIONS

Two successive rotations applied to point P produce transformed position

P’= R(Ɵ2).{R(Ɵ1).P}

= {R(Ɵ2).R(Ɵ1).P -----> 3

Multiply the two rotation matrices,verify the rotations are additive


R(Ɵ2).R(Ɵ1) = R(Ɵ1 + Ɵ2 ) ------->4

final rotated coordinates can be calculated with the composite rotation matrix as,

P’ = R (Ɵ1 + Ɵ2 ).P ------->5

SCALING

Concatenate transformation matrices for two scaling operations.calculate the


scaling matrix:

---------> 6

S(sx2 ,sy2). S(sx1 ,sy1) = S(sx1. Sx2, sy1. Sy2 ) ----------->7

GENERAL PIVOT –POINT ROTATION(5 mark)

Generate rotations about selected pivot point (xr , yr) to perform the following
sequence of translate-rotate-translate operations.

1. Translate the object so that the pivot-point positions is moved to the


coordinate origin.
2. Rotate the object about the coordinate origin.
3. Translate the object is so that the pivot point is returned to its original
position.

The composite matrix for this sequence is obtained with the concatenation
Which can be expressed in the form

T(xr,yr).R(Ɵ).T(-xr, -yr )=R(xr,yr, Ɵ) -->2

Where T(-xr, -yr) = T -1 (xr , yr) a rotate function can be set up to accept
parameters for pivot-point coordinates.

GENERAL FIXED-POINT SCALING

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.

Concatenate the matrices for three operations scaling matrix

T(xf, yf) .S(sx, sy ).T (-xf, -yf) = S(xf, yf,sx, sy ) --------->1

This transformation generate the scale function that accepts coordinates


for the fixed point.
GENERAL SCALING DIRECTIONS
Parameters sx, sy scale objects along the x and y directions.
Scale the object and rotate the object.

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

We flip both the x and y coordinates of a point by reflecting relative


to an axis that is perpendicular to xy plane

-1 0 0
 0 -1 0
 0 0 1 ------->3
Reflection of an object about the y axis

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 shear.
 Two shearing transformations:
o Shift coordinate x values
o Shift y values

An x –direction shear relative to the x axis is produced with the transformation


matrix

1 sh 0
 0 1 0

0 0 1 ----------->1

Transforms coordinate positions as

X’=x+shx.y, y’=y --------->2


Any real number can be assigned to the shear parameter shx.

A coordinate position (x,y) is then shifted horizontally.

Distance y value from the x axis (y=0)

Generate the x-direction shears relative to other reference lines with

-->3
A shear parameter value of ½ relative to the line yref= -1.

Reflection line y = -x

A y –direction shear relative to the line x = xref is generated with the


transformation matrix

-->3

The reference line x =x ref. shy = ½ and xref = -1

Shearing operations expressed as sequences of basic transformations.


Shifts in the positions of objects relative to shearing reference lines are equivalent
to translations.

2D VIEWING

THE VIEWING PIPELINE

A world-coordinate area selected for display is called a window.


An area on a display device to which a window is mapped is called a
viewport.
The window defines what is to be viewed; the viewport defines where it is
to be displayed.
Often, windows and viewports are rectangles in standard position, with the
rectangle edges parallel to the coordinate axes.
Other window or viewport geometries ,such as general polygon shapes and
circles, are used in some applications.
but these shapes take longer to process, Sometimes the two-dimensional
viewing transformation is simply referred to as the window-to-viewport
transformation or the windowing transformation.
But, in general, viewing involves more than just the transformation from the
window to the viewport.
Figure 6-1 illustrates the mapping of a picture section that falls within a
rectangular window onto a designated &angular viewport.
In computer graphics terminology, the term window originally referred to
an area of a picture that is selected for viewing.
Some graphics packages that provide window and viewport operations
allow only standard rectangles.
but a more general approach is to allow the rectangular window .
In this case, we carry out the viewing transformation in several steps, as
indicated in Fig. 6-2. First, we construct the scene in world coordinates
using the output primitives and attributes.
A particular orientation for the window, we can set up a two-dimensional
viewing-coordinate system in the world coordinate plane, and define a
window In the viewing-coordinate system.
The viewing coordinate reference frame is used to provide a method for
setting up arbitrary orientations for rectangular windows. Once the viewing
reference frame is established.
we can transform descriptions in world coordianets to viewing coordinates.
We then define a Viewport in normalized coordinates and map the viewing-
coordinate description of the scene to normalized coordinates.
At the final step,all parts of the picture that the outside the viewport
are clipped, and the contents of the viewport are transferred to device
coordinates.
Figure 6-3 i1lustratts a rotated viewing-coordinate reference frame and the
mapping to normalized coordinates.

By changing the position of the viewport, we can view objects at different


positions on the display area of an output device.

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.

VIEWING COORDINATE REFERENCE FRAME

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

u = (ux,Uy) for the viewing y, and x, axes, respectively. These unit


vectors are used to form the first and second rows of the rotation matrix R
that aligns the
o viewing xv,yv. axes with the world x,y,, axes.
Figure 6 4
A viewing-coordinate frame is moved into coincidence with the world
frame in two steps: (a) translate the viewing origin to the world origin,
then (b) rotate to align the axes of the two systems.

We obtain the matrix for converting worldcoordinate positions to viewing


coordinates as a two-step composite transformation:
First, we translate the viewing origin to the world origin, then we
rotate to align the two coordinate reference
frames. The composite two-dimensional transformation to convert world
coordinates to viewing coordinate is

Mwc.vc = R.T ----------------------> 1

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

o Once object descriptions transferred to the viewing reference frame,


choose the window extents in viewing coordinates and select the viewport
limits in normalized coordinates.
o Object descriptions are then transferred to normalized device coordinates.
o If a coordinate position is at the center of the viewing window, it will be
displayed at the center of the viewport.
o Fig 6.5 illustrates the window-to-viewport mapping.

o A point at position (xѠ,yѠ) in the window is mapped into position (xʋ,yʋ)


in the associated viewport.

xʋ - xʋmin = xѠ - xѠmin

xʋmax - xʋmin xѠmax - xѠmin

------------------> 1

yʋ - yʋmin = yѠ - yѠmin

yʋmax - yʋmin yѠmax - yѠmin


o Solving these expressions for the viewport position (xʋ ,yʋ ), we have
xʋ = xʋmin + (xѠ - xѠmin ) sx
yʋ = yʋmin + (yѠ - yѠmin ) sx -------------> 2

o Equation 3 can be derived with a set of transformations that converts the


window area into the viewport area.

1. Perform a scaling transformation using a fixed-point position of


(xѠmin, , yѠmin).
2. Translate the scaled window area to the position of the
viewport.

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy