• date post

20-Dec-2015
• Category

## Documents

• view

242

6

Embed Size (px)

### Transcript of 1 Modeling Transformations ï‚¬ 2D Transformations ï‚¬ 3D...

• Slide 1
• 1 Modeling Transformations 2D Transformations 3D Transformations OpenGL Transformation
• Slide 2
• 2 2D-Transformations Basic Transformations Homogeneous coordinate system Composition of transformations
• Slide 3
• 3 Translation 2D x = x + d x y = y + d y
• Slide 4
• 4 Scaling 2D Types of Scaling: Differential ( s x != s y ) Uniform ( s x = s y )
• Slide 5
• Rotation 2D rotated original
• Slide 6
• 6 Rotation 2D
• Slide 7
• 7 Mirror Reflection
• Slide 8
• 8 Shearing Transformation
• Slide 9
• 9 Inverse 2D - Transformations
• Slide 10
• 10 Homogeneous Co-ordinates Translation, scaling and rotation are expressed (non-homogeneously) as: translation: P = P + T Scale: P = S P Rotate: P = R P Composition is difficult to express, since translation not expressed as a matrix multiplication Homogeneous coordinates allow all three to be expressed homogeneously, using multiplication by 3 matrices W is 1 for affine transformations in graphics
• Slide 11
• 11 Homogeneous Co-ordinates P 2d is a projection of P h onto the w = 1 plane So an infinite number of points correspond to : they constitute the whole line (tx, ty, tw) x y w P h (x,y,w) P 2d (x,y,1) w=1
• Slide 12
• 12 Classification of Transformations 1.Rigid-body Transformation Preserves parallelism of lines Preserves angle and length e.g. any sequence of R( ) and T(dx,dy) 2.Affine Transformation Preserves parallelism of lines Doesnt preserve angle and length e.g. any sequence of R( ), S(sx,sy) and T(dx,dy)
• Slide 13
• 13 Properties of rigid-body transformation The following Matrix is Orthogonal if the upper left 2X2 matrix has the following properties 1.A) Each row are unit vector. sqrt(r 11 * r 11 + r 12 * r 12 ) = 1 B) Each column are unit vector. sqrt(c 11 * c 11 + c 12 * c 12 ) = 1 2.A) Rows will be perpendicular to each other (r 11, r 12 ). ( r 21, r 22 ) = 0 B) Columns will be perpendicular to each other (c 11, c 12 ). (c 21,c 22 ) = 0 e.g. Rotation matrix is orthogonal Orthogonal Transformation Rigid-Body Transformation For any orthogonal matrix B B -1 = B T
• Slide 14
• 14 Commutativity of Transformation Matrices In general matrix multiplication is not commutative For the following special cases commutativity holds i.e. M 1.M 2 = M 2.M 1 M1M1 M2M2 Translate Scale Rotate Uniform ScaleRotate Some non-commutative Compositions: Non-uniform scale, Rotate Translate, Scale Rotate, Translate Original Transitional Final
• Slide 15
• 15 Associativity of Matirx Multiplication Create new affine transformations by multiplying sequences of the above basic transformations. q = CBA p q = ( ( CB ) A ) p = ( C ( B A ))p = C ( B ( A p) ) etc. matrix multiplication is associative. But to transform many points, best to do M = CBA then do q = M p for any point p to be rendered. To transform just a point, better to do q = C ( B ( A p)) For geometric pipeline transformation, define M and set it up with the model-view matrix and apply it to any vertex subsequently defined to its setting.
• Slide 16
• 16 Rotation of about P(h,k): R ,P R ,P = Q(x,y) P(h,k) Step 1: Translate P(h,k) to origin T(-h,-k) Q 1 (x ,y ) P 1 (0,0) Step 2: Rotate w.r.t to origin R*R* Q 2 (x ,y ) P 2 (0,0) Step 3: Translate (0,0) to P(h,k0) T(h,k) * P 3 (h,k) Q 3 (x +h, y +k)
• Slide 17
• 17 Scaling w.r.t. P(h,k): S sx,sy,p T(-h,-k)S(s x,s y )*T(h,k) * S sx,sy,P = (4,3) (1,1)(4,1) S 3/2,1/2,(1,1) Step 1: Translate P(h,k) to origin (4,2) (0,0)(4,0) T(-1,-1) Step 2: Scale S(s x,s y ) w.r.t origin (6,1) (6,0)(0,0) S(3/2,1/2) (7,1) Step 3: Translate (0,0) to P(h,k) (7,2) (1,1) T(1,1)
• Slide 18
• 18 Reflection about line L, M L Step 1: Translate (0,b) to origin T(0,-b)M L = Step 2: Rotate - degrees Step 3: Mirror reflect about X-axis R(- ) * T(0,b) * Step 4: Rotate degrees Step 5: Translate origin to (0,b) M x * R( ) *
• Slide 19
• 19 Problems to be solved: Schaums outline series: Problems: 4.1 4.2 4.3, 4.4, 4.5 => R ,P 4.6, 4.7, 4.8 => S sx,sy,,P 4.9, 4.10, 4.11, 4.21 => M L 4.12 => Shearing Pg-281(1.24), Pg-320(5.19) => Circular view-port
• Slide 20
• 20 3D Transformations Basics of 3D geometry Basic 3D Transformations Composite Transformations
• Slide 21
• 21 Orientation Thumb points to +ve Z-axis Fingers show +ve rotation from X to Y axis
• Slide 22
• 22 Vectors in 3D Have length and direction V = [x v, y v, z v ] Length is given by the Euclidean Norm ||V|| = ( x v 2 + y v 2 + z v 2 ) Dot Product V U = [x v, y v, z v ][x u, y u, z u ] = x v *x u + y v *y u + z v *z u = ||V|| || U|| cos Cross Product V U = [y v *z u - z v y u, -x v *z u + z v *x u, x v *y u y v *x u ] = ||V|| || U|| sin V U = - ( U x V) (xv,yv,zv) V=aI+bJ+cK x y z
• Slide 23
• 23 3D Equation of Curve & Line Parametric equations of Curve & Line Curve Line P 0 (x 0,y 0,z 0 ) P 1 (x 1,y 1,z 1 ) t > 1 V t < 0 t =1 t = 0 0 < t < 1 x y z C
• Slide 24
• 24 3D Equation of Surface & Plane Parametric equations of Surface & Plane Surface Plane : with Normal, N P0P0 N
• Slide 25
• 25 3D Plane Ways of defining a plane 1. 3 points P 0, P 1, P 2 on the plane 2. Plane Normal N & P 0 on plane 3. Plane Normal N & a vector V on the plane Plane Passing through P 0, P 1, P 2 P0P0 P1P1 P2P2 N V
• Slide 26
• 26 Affine Transformation Transformation is a function that takes a point (or vector) and maps that point (or vector) into another point (or vector). A coordinate transformation of the form: x = a xx x + a xy y + a xz z + b x, y = a yx x + a yy y + a yz z + b y, z = a zx x + a zy y + a zz z + b z, is called a 3D affine transformation. The 4 th row for affine transformation is always [0 0 0 1]. Properties of affine transformation: translation, scaling, shearing, rotation (or any combination of them) are examples affine transformations. Lines and planes are preserved. parallelism of lines and planes are also preserved, but not angles and length.
• Slide 27
• 27 Translation 3D
• Slide 28
• 28 Scaling 3D Original scale all axes scale Y axis
• Slide 29
• 29 Rotation 3D For 3D-Rotation 2 parameters are needed Angle of rotation Axis of rotation Rotation about z-axis:
• Slide 30
• Slide 31
• 31 Shear along Z-axis y x z
• Slide 32
• 32 Object Transformation Line: Can be transformed by transforming the end points Plane:(described by 3-points) Can be transformed by transforming the 3-points Plane:(described by a point and Normal) Point is transformed as usual. Special treatment is needed for transforming Normal
• Slide 33
• 33 Composite Transformations 3D Some of the composite transformations to be studied are: A V,N = aligning a vector V with a vector N R ,L = rotation about an axis L( V, P ) S sx,sy,P = scaling w.r.t. point P
• Slide 34
• 34 A V : aligning vector V with k A v =R ,i
• Slide 35
• 35 A V : aligning vector V with k A v =R ,i R - ,j *
• Slide 36
• 36 A V : aligning vector V with k A V -1 = A V T A V,N = A N -1 * A V
• Slide 37
• 37 R ,L : rotation about an axis L Let the axis L be represented by vector V and passing through point P 1. Translate P to the origin 2. Align V with vector k 3. Rotate about k 4. Reverse step 2 5. Reverse step 1 R ,L =T -P A V *R ,k * A V -1 *T -P -1 *
• Slide 38
• 38 M N,P : Mirror reflection Let the plane be represented by plane normal N and a point P in that plane x y z N P
• Slide 39
• 39 M N,P : Mirror reflection Let the plane be represented by plane normal N and a point P in that plane 1. Translate P to the origin M N,P =T -P x y z N P
• Slide 40
• 40 M N,P : Mirror reflection Let the plane be represented by plane normal N and a point P in that plane 1. Translate P to the origin 2. Align N with vector k M N,P =T -P A N * N P x y z
• Slide 41
• 41 M N,P : Mirror reflection Let the plane be represented by plane normal N and a point P in that plane 1. Translate P to the origin 2. Align N with vector k 3. Reflect w.r.t xy-plane M N,P =T -P A N *S 1,1,-1 * N P x y z
• Slide 42
• 42 x y z M N,P : Mirror reflection Let the plane be represented by plane normal N and a point P in that plane 1. Translate P to the origin 2. Align N with vector k 3. Reflect w.r.t xy-plane 4. Reverse step 2 M N,P =T -P A N *S 1,1,-1 *A N -1 *
• Slide 43
• 43 M N,P : Mirror reflection Let the plane be represented by plane normal N and a point P in that plane 1. Translate P to the origin 2. Align N with vector k 3. Reflect w.r.t xy-plane 4. Reverse step 2 5. Reverse step 1 M N,P =T -P A N *S 1,1,-1 *A N -1 *T -P -1 * x y z N P
• Slide 44
• 44 Further Composition The Composite Transform must have Translation of P 1 to Or