0% found this document useful (0 votes)
5 views18 pages

2D Transformation, OCW_2

The document provides an overview of two-dimensional transformations in computer graphics, detailing basic concepts such as translation, rotation, scaling, and shearing. It explains geometric and coordinate transformations, along with the use of homogeneous coordinates for matrix operations. The chapter also discusses composite transformations and their implications on object manipulation in graphics.

Uploaded by

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

2D Transformation, OCW_2

The document provides an overview of two-dimensional transformations in computer graphics, detailing basic concepts such as translation, rotation, scaling, and shearing. It explains geometric and coordinate transformations, along with the use of homogeneous coordinates for matrix operations. The chapter also discusses composite transformations and their implications on object manipulation in graphics.

Uploaded by

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

Computer Graphics

Two-Dimensional
Transformations
Edited by
Dr. Md. Manjur Ahmed
Faculty of Computer Systems and Software
Engineering
[email protected]
Chapter Description

• Aims
– Basic of Computer Graphics.

• Expected Outcomes
– Understand the basic concept of computer graphics. (CO1: Knowledge)
– Ability to use the computer graphics technology. (CO1: Knowledge)

• References
– Dr. Masudul Ahsan, Dept. Of CSE, Khulna University of Engineering and Technology
(KUET), Bangladesh.
– Computer Graphics by Zhigang Xiang, Schaum’s Outlines.
– Donald Hearn & M. Pauline Baker, Computer Graphics with OpenGL, 4th Edition, Boston :
Addison Wesley, 2011.

2
Modeling Transformations
• Simulate the manipulation of objects in space
• Two contrary points of view for describing
object
– Geometric transformation –
• Relative to a stationary coordinate system
• Changes in orientation, size and shape
– Coordinate Transformation – Keeping the object
stationary while coordinate system is transformed
with respect to the stationary object.
Geometric transformation
– Basic Transformations
• Translation
• Rotation
• Scaling
• Shear
• Mirror reflection
Translation – 2D Transformation
(about the Origin)
• Object is moved to a new position
 Considering distance and direction P’
• Let, new point P(x,y) is found by P
adding translation distance (tx,ty) to P(x,y).
Then displacement vector is
y
x  x  t x and y  y  t y - - - - (1)
Let’s column vector

 x  x  t x 
 
P    P   T  
 y y  t y 
Therefore, Eqn (1) can be rewritten as P  P  T
Rotation – 2D
• Object is rotated along a circular path using
rotation angle ()
– Rotation angle ()
• Counter clockwise, + 
• Clockwise, - 
– Consider center (0,0) of rotation means that origin
as pivot point
Rotation – 2D y
 x r cos  
P

P    
 y  r sin  

r sin( + )
r
P

r sin
 x  r cos(   )  r
P       
 
y    
 r sin( )  r cos( +  ) x
r cos
r cos  cos   r sin  sin  
  
 r cos  sin   r sin  cos  
 x cos   y sin  
  
 x sin   y cos  
Rotation – 2D
Matrix form
 x   x  cos   y  sin   cos   sin    x 
 y   x  sin   y  cos     sin  cos     y 
       

Therefore,
P  R  P

R is called Rotation
Matrix
Scaling – 2D
• Consider the dimensions of an object, either Expand or compress
• Scaling factors for XY Plane (2D) are defined as sx and sy.
magnification if sx (or sy) > 1
reduction if sx (or sy) < 1

x  sx  x , y  s y  y
In matrix form where S is scaling matrix.
P  S P
  
 x  sx  sx 0   x
ys    0   
sy   y
 y 
Scaling – 2D
• After scaling,
– Centroid can be changed and new object will be located at a different
position relative to origin
scale factors, s  2, s 1
x y 2

2 2

1 1
1/2

Types of Scaling:
Differential ( sx != sy )
Uniform ( sx = sy )
Homogeneous Co-ordinates
• Non-homogeneously: In matrix form, translation, scaling and
rotation are defined as:
– translation: P = P + T,  22 Matrix form
– Scale: P = S · P  33 Matrix form
– Rotate: P = R · P  33 Matrix form
• Composition Transformations (??)---- more than one
transformations at a time
– But translation not expressed as a matrix multiplication method, thus
difficult to determine
• Homogeneously: Allow all three transformation by the
multiplication of 33 matrices
• Each Cartesian position (x,y) is represented by a triple (xh, yh,
h), where,
xh yh
x y
h h
Homogeneous Co-ordinates
• h can have any non zero value, better to use h = 1
• allows all transformation eq as matrix multiplication,
and
1)Transformation matrices for translation
x  x  t x , y  y  t y
 x   1 0 t x   x 
      
 y  0 1 t y  *  y 
 1  0 0 1   1 

T(t x ,t y )
Homogeneous Co-ordinates
2) Transformation matrices for rotation
x  x  cos   y  sin  , y  x  sin   y  cos 
 x   cos  sin  0  x 
       
 y   sin cos 0 *  y 
 1   0 0 1  1 

R( )
3) Transformation matrices for Scaling
x  sx  x , y  s y  y
 x   s x 0 0  x 
      
y   0 sx 0 *  y 
 1   0 0 1  1 
S( sx ,s y )
Mirror Reflection
Y Y

(1,1)
(-1,1) (1,1)

X X

(1,-1)

Reflection about X - axis Reflection about Y - axis


x  x y    y x   x y   y
1 0 0   1 0 0
M x  0  1 0 M y   0 1 0
0 0 1  0 0 1
Shearing Transformation
1 a 0 1 0 0 1 a 0
SH x  0 1 0 SH y  b 1 0 SH xy  b 1 0
0 0 1 0 0 1 0 0 1

Sheared in X Sheared in Y Sheared in both X


unit cube
direction direction and Y direction
Composite Transformation
 Composite transformation matrix based on the concatenation
of transformation matrices
 It leads to different results if the change in the order of
transformation. Thus, the matrix, [A] ∙ [B] ≠ [B] ∙ [A]

 For example, in order to rotate an object around an arbitrary


point P(h,k):
1) Translate P(h,k) to the origin.
2) Rotate it around the origin.
3) To finish, translate the center of rotation back as it
was previously.
General Pivot point, P(h,k),
Rotation of  : R,P
Step 1: Translate A(h,k) to origin
B3(x’+h, y’ +k)
Step 2: Rotate  w.r.t to origin
Step 3: Translate (0,0) to A(h,k)
A3(h,k)
R,P= T(h ,k) * R* T(-h ,-k)

B(x,y)

B1(x’,y’) B2(x’,y’)
A(h,k)

A1 (0,0) A2 (0,0)
Fixed point P(h,k) Scaling : Ssx,sy,p
Step 1: Translate P(h,k) to origin
Step 2: Scale S(sx,sy) w.r.t origin
(7,2)
Step 3: Translate (0,0) to P(h,k)
(1,1) (7,1)
Ssx,sy,P= T(h ,k) * S(sx,sy)* T(-h ,-k)
T(1,1)

(4,3)
(4,2)
(6,1)
(1,1) (4,1)
(0,0) (4,0) (0,0) (6,0)
S3/2,1/2,(1,1) T(-1,-1) S(3/2,1/2)
18

You might also like