Download as pdf or txt
Download as pdf or txt
You are on page 1of 95

Module – 2

• Computer Graphics & Techniques for Geometric modeling


Computer Graphics
• Deals with the generation of a 2D and 3D models of an object using
graphics software or an application software or both
• Process begins with the data input and ends with model generation
• User can generate a model by using user friendly software or by
programming.
• Latest technology is to use the specialized user friendly software.
• It is used in areas – such as science, engineering, medicines,
entertainment, advertising etc.
• Used for simulation also
Two dimensional geometric transformations
Major advantages of computer graphics is - alteration can be easily
done
The database can be modified by mathematical operations called
transformations.
Two types of these transformation
geometric transformation
coordinate transformation
• Geometric transformation :- the object itself is moved
• Coordinate transformation:- coordinate system is moved relative to it.
Geometric transformation
• Defi:- change done to the database by performing certain
mathematical operations on it, so as to produce the desired change in
the image.
• Purpose:-
• Creation of model
• Express location of objects relative to others
• To view an object from different positions and direction
• Used to perform certain transformations such as translation ……
• To create animation to study the motion of the model
formulation
• L = [ p1
P2 ] = [x1 y1
x2 y2 ]
L’ = L[TM]
[TM] = transformation matrix
Translation
Rotation
Rotation is an important transformation and allows the user to view
the objects from different angles.
Transformations such as translation, scaling or reflection are
commutative. That is the sequence of the transformations do not
change the final orientation of the object. However, rotations have a
unique property of it being non – commutative.
• Used to create entities arranged in circular arrays, by creating the
entity once and then rotating it to the desired position.
• P = [X Y]
= [ r cosᵩ r sinᵩ]
P’ = [X’ Y’]
P’ = [ r cos(ᶿ+ᵩ) r sin (ᶿ+ᵩ) ]

P’ = [X Y] * [cosᶿ sin ᶿ ; - sin ᶿ cosᶿ ]


P’ = P * R
Where R = [cosᶿ sin ᶿ ; - sin ᶿ cosᶿ ]
SCALING
• Scaling transformation alters the size of an object.
• Scaling can be uniform or non uniform.
• Scaling about the origin can be achieved by the matrix transformation
of the form:
• P’ = P * S
• [X’ Y’ ] =[ X Y] * [ Sx 0 ; 0 Sy]
Sx = scale factor in X direction
Sy = scale factor in Y direction
REFLECTION / MIRRORING
• Reflection is the process of obtaining a mirror of the original shape.
• This is an important transformation and is used quite often as many
engineering products.
• The following matrices as shown in fig. when multiplied to the
original point produce a Reflection or Mirror.

• P’ = P *M
shear
• This transformation causes the image to slant.
• The y shear preserves all the x coordinate values but shifts the y values.
• The amount of change in the y value depends upon the x position. This
causes horizontal lines to slope up or down.

P’ = P * SH
SH = [ 1 a ; 0 1] about Y axis shear

SH = [ 1 0; b 1] about X axis shear


Problem
• A rectangle is formed by four points ABCD whose coordinates are
A(50,50), B(100,50), C(100,80), D(50,80). Calculate the new
coordinates of the rectangle in reduced size using the scaling factor Sx
= 0.5 and Sy = 0.6.
• Solution: P’ = P *S
• P = [50 50; 100 50 ; 100 80 ; 50 80]
• S= [ 0.5 0 ; 0 0.6]
• P’ = [25 30; 50 30 ; 50 48 ; 25 48 ]


Homogeneous coordinates
• In the different types of transformations matrix e.g. rotation,
reflection, scaling, shearing etc. the reference point has always been
the origin.
• In some cases it is necessary to modify the position of the origin e.g.
transform every point in the two dimensional plane.
• This can effectively achieved by representing the points by their
homogeneous coordinates.
• Only translation is in the form of vector addition where as others are
in the form of multiplications
• The use of homogeneous coordinate system is vital when there are
multiple operations which include translation, which can also be
represented as a multiplication.
• X=x’ /h
• Y = y’/h
• And h is any non zero number.
• A convenient value for h is 1.
• Any point P expressed as P(x,y,1) in homogeneous coordinate system.
• The general transformation matrix is also modified to a 3X3 matrix
= [a d 0 ; b e 0 ; c f 1]
The important matrix transformation in the
homogeneous coordinate system will now be
modified as under:
• 1. translation
• 2. rotation
• 3. scaling
• 4. reflection
• 5. shear
Concatenation or composite transformation
• A) rotation about any point
• (a) original shape
• (b) translation to origin
• © rotation about origin
• Translation back to original point
• P’ = P T R T¯¹
(B) Scaling about any point :

(a) Original shape


(b) translation to origin
(c) Scaling about origin
(d) Translation back to original point
© Reflection about any axis y = mx + b

(a) Original shape


(b) Translation to origin
(c) Rotation
(d) Reflection
(e) Inverse rotation
(f) Inverse translation
P’= P T R M R¯¹ T¯¹
Problem
• Write a 3 X 3 transformation matrix for the following effects
• Scale the image to be twice as large and then translate it 1 unit to the left
• Scale X direction to be half as large and then rotate anticlockwise by 90
degree about the origin
• Rotate anticlockwise about origin by 90 degree and then scale the X direction
by half as large
• Translate down 0.5 unit, right 0.5 unit, and then rotate anticlockwise by 45
degree.
Scale the image to be twice as large and then
translate it 1 unit to the left
Scale X direction to be half as large and then
rotate anticlockwise by 90 degree about the origin
Rotate anticlockwise about origin by 90 degree
and then scale the X direction by half as large
Translate down 0.5 unit, right 0.5 unit, and then
rotate anticlockwise by 45 degree.
Problem
• Prove that a uniform scaling and a rotation form a commutative pair
of operations, but that in general scaling and rotation are not
commutative.
Problem
• Show that the transformation matrix for a reflection about the line
y=x is equivalent to a reflection relative to the X axis, followed by an
anticlockwise rotation of 90 degree.
Problem
• A triangle PQR has its vertices at P(0,0), Q(4,0) and R(2,3). It is to be
translated by 4 units in X direction, and 2 units in Y direction, then it is
to be rotated in anticlockwise direction about the new position of
point R through 90 degree. Find the new position of the triangle.
B= A*T*R*(inv)T
Problem
• Calculate the concatenated transformation matrix for the following
operations performed in the sequence as below:
• Translation by 4 and 5 units along X and Y axis
• Change of scale by 2 units in X direction and 4 units in Y direction.
• Rotation by 60 degree in CCW direction about Z axis passing through the point
(4,4).
What is the effect of the transformation on a triangle ABC with A(4,4), B(8,4)
and C(6,8).
Problem
• A square with an edge length 10 units is located on the origin with
one of the edge at an angle of 30 degree with the +X axis. Calculate
the new position of the square if is rotated by an angle 30 degree in
the clockwise direction.
Problem
• A triangle ABC is represented as A(14, 15), B(66, 15) and C(40, 60). It
is mirrored about a line y=30. Determine the new coordinates of the
triangle.
Problem
• A rectangle ABCD has vertices A(10,20) B(40,20) C(40,40) and
D(10,40).This rectangle is to be sheared in such a way that
coordinates of vertices C and D change to C’(50,40) and D’(20,40),
with A and B remains unchanged. Write the necessary transformation
for the same.
Page no 44
Problem
• The concatenated transformation of the graphics element consist of the
following operations:
• The translation through 4 and 2 units along X and Y direction respectively.
• The change of scale by 2 units in X direction and 4 unit inn Y direction.
• Rotating by 60 degree in counter clockwise direction about an axis passing through
the point (4, 2).
• Write the homogeneous transformation matrices for the above operations
and develop the concatenate transformation matrix if the operations are
done in the above sequence.
• What will be the effect of the above operations on a circle having radius of
5 units with the centre originally located at (0, 0)? Divide the circle in eight
equal parts. Sketch the original and the resulting element after
transformation.
xn=xc + R cos u
yn=yc + R sin u

• xc = 0 and yc = 0 and r=5 are given


• The corresponding eight points are tabulated below:
Angle X Y Point
0 5 0 (5,0)
45 3.536 3.536 (3.536, 3.536)
90 0 5.0 (0, 5)
135 -3.356 3.356 (-3.536, 3.536)
180 -5.00 0 (-5, 0)
225 -3.536 -3.536 (-3.536, -3.536)
270 0 -5.0 (0, -5.0)
315 3.536 -3.536 (3.536, -3.536)
360 5 0 (5, 0)
• The circle can be represented by the following matrix
Problem
• A triangle ABC with vertices A(32,22), B(88, 20) and C(32, 82) is to be
scaled by a factor of 0.6 about a point X(50, 42). Determine
• The composite transformation matrix and
• The coordinates of the vertices for the scaled triangle.
Problem
• A triangle formed by three points A,B and C whose coordinates are
A(50, 40) B(100, 60) and c(70,80). Calculate the new coordinates if
the triangle is reduced in size using scale factors Sc=0.5, Sy=0.7 and
base point is A.
Problem
• A rectangle ABCD has vertices A(1, 1), B(2, 1), C(2, 3), D(1, 3). It has to
be rotated by 30degree CCW about point P(3, 2). Determine :
• The composite transformation matrix
• The new coordinates of rectangle
Problem
• A triangle PQR with vertices P(2, 5), Q(6,7) and R(2, 7) is to be
reflected about a line 2y=x+6. Determine:
• The concatenated matrix and
• The coordinates of the matrices for the reflected triangle:
• 2y=x+6
• Y=0.5x+3
• m=0.5

• tanᶿ = slope = 0.5

•ᶿ = 26.565
• As rotation is clockwise, to make it aligned with X axis, we take as
• ᶿ = -26.565
• Concatenated matrix would be:
• G= T*R*M*INV(R)*INV(T)
Problem
• A triangle PRQ has its vertices at P(0,0), Q(4,0) and R(2,3). It is to be
translated by 4 units in X direction, and 2 units in Y direction, then it is
to be rotated in anticlockwise direction about the new position of
point R through 90 degree. Find the new position of the triangle.
Problem
• Calculate the concatenated transformation matrix for the following
operations performed in the sequence as below:
• Translation by 4 and 5 units along X and Y axis.
• Change of scale by 2 units in X direction and 4 units in Y direction.
• Rotation by 60 degree in CCW direction about Z axis passing through the point
(4,4)
What is the effect of the transformation on a triangle ABC with A(4,4), B(8,4)
and C(6,8)
Problem
• A rectangle ABCD is represented by the vertices A(20, 20), B(106.603,
70), C(81.603,113.301), D(-5,63.301). The rectangle is rotated by 30
degree clockwise about the vertex A. determine the new vertex
positions A’,B’,C’ and D’. The transformed rectangle is then to be
moved about a line joining the diagonal vertices A’ and C’. Determine
the new vertices of the rectangle.
• A’(20 20) B’(120 20) C’(120, 70) D’(20,70)

You might also like