2D Geometric Transformations (Chapter 5 in FVD)
2D geometric transformation Translation Scaling Rotation Shear Matri notation Compositions Homogeneous coordinates 2
2D Geometric Transformations Question: How do we represent a geometric object in the plane? Answer: For now, assume that objects consist of points and lines. A point is represented b its Cartesian coordinates: (,). Question: How do we transform a geometric object in the plane? Answer: Let (A,B) be a straight line segment and T a general 2D transformation: T transforms (A,B) into another straight line segment (A,B ), where A =TA and B =TB. 3
Translation Translate (a,b): (,) (+a,+b) Translate(2,4) 4
Scale Scale (a,b): (,) (a,b) Scale (2,3) Scale (2,3) 5
How can we scale an object without moving its origin (lower left corner)? Translate(-,-) Translate(,) Scale(2,3) 6
Reflection Scale(-,) Scale(,-) 7
Rotation Rotate(θ): (,) ( cos(θ)+ sin(θ), - sin(θ)+ cos(θ)) Rotate(9) Rotate(9) 8
How can we rotate an object without moving its origin (lower left corner)? Translate(-,-) Translate(,) Rotate(9) 9
Shear Shear (a,b): (,) (+a,+b) Shear(,) Shear(,2)
Composition of Transformations Rigid transformation: Translation + Rotation (distance preserving). Similarit transformation: Translation + Rotation + uniform Scale (angle preserving). Affine transformation: Translation + Rotation + Scale + Shear (parallelism preserving). All above transformations are groups where Rigid Similarit Affine.
Affine Similarit Rigid 2
Matri Notation Let s treat a point (,) as a 2 matri (a column vector): What happens when this vector is multiplied b a 22 matri? a c b d = a c + + b d 3
2D Transformations 2D object is represented b points and lines that join them. Transformations can be applied onl to the the points defining the lines. A point (,) is represented b a 2 column vector, and we can represent 2D transformations using 22 matrices: ' ' a = c b d 4
Scale Scale(a,b): (,) (a,b) a b a = b If a or b are negative, we get reflection. Inverse: S - (a,b)=s(/a,/b) 5
6 Reflection Reflection through the ais: Reflection through the ais: Reflection through =: Reflection through =-:
Shear, Rotation Shear(a,b): (,) (+a,+b) b a = + + a b Rotate(θ): (,) (cosθ+sinθ, -sinθ + cosθ) cosθ sinθ Inverse: sinθ cosθ + sinθ = cosθ sinθ + cosθ R - (θ)=r T (θ)=r(-θ) 7
Composition of Transformations A sequence of transformations can be collapsed into a single matri: [ ][ ][ ] [ ] A B C Note: order of transformations is important! (otherwise - commutative groups) = D translate rotate rotate translate 8
Composition of Transformations (Cont.) D = A B C D - = C - B - A - Proof: D * D- = ABC * C-B-A- = AB* I * B- * A- = A*I*A = I 9
Translation Translation(a,b): Problem: Cannot represent translation using 22 matrices. + + a b Solution: Homogeneous Coordinates 2
Homogeneous Coordinates Homogeneous Coordinates is a mapping from R n to R n+ : (, ) ( X, Y, W) = ( t, t, t) Note:(t,t,t) all correspond to the same non-homogeneous point (,). E.g. (2,3,) (6,9,3). Inverse mapping: X Y ( X, Y, W ), W W 2
22 Translation Translate(a,b): Inverse: T - (a,b)=t(-a,-b) Affine transformation now have the following form: + + = b a b a f d c e b a
Geometric Interpretation W (X,Y,) Y (X,Y,W) A 2D point is mapped to a line (ra) in 3D. The non-homogeneous points are obtained b projecting the ras onto the plane Z=. X 23
24 Eample: Rotation about an arbitrar point: Actions: Translate the coordinates so that the origin is at (, ). Rotate b θ. Translate back. (, ) θ + = = sin ) cos ( cos sin sin ) cos ( sin cos cos sin sin cos θ θ θ θ θ θ θ θ θ θ θ θ
Another eample: Reflection about an Arbitrar Line: p 2 p L=p +t (p 2 -p )=t p 2 +(-t) p Actions: Translate the coordinates so that P is at the origin. Rotate so that L aligns with the - ais. Reflect about the -ais. Rotate back. Translate back. 25
Change of Coordinates It is often requires the transformation of object description from one coordinate sstem to another. How do we transform between two Cartesian coordinate sstems? Rule: Transform one coordinate frames towards the other in the opposite direction of the representation change. Representation Transformation 26
Change of Coordinates (Cont.) Eample: X P O Y X P O Y 27
Eample: Represent the point P=( p, p,) in the (, ) coordinate sstem. where P ' =MP M = R T cosθ = sinθ sinθ cosθ ( p, p ) (, ) θ 28
29 Alternative method: Assume =(u,u ) and =(v,v ) in the (,) coordinate sstem. (, ) P =MP ' = v v u u M where (u,u ) (v,v )
3 Eample: P is at the ais P=(v,v ): What is the inverse? (u,u ) (v,v ) = = = ' v v v v u u MP P
3 Another eample: Reflection about an Arbitrar Line: Define a coordinate sstems (u,v) parallel to P P 2 : p p 2 = u u p p p p 2 2 u = = v v u u v = p p v v u u v u v u p p M