© 2005 Pearson Education
Computer Graphics
© 2005 Pearson Education
Chapter 5
Geometric
Transformations
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Geometric Transformations
• Basic transformations:
– Translation
– Scaling
– Rotation
• Purposes:
– To move the position of objects
– To alter the shape / size of objects
– To change the orientation of objects
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Basic two-dimensional geometric
transformations (1/1)
• Two-Dimensional translation
– One of rigid-body transformation, which move objects without
deformation
– Translate an object by Adding offsets to coordinates to generate
new coordinates positions
– Set tx,ty be the translation distance, we have
– In matrix format, where T is the translation vector
xtx'x  yty'y 







y
x
P 






y
x
t
t
T






'y
'x
'P
TP'P 
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
– We could translate an object by applying the equation to
every point of an object.
• Because each line in an object is made up of an
infinite set of points, however, this process would
take an infinitely long time.
• Fortunately we can translate all the points on a line
by translating only the line’s endpoints and drawing
a new line between the endpoints.
• This figure translates the “house” by (3, -4)
Basic two-dimensional geometric
transformations (1/2)
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Translation Example
y
x0 1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
(1, 1) (3, 1)
(2, 3)
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Basic two-dimensional geometric
transformations (2/1)
• Two-Dimensional rotation
– Rotation axis and angle are specified for rotation
– Convert coordinates into polar form for calculation
– Example, to rotation an object with angle a
• The new position coordinates
• In matrix format
• Rotation about a point (xr, yr)
cosrx  sinry 





 



cossin
sincos
R PR'P 


cossincossinsincos)sin('
sincossinsincoscos)cos('
yxrrry
yxrrrx




cos)(sin)('
sin)(cos)('
rrr
rrr
yyxxyy
yyxxxx


r
r
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
– This figure shows the rotation of the house by 45
degrees.
• Positive angles are measured counterclockwise
(from x towards y)
• For negative angles, you can use the identities:
– cos(-) = cos() and sin(-)=-sin()
Basic two-dimensional geometric
transformations (2/2)
6

 
y
x0
1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Rotation Example
y
0 1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
(3, 1) (5, 1)
(4, 3)
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Basic two-dimensional geometric
transformations (3/1)
• Two-Dimensional scaling
– To alter the size of an object by multiplying the coordinates
with scaling factor sx and sy
– In matrix format, where S is a 2by2 scaling matrix
– Choosing a fix point (xf, yf) as its centroid to perform scaling
xsx'x  ysyy 


















y
x
s0
0s
'y
'x
y
x
PS'P 
)s1(ysy'y
)s1(xsx'x
yfy
xfx


Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
– In this figure, the house is scaled by 1/2 in x and 1/4 in y
• Notice that the scaling is about the origin:
– The house is smaller and closer to the origin
Basic two-dimensional geometric
transformations (3/2)
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Scaling
Note: House shifts position relative to origin
y
x
0
1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6






1
2






1
3






3
6






3
9
– If the scale factor had been greater than 1, it would be
larger and farther away.
WATCH OUT: Objects grow and move!
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Scaling Example
y
0 1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
(1, 1) (3, 1)
(2, 3)
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Homogeneous Coordinates
• A point (x, y) can be re-written in homogeneous
coordinates as (xh, yh, h)
• The homogeneous parameter h is a non-
zero value such that:
• We can then write any point (x, y) as (hx, hy, h)
• We can conveniently choose h = 1 so that
(x, y) becomes (x, y, 1)
h
x
x h

h
y
y h

Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Why Homogeneous Coordinates?
• Mathematicians commonly use homogeneous
coordinates as they allow scaling factors to be
removed from equations
• We will see in a moment that all of the
transformations we discussed previously can be
represented as 3*3 matrices
• Using homogeneous coordinates allows us use
matrix multiplication to calculate transformations –
extremely efficient!
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Homogenous Coordinates
• Combine the geometric transformation into a single matrix with 3by3
matrices
• Expand each 2D coordinate to 3D coordinate with homogenous
parameter
• Two-Dimensional translation matrix
• Two-Dimensional rotation matrix
• Two-Dimensional scaling matrix
































1
y
x
100
t10
t01
1
'y
'x
y
x




















 











1
y
x
100
0cossin
0coscos
1
'y
'x


































1
y
x
100
0s0
00s
1
'y
'x
y
x
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Inverse transformations
• Inverse translation matrix
• Two-Dimensional translation matrix
• Two-Dimensional translation matrix













100
t10
t01
T y
x
1











100
0cossin
0sincos
R 1





















100
0
s
1
0
00
s
1
S
x
x
1
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Two-dimensional composite
transformation (1)
• Composite transformation
– A sequence of transformations
– Calculate composite transformation matrix rather than
applying individual transformations
• Composite two-dimensional translations
– Apply two successive translations, T1 and T2
– Composite transformation matrix in coordinate form
PM'P
PMM'P 12


PTTPTTP
ttTT
ttTT
yx
yx



)()('
),(
),(
1212
222
111
),(),(),( 21211122 yyxxyxyx ttttTttTttT 
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Two-dimensional composite
transformation (2)
• Composite two-dimensional rotations
– Two successive rotations, R1 and R2 into a point P
– Multiply two rotation matrices to get composite
transformation matrix
• Composite two-dimensional scaling
PRRP
PRRP


)}()({'
})({)('
12
12


PssssSP
ssssSssSssS
yyxx
yyxxyxyx


),('
),(),(),(
2121
21212211
PRP
RRR


)('
)()()(
21
2112


Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Two-dimensional composite
transformation (3)
• General two-dimensional Pivot-point rotation
– Graphics package provide only origin rotation
– Perform a translate-rotate-translate sequence
• Translate the object to move pivot-point position to
origin
• Rotate the object
• Translate the object back to the original position
– Composite matrix in coordinates form
),y,x(R)y,x(T)(R)y,x(T rrrrrr  
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Two-dimensional composite
transformation (4)
• Example of pivot-point rotation
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Pivot-Point Rotation



































 











100
sin)cos1(cossin
sin)cos1(sincos
100
10
01
100
0cossin
0sincos
100
10
01




rr
rr
r
r
r
r
xy
yx
y
x
y
x
        ,,,, rrrrrr yxRyxTRyxT 
Translate Rotate Translate
(xr,yr) (xr,yr) (xr,yr)(xr,yr)
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Two-dimensional composite
transformation (5)
• General two-dimensional Fixed-point scaling
– Perform a translate-scaling-translate sequence
• Translate the object to move fixed-point position to
origin
• Scale the object wrt. the coordinate origin
• Use inverse of translation in step 1 to return the object
back to the original position
– Composite matrix in coordinates form
)s,s,y,x(S)y,x(T)s,s(S)y,x(T yxffffyxff 
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Two-dimensional composite
transformation (6)
• Example of fixed-point scaling
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
General Fixed-Point Scaling















































100
)1(0
)1(0
100
10
01
100
00
00
100
10
01
yfy
xfx
f
fx
f
f
sys
sxs
y
x
s
s
y
x
y
Translate Scale Translate
(xr,yr) (xr,yr) (xr,yr) (xr,yr)
       yxffffyxff ssyxSyxTssSyxT ,,,, ,, 
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Two-dimensional composite
transformation (7)
• General two-dimensional scaling directions
– Perform a rotate-scaling-rotate sequence
– Composite matrix in coordinates form














100
0cosssinssincos)ss(
0sincos)ss(sinscoss
)(R)s,s(S)(R
2
2
2
112
12
2
2
2
1
21
1




s1
s2
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
General Scaling Directions
• Converted to a parallelogram













100
0cossinsincos)(
0sincos)(sincos
)(),()( 2
2
2
112
12
2
2
2
1
21
1


 ssss
ssss
RssSR
x
y
(0,0)
(3/2,1/2)
(1/2,3/2) (2,2)
x
y
(0,0) (1,0)
(0,1) (1,1)
x
y s
2
s
1

Scale
Computer Graphics with OpenGL, Third Edition, by Donald Hearn and M.Pauline Baler.
IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education
Basic transformations such as translation, rotation and scaling are
include in most graphics package. Some package provide additional
transformations that are useful in certain applications. Two such
transformations are reflection and shear.
A reflection is a transformation that produces a
mirror image of an object.
The mirror image generated by rotating an
object 180 deg about reflection axis
We can choose axis of reflection in the xy
plane or perpendicular to xy plane.

Geometric transformation 2d chapter 5

  • 1.
    © 2005 PearsonEducation Computer Graphics
  • 2.
    © 2005 PearsonEducation Chapter 5 Geometric Transformations
  • 3.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Geometric Transformations • Basic transformations: – Translation – Scaling – Rotation • Purposes: – To move the position of objects – To alter the shape / size of objects – To change the orientation of objects
  • 4.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Basic two-dimensional geometric transformations (1/1) • Two-Dimensional translation – One of rigid-body transformation, which move objects without deformation – Translate an object by Adding offsets to coordinates to generate new coordinates positions – Set tx,ty be the translation distance, we have – In matrix format, where T is the translation vector xtx'x  yty'y         y x P        y x t t T       'y 'x 'P TP'P 
  • 5.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education – We could translate an object by applying the equation to every point of an object. • Because each line in an object is made up of an infinite set of points, however, this process would take an infinitely long time. • Fortunately we can translate all the points on a line by translating only the line’s endpoints and drawing a new line between the endpoints. • This figure translates the “house” by (3, -4) Basic two-dimensional geometric transformations (1/2)
  • 6.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Translation Example y x0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6 (1, 1) (3, 1) (2, 3)
  • 7.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Basic two-dimensional geometric transformations (2/1) • Two-Dimensional rotation – Rotation axis and angle are specified for rotation – Convert coordinates into polar form for calculation – Example, to rotation an object with angle a • The new position coordinates • In matrix format • Rotation about a point (xr, yr) cosrx  sinry            cossin sincos R PR'P    cossincossinsincos)sin(' sincossinsincoscos)cos(' yxrrry yxrrrx     cos)(sin)(' sin)(cos)(' rrr rrr yyxxyy yyxxxx   r r
  • 8.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education – This figure shows the rotation of the house by 45 degrees. • Positive angles are measured counterclockwise (from x towards y) • For negative angles, you can use the identities: – cos(-) = cos() and sin(-)=-sin() Basic two-dimensional geometric transformations (2/2) 6    y x0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6
  • 9.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Rotation Example y 0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6 (3, 1) (5, 1) (4, 3)
  • 10.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Basic two-dimensional geometric transformations (3/1) • Two-Dimensional scaling – To alter the size of an object by multiplying the coordinates with scaling factor sx and sy – In matrix format, where S is a 2by2 scaling matrix – Choosing a fix point (xf, yf) as its centroid to perform scaling xsx'x  ysyy                    y x s0 0s 'y 'x y x PS'P  )s1(ysy'y )s1(xsx'x yfy xfx  
  • 11.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education – In this figure, the house is scaled by 1/2 in x and 1/4 in y • Notice that the scaling is about the origin: – The house is smaller and closer to the origin Basic two-dimensional geometric transformations (3/2)
  • 12.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Scaling Note: House shifts position relative to origin y x 0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6       1 2       1 3       3 6       3 9 – If the scale factor had been greater than 1, it would be larger and farther away. WATCH OUT: Objects grow and move!
  • 13.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Scaling Example y 0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6 (1, 1) (3, 1) (2, 3)
  • 14.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Homogeneous Coordinates • A point (x, y) can be re-written in homogeneous coordinates as (xh, yh, h) • The homogeneous parameter h is a non- zero value such that: • We can then write any point (x, y) as (hx, hy, h) • We can conveniently choose h = 1 so that (x, y) becomes (x, y, 1) h x x h  h y y h 
  • 15.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Why Homogeneous Coordinates? • Mathematicians commonly use homogeneous coordinates as they allow scaling factors to be removed from equations • We will see in a moment that all of the transformations we discussed previously can be represented as 3*3 matrices • Using homogeneous coordinates allows us use matrix multiplication to calculate transformations – extremely efficient!
  • 16.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Homogenous Coordinates • Combine the geometric transformation into a single matrix with 3by3 matrices • Expand each 2D coordinate to 3D coordinate with homogenous parameter • Two-Dimensional translation matrix • Two-Dimensional rotation matrix • Two-Dimensional scaling matrix                                 1 y x 100 t10 t01 1 'y 'x y x                                  1 y x 100 0cossin 0coscos 1 'y 'x                                   1 y x 100 0s0 00s 1 'y 'x y x
  • 17.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Inverse transformations • Inverse translation matrix • Two-Dimensional translation matrix • Two-Dimensional translation matrix              100 t10 t01 T y x 1            100 0cossin 0sincos R 1                      100 0 s 1 0 00 s 1 S x x 1
  • 18.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Two-dimensional composite transformation (1) • Composite transformation – A sequence of transformations – Calculate composite transformation matrix rather than applying individual transformations • Composite two-dimensional translations – Apply two successive translations, T1 and T2 – Composite transformation matrix in coordinate form PM'P PMM'P 12   PTTPTTP ttTT ttTT yx yx    )()(' ),( ),( 1212 222 111 ),(),(),( 21211122 yyxxyxyx ttttTttTttT 
  • 19.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Two-dimensional composite transformation (2) • Composite two-dimensional rotations – Two successive rotations, R1 and R2 into a point P – Multiply two rotation matrices to get composite transformation matrix • Composite two-dimensional scaling PRRP PRRP   )}()({' })({)(' 12 12   PssssSP ssssSssSssS yyxx yyxxyxyx   ),(' ),(),(),( 2121 21212211 PRP RRR   )(' )()()( 21 2112  
  • 20.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Two-dimensional composite transformation (3) • General two-dimensional Pivot-point rotation – Graphics package provide only origin rotation – Perform a translate-rotate-translate sequence • Translate the object to move pivot-point position to origin • Rotate the object • Translate the object back to the original position – Composite matrix in coordinates form ),y,x(R)y,x(T)(R)y,x(T rrrrrr  
  • 21.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Two-dimensional composite transformation (4) • Example of pivot-point rotation
  • 22.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Pivot-Point Rotation                                                 100 sin)cos1(cossin sin)cos1(sincos 100 10 01 100 0cossin 0sincos 100 10 01     rr rr r r r r xy yx y x y x         ,,,, rrrrrr yxRyxTRyxT  Translate Rotate Translate (xr,yr) (xr,yr) (xr,yr)(xr,yr)
  • 23.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Two-dimensional composite transformation (5) • General two-dimensional Fixed-point scaling – Perform a translate-scaling-translate sequence • Translate the object to move fixed-point position to origin • Scale the object wrt. the coordinate origin • Use inverse of translation in step 1 to return the object back to the original position – Composite matrix in coordinates form )s,s,y,x(S)y,x(T)s,s(S)y,x(T yxffffyxff 
  • 24.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Two-dimensional composite transformation (6) • Example of fixed-point scaling
  • 25.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education General Fixed-Point Scaling                                                100 )1(0 )1(0 100 10 01 100 00 00 100 10 01 yfy xfx f fx f f sys sxs y x s s y x y Translate Scale Translate (xr,yr) (xr,yr) (xr,yr) (xr,yr)        yxffffyxff ssyxSyxTssSyxT ,,,, ,, 
  • 26.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Two-dimensional composite transformation (7) • General two-dimensional scaling directions – Perform a rotate-scaling-rotate sequence – Composite matrix in coordinates form               100 0cosssinssincos)ss( 0sincos)ss(sinscoss )(R)s,s(S)(R 2 2 2 112 12 2 2 2 1 21 1     s1 s2
  • 27.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education General Scaling Directions • Converted to a parallelogram              100 0cossinsincos)( 0sincos)(sincos )(),()( 2 2 2 112 12 2 2 2 1 21 1    ssss ssss RssSR x y (0,0) (3/2,1/2) (1/2,3/2) (2,2) x y (0,0) (1,0) (0,1) (1,1) x y s 2 s 1  Scale
  • 28.
    Computer Graphics withOpenGL, Third Edition, by Donald Hearn and M.Pauline Baler. IBSN 0-12-0-153-90-7 @ 2004 Pearson Education, Inc., Upper Saddle River, NJ. All right reserved © 2005 Pearson Education Basic transformations such as translation, rotation and scaling are include in most graphics package. Some package provide additional transformations that are useful in certain applications. Two such transformations are reflection and shear. A reflection is a transformation that produces a mirror image of an object. The mirror image generated by rotating an object 180 deg about reflection axis We can choose axis of reflection in the xy plane or perpendicular to xy plane.