0% found this document useful (0 votes)
894 views48 pages

Chapter2 CAD CAM TRANSFORMATION

The document discusses basic 2D geometric transformations in computer graphics, including translation, rotation, and scaling. Translation moves objects by adding offsets to coordinates. Rotation specifies an axis and angle of rotation to calculate new coordinate positions. Scaling alters an object's size by multiplying coordinates by scaling factors. These transformations are used to position, orient, and resize objects and can be represented by transformation matrices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Topics covered

  • Pivot-Point Rotation,
  • Affine Transformations,
  • Scaling,
  • Computer Graphics Techniques,
  • 3D Transformations,
  • Composite Transformations,
  • Transformation Effects,
  • Geometric Representation,
  • Object Manipulation,
  • Counterclockwise Rotation
0% found this document useful (0 votes)
894 views48 pages

Chapter2 CAD CAM TRANSFORMATION

The document discusses basic 2D geometric transformations in computer graphics, including translation, rotation, and scaling. Translation moves objects by adding offsets to coordinates. Rotation specifies an axis and angle of rotation to calculate new coordinate positions. Scaling alters an object's size by multiplying coordinates by scaling factors. These transformations are used to position, orient, and resize objects and can be represented by transformation matrices.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Topics covered

  • Pivot-Point Rotation,
  • Affine Transformations,
  • Scaling,
  • Computer Graphics Techniques,
  • 3D Transformations,
  • Composite Transformations,
  • Transformation Effects,
  • Geometric Representation,
  • Object Manipulation,
  • Counterclockwise Rotation

Computer Graphics

with OpenGL 3e

© 2005 Pearson Education


Chapter 5
Geometric
Transformations

© 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
x'  x  t x y'  y  t y

– In matrix format, where T is the translation vector


 x'  x  t x 
P'    P  T 
 y'  y  t y 

P'  P  T

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/2)
– 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)

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

4
(2, 3)
3

1
(1, 1) (3, 1)

0 1 2 3 4 5 6 7 8 9 10 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
Basic two-dimensional geometric
transformations (2/1)

• Two-Dimensional rotation
– Rotation axis and angle are specified for rotation r
– Convert coordinates into polar form for calculation
r
x  r cos  y  y sin 
– Example, to rotation an object with angle a
• The new position coordinates
x'  r cos(   )  r cos  cos  r sin  sin   x cos  y sin 
y '  r sin(   )  r cos  sin   r sin  sin   x sin   y cos 
• In matrix format
cos   sin  
R P'  R  P
 sin  cos  
• Rotation about a point (xr, yr)
x'  xr  ( x  xr ) cos  ( y  yr ) sin 
y '  yr  ( x  xr ) sin   ( y  yr ) cos 

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/2)

– This figure shows the rotation of the house by 45


degrees. y
6

2


1 6

0
1 2 3 4 5 6 7 8 9 10
x
• Positive angles are measured counterclockwise
(from x towards y)
• For negative angles, you can use the identities:
– cos(-) = cos() and sin(-)=-sin()

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

4
(4, 3)
3

1
(3, 1) (5, 1)

0 1 2 3 4 5 6 7 8 9 10
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
x'  x  s x y  y  sy
– In matrix format, where S is a 2by2 scaling matrix
 x ' s x 0  x
   0  P'  S  P
 y '  s y   y 

– Choosing a fix point (xf, yf) as its centroid to perform scaling


x'  x  s x  x f (1  s x )
y'  y  s y  y f (1  s y )

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/2)

– 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

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

– If the scale factor had been greater than 1, it would be


larger and farther away.
WATCH OUT: Objects grow and move!
y
6

3 6 9
 3 3
   
2

1  2 3
1  1
   
0
1 2 3 4 5 6 7 8 9 10
x
Note: House shifts position relative to origin

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

4
(2, 3)
3

1
(1, 1) (3, 1)

0
Computer Graphics with OpenGL,1Third Edition,
2 by Donald3 Hearn and
4 M.Pauline5Baler. 6 7 8 9 10
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:
xh yh
x y
h h
• 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)

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
 x '  1 0 t x   x 
     
y '
    0 1 t y   y
 1  0 0 1   1

• Two-Dimensional rotation matrix


 x' cos   cos  0  x 
     
 y'   sin cos  0   y 
 1   0 0 1  1
• Two-Dimensional scaling matrix
 x ' s x 0 0  x 
     
 y '   0 sy 0   y 
 1   0 0 1  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
Inverse transformations

• Inverse translation matrix


1 0  t x 
 
T 1  0 1  t y 
0 0 1 

• Two-Dimensional translation matrix


 cos  sin 0
 
R 1   sin cos  0
 0 0 1

• Two-Dimensional translation matrix


 1 
s 0 0 
 x 
1
S 1   0 0
 sx 
0 0 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
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
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
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
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
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
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
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 2D Transformations

• Basic 2D transformations as 3x3 Matrices

 x  1 0 tx   x   x   sx 0 0   x 
 y  0 1 ty   y   y  0 sy 0  y 
         
1  0 0 1  1  1  0 0 1  1 
Translate Scale
 x  cos  sin  0   x   x  1 shx 0   x 
 y  sin  cos 0  y  y   shy 1 0  y 
         
1  0 0 1  1  1  0 0 1 1 

Rotate Shear

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 in three-
dimensional space (1)

• Extend from two-dimensional transformation by including


considerations for the z coordinates
• Translation and scaling are similar to two-dimension,
include the three Cartesian coordinates
• Rotation method is less straight forward
• Representation
– Four-element column vector for homogenous coordinates
– Geometric transformation described 4by4 matrix

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 in three-
dimensional space (2)

• Three-dimensional translation
– A point P (x,y,z) in three-dimensional space translate to new
location with the translation distance T (tx, ty, tz)
x'  x  t x y'  y  t y z'  z  t z
– In matrix format
 x '  1 0 0 t x  x
     
 y'  0 1 0 t y  y
 P'  T  P
 z'  0 0 1 t z  z
     
 1  0 0 0 1   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
Geometric transformations in three-
dimensional space (3)

• Three-dimensional scaling
– Relative to the coordinate origin, just include the parameter
for z coordinate scaling in the transformation matrix
 x ' s x 0 0 0  x 
     
 y '   0 sy 0 0  y 
 P'  S  P
 z'   0 0 sz 0 z

     
 1  0 0 0 1  1
– Relative to a fixed point (xf, yf zf)
• Perform a translate-scaling-translate composite
transformation
t( x f , y f , z f )  S(s x , s y , s z )  T(  x f , y f ,z f )
s x 0 0 (1  s x )x f 
 
0 sy 0 (1  s y )y f 

0 0 sz (1  s z )z f 
 
0 0 0 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
Geometric transformations in three-
dimensional space (4)

• Three-dimensional rotation definition


– Assume looking in the negative direction along the axis
– Positive angle rotation produce counterclockwise
rotations
about a coordinate axis

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 in three-
dimensional space (5)

• Three-dimensional coordinate-axis rotation


– Z-axis rotation equations Rz
 x' cos  sin 0 0  x 
x'  x cos   y sin
     
y'  x sin  y cos  y '
  sin  cos  0 0   y
z'  z  z'   0 0 1 0  z 
     
1
   0 0 0 1   1
– Transformation equations for rotation about the other two
coordinate axes can be obtained by a cyclic permutation
x  y  z  x
– X-axis rotation equations 1 0 0 0
y'  y cos   z sin 0 cos  sin  0
z'  y sin  z cos  Rx  Rx   
0 sin  cos
 
x'  x
0
 
0 0 0 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
Geometric transformations in three-
dimensional space (6)

• Three-dimensional coordinate-axis rotation


– Y-axis rotation equations  cos 0 sin  0
z'  z cos   x sin  0 1 0 0
x'  z sin  x cos  R y  R y    
y'  y  sin  0 cos 0
 
– General Three-dimensional rotations  0 0 0 1
• Translate object so that the rotation axis coincides with the parallel
coordinate axis
• Perform the specified rotation about that axis
• Translate object back to the original position
P'  T 1  R x ( )  T  P
R( )  T 1  R x ( )  T

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 in three-
dimensional space (7)

• Inverse of a rotation matrix


R 1    R  

cos    cos , sin      sin 

cos    sin    0 0  cos sin  0 0


 sin    cos   0 0  sin  cos 0 0
R z1    R z      
 0 0 1 0  0 0 1 0
   
 0 0 0 1  0 0 0 1

1 T
R R : orthogonal matrix
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
Concatenation of Transformations

• Concatenating
– affine transformations by multiplying together
– sequences of the basic transformations
 define an arbitrary transformation directly
– ex) three successive transformations
p1 p2
p A B C q

p1 = Ap
p2 = Bp1 q  CBAp   CBAp
q = Cp2 CBA
M  CBA
q = CBp1
q = CBAp q  Mp p M q
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
Matrix Concatenation Properties

• Associative properties

M1  M2  M3  M1  (M2  M3 )  (M1  M2 )  M3

• Transformation is not commutative (CopyCD!)


– Order of transformation may affect transformation
position

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
P'  M2  M1  P
P'  M  P
• Composite two-dimensional translations
– Apply two successive translations, T1 and T2
T1  T (t1x , t1 y )
T2  T (t 2 x , t 2 y )
P '  T2  (T1  P )  (T2  T1 )  P

T( t 2 x , t 2 y )  T( t 1x , t 1y )  T( t 1x  t 2 x , t 1y  t 2 y )
– Composite transformation matrix in coordinate form

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
P'  R(1 )  {R( 2 )  P}
P'  {R(1 )  R( 2 )}  P

– Multiply two rotation matrices to get composite


R(1 )  R( 2 ) matrix
transformation  R(1   2 )
P'  R(1   2 )  P

S(s1x ,two-dimensional
• Composite s1y )  S(s 2 x , s 2 y )  Sscaling
( s1x  s 2 x , s1y  s 2 y )
P'  S(s1x  s 2 x , s1y  s 2 y )  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
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
T( x r , y r )  R( )  T(  x r , y r )  R( x r , y 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
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

(xr,yr (xr,yr (xr,yr (xr,yr


) ) ) )

Translate Rotate Translate

T xr , yr  R  T  xr , yr   Rxr , yr , 


1 0 x r  cos   sin  0 1 0  x r  cos   sin  x r (1  cos  )  y r sin  
0 1 y    sin  cos  0  0 1  y    sin  cos  y (1  cos  )  x sin  
 r    r  r r 
0 0 1   0 0 1 0 0 1   0 0 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 (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
T( x f , y f )  S(s x , s y )  T(  x f , y f )  S( x f , y f , s x , s y )

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

(xr,yr (xr,yr (xr,yr (xr,yr


) ) ) )

Translate Scale Translate

T x f , y f  S s x , s y  T  x f , y f   S x f , y f , s x , s y 
1 0 xf  s x 0 0 1 0  xf  s x 0 x f (1  s x ) 
0 1 yf 0 sy 0  0 1  yf 0 sy y f (1  s y )
    
0 0 1   0 0 1 0 0 1   0 0 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 (7)

• General two-dimensional scaling directions


– Perform a rotate-scaling-rotate sequence
– Composite matrix in coordinates form
R 1( )  S(s1, s 2 )  R( )
s1 cos 2   s 2 sin2  (s 2  s1 ) cos sin 0
 
  (s 2  s1 ) cos sin s1 sin2   s 2 cos 2  0
 0 0 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
y y
(1/2,3/ (2,2)
2)
(0,1) (1,1)
(3/2,1/
2)
(0,0) (1,0) x (0,0) x

Scale
s1 cos   s2 sin  ( s2  s1 ) cos sin  0
2 2 y s2
 
R 1 ( )  S ( s1 , s2 )  R( )   ( s2  s1 ) cos sin  s1 sin 2   s2 cos 2  0
 0 0 1  xs
 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
General Rotation (1/2)

• Three successive rotations about the three axes

rotation of a cube about the z axis rotation of a cube about the y axis

?
rotation of a cube about the x axis
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 Rotation (2/2)

R  Rx R y Rz

1 0 0 0  cos  0 sin  0 cos  sin  0 0


0 cos   sin  0  0 1 0 0  sin  cos 0 0

0 sin  cos  0  sin  0 cos  0  0 0 1 0
   
0 0 0 1  0 0 0 1  0 0 0 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
Instance Transformation (1/2)

• Instance of an object’s
prototype
– occurrence of that object in
the scene
• Instance transformation

?
– applying an affine
transformation to the
prototype to obtain desired
size, orientation, and location

instance transformation

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
Instance Transformation (2/2)

M  TRS

1 0 0  x  cos   sin  0 0  x 0 0 0
0 1 0  y   sin  cos  0 0  0  y 0 0

0 0 1  z  0 0 1 0  0 0 z 0
   
0 0 0 1  0 0 0 1  0 0 0 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

You might also like