2D

Document Sample
2D
Shared by: manisha Thakkar
Categories
Tags
Stats
views:
152
posted:
2/6/2009
language:
English
pages:
36
Chapter 5



Two-Dimensional Geometric Transformations



Two-Dimensional Geometric Transformations



• Basic Transformations

• Translation • Rotation • Scaling • Composite Transformations • Other transformations • Reflection • Shear



Translation

• Translation transformation ' ' y  y  ty x  x  tx •



• Translation vector or shift vector T = (tx, ty) Rigid-body transformation • Moves objects without deformation y P’ p



y



T

x



T

x



Rotation

 Rotation transformation

x’=rcos(+)= rcoscos-rsin sin y

P’ (x’,y’)



y’=rsin(+ rcossin+rsin x=rcos )= y=rsin  cos x’=x cos-ysin

y’=xsin+ycos P’= R· P



 r



P(x,y)



cos R  sin 



 sin   cos  







x



Rotation

 Pivot point

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

P’ (x’,y’)



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

 r  (xr,yr)



P(x,y)



x



Scaling

 Scaling transformation



x '  x  sx ' y  y  sy

 



 x '   sx  '   0 y   Scaling factors, sx and sy Uniform scaling



0   x   sy   y



P  SP

'



y



sx  2 sy  1

x



y



x



Scaling

 Fixed point x '  x f  ( x  x f )  sx y'  y f  ( y  y f )  sy

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

'



Matrix Representations and Homogeneous Coordinates



• Homogeneous Coordinates

( x , y )  ( xh , y h , h )



• Matrix representations

• Translation



xh x h yh y h



 x '  1 0 t x   x   '  y   0 1 ty  y      1  0 0 1   1      



Matrix Representations

 Matrix representations





Scaling



 x '   sx  '  y    0 1 0   

 x '  cos  '   y    sin  1  0   



0 sy 0



0  x  0  y    1  1   

 sin  cos 0 0  x  0  y    1  1   







Rotation



Composite Transformations

 Translations

P'  T (tx 2 , t y 2 )  {T (tx1, t y1 )  P}  {T (t x 2 , t y 2 )  T (t x1 , t y1 )}  P

1 0 t x 2  1 0 t x1  1 0 t x1  t x 2   0 1 t   0 1 t   0 1 t  t  y2   y1  y1 y2    1   0 0 1  0 0 1  0 0      



T ( t x 2 , t y 2 )  T ( t x1 , t y 1 )  T ( t x1  t x 2 , t y 1  t y 2 )



Composite Transformations

 Scaling

 sx 2 0  0  0 sy2 0 0  sx1 0   0   1  0   0 s y1 0 0  s x 1  s x 2 0   0   1  0   0 s y1  s y 2 0 0 0  1 



S ( s x 2 , s y 2 )  S ( s x1 , s y 1 )  S ( s x1  s x 2 , s y 1  s y 2 )



Composite Transformations

 Rotations P '  R( 2 )  {R(1 )  P}  {R( 2 )  R(1 )}  P

cos 2  sin  2   0   sin  2 cos 2 0 0 cos1 0   sin 1   1  0    sin 1 0 cos( 1   2 )  sin(1   2 ) 0  cos1 0   sin(1   2 ) cos( 1   2 ) 0     0 1  0 0 1   



R( 2 )  R(1 )  R(1   2 )



General Pivot-Point Rotation

• Rotations about any selected pivot point (xr,yr) • Translate-rotate-translate



General Pivot-Point Rotation

1 0 0 1  0 0  xr  cos  sin  0 1 0  xr  yr    sin  cos 0  0 1  yr       1  0 0 1  0 0 1       cos  sin  xr (1  cos )  yr sin     sin  cos yr (1  cos )  xr sin     0 1  0   



T ( xr , yr )  R( )  T (  xr , yr )  R( xr , yr , )



General Fixed-Point Scaling

Scaling with respect to a selected fixed position (xf,yf)



General Fixed-Point Scaling

 Translate-scale-translate 1 0 xr   sx 0 0 1 0  xr   0 1 y    0 s 0   0 1  y  r  y r    1  0 0 1   0 0 1   0 0        s x 0 x f (1  s x )    0 s y y f (1  s y )   1 0 0   



T ( x f , y f )  S ( s x , s y )  T (  x f , y f )  S ( x f , y f , xr , y r )



General Scaling Directions

 Scaling factors sx and sy scale objects along the x and y directions.  We scale an object in other directions with scaling factors s1 and s2



General Scaling Directions



Concatenation Properties

 Matrix multiplication is associative. A·B ·C = (A·B )·C = A·(B ·C)  Transformation products may not be commutative  Be careful about the order in which the composite matrix is evaluated.  Except for some special cases:

   



Two successive rotations Two successive translations Two successive scalings rotation and uniform scaling



Concatenation Properties

 Reversing the order





A sequence of transformations is performed may affect the transformed position of an object.



General Composite Transformations and Computer Efficiency

 A general two-dimensional transformation  x '   rs xx rs xy  '   y    rs yx rs yy 1  0 0   







trs x   x  trs y   y    1 1  



Rotation-scaling terms rsij Translational terms trsx and trsy

Four multiplications Four additions



 Minimum number of computations









x'  x  rsxx  y  rsxy  trsx y'  x  rs yx  y  rs yy  trsy



Rigid-Body Transformation

 Rigid-body transformation matrix  rxx rxy trx  r ryy try  Multiplicative rotation terms rij  yx  Translational terms tr and tr x y 0 0 1    The upper-left 2-by-2 submatrix is an orthogonal matrix





Two vectors (rxx, rxy) and (ryx, ryy) form an orthogonal set of unit vectors.

2 2 2 2 rxx  rxy  ryx  ryy  1 rxxryx  rxy ryy  0



Rigid-Body Transformation

 The orthogonal property of rotation matrices





We know the final orientation of an object



Construct the desired transformation by assigning the elements of u’ to the first row of the rotation matrix and the elements of v’ to the second row.



Computational Efficiency

 Use approximations and iterative calculations to reduce computations













Approximate the trigonometric functions based on the first few terms of their power-series expansions. For small enough angles (< 100), cos is approximately 1.sin is approximately  Accumulated error control

 



Estimate the error in x’ and y’ at each step Reset object positions when the error accumulation becomes too great



Reflection

 A transformation produces a mirror image of an object.  Axis of reflection

  



A line in the xy plane A line perpendicular to the xy plane The mirror image is obtained by rotating the object 1800 about the reflection axis. Axis in xy plane: in a plane perpendicular to the xy plane. Axis perpendicular to xy plane: in the xy plane.



 Rotation path

 



Reflection

 Reflection about the x axis



Reflection

 Reflection about the y axis



Reflection

 Reflection relative to the coordinate origin



Reflection

 Reflection of an object relative to an axis perpendicular to the xy plane through Prfl



Reflection

 Reflection about the line y = x



Shear

 The x-direction shear relative to x axis

1 shx 0 1  0 0 

If shx = 2:



0 0  1 



x '  x  shx  y y'  y



Shear

 The x-direction shear relative to y = yref

1 shx 0 1  0 0   shx  yref   0  1  



x'  x  shx  ( y  yref )

y'  y



If shx = ½ yref = -1:

1 1/2 3/2



Shear

 The y-direction shear relative to x = xref

 1  sh  y  0   1  sh y  xref   0 1   0 0

x'  x



y'  shy ( x  xref )  y

3/2 1/2 1



If shy = ½ xref = -1:



Transformations between Coordinate Systems



y



y’

θ



y x’ y’

θ



y0



x’



x0



x



x



Transformations between Coordinate Systems

Method 1:



1 0  x0  T (  x0 , y0 )  0 1  y0    1  0 0  



 cos R(  )   sin    0 



sin  cos 0



0 0  1 



M xy, x ' y '  R(  )  T (  x0 , y0 )

Method 2:



V v  (vx , v y ) V u  ( v y , v x )  (u x , u y )



u x R  vx  0 



uy vy 0



0 0  1 



Affine Transformations

 A coordinate transformation of the form x’=axxx+axyy+bx, y’=ayxx+ayyy+by  x’ and y’ is a linear function of the original coordinates x and y.  aij and bk are constants determined by the transformation type.  Translation, rotation, scaling, reflection, and shear are two-dimensional affine transformations.  An affine transformation involving only rotation, translation, and reflection preserves angles and lengths.




Share This Document


Related docs
Other docs by manisha Thakka...
2D
Views: 152  |  Downloads: 19
by registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!