1 / 67

Transformations

Transformations. 고려대학교 컴퓨터 그래픽스 연구실. Contents. Affine transformations rotation, translation, and scaling Transformations in homogeneous coordinates Concatenation of transformations rotation about a fixed point general rotation instance transformation rotation about an arbitrary axis

taber
Download Presentation

Transformations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Transformations 고려대학교 컴퓨터 그래픽스 연구실 kucg.korea.ac.kr

  2. Contents • Affine transformations • rotation, translation, and scaling • Transformations in homogeneous coordinates • Concatenation of transformations • rotation about a fixed point • general rotation • instance transformation • rotation about an arbitrary axis • OpenGL transformation matrices • Smooth rotation with a virtual trackball kucg.korea.ac.kr

  3. u v R P T Q Transformations • Take a point (or vector) and map that point (or vector) into another point (or vector) 4D column matrices homogeneous coordinate transformation function kucg.korea.ac.kr

  4. Affine Transformations (1/2) • Linearity – linear function • Linear transformation • transform the representation of a point (or vector) into another representation of a point (or vector) point 44 matrix vector kucg.korea.ac.kr

  5. Affine Transformations (2/2) • Linear transformation (cont’) • preserve lines – transform a line into another line  only transform the endpoints of a line segment • Most transformations in CG are affine • rotation, translation, scaling, and shear homogeneous coordinate affine transformation kucg.korea.ac.kr

  6. Translation • Operation that displace points by a fixed distance in a given direction • displacement vector d (a) object in original position (b) object translated kucg.korea.ac.kr

  7. Rotation (1/2) • Simple example of 2D rotation kucg.korea.ac.kr

  8. Rotation (1/2) • Simple example of 2D rotation kucg.korea.ac.kr

  9. Rotation (1/2) • Simple example of 2D rotation kucg.korea.ac.kr

  10. Rotation (2/2) • Needs • fixed point – a point is unchanged by the rotation • rotation angle – positive rotation (counterclockwise in right hand system) • rotation axis in 3D – values on axis are unchanged by the rotation (a) rotation about a fixed point (b) 3D rotation kucg.korea.ac.kr

  11. Rigid-Body Transformations • Rotation and translation • No combination of rotations and translations can alter the shape of object alter only the object’s location and orientation affine transformations, but non-rigid body transformations kucg.korea.ac.kr

  12. Scaling (1/2) • Make an object bigger or smaller • uniform – scaling in all directions • Affine non-rigid body transformation • affine transformation: translation, rotation, scaling, shear nonuniform uniform kucg.korea.ac.kr

  13. Scaling (2/2) • Needs • fixed point • direction to scale • scale factor • longer (α>1) or smaller (0≤α<1) • Reflection – negative scale factor effect of scale factor reflection kucg.korea.ac.kr

  14. Transformations in Homogeneous Coordinates • Representations in homogeneous coordinates • Affine transformation – 44 matrix kucg.korea.ac.kr

  15. Translation • Point p to p’ by displacing by a distance d ? translation matrix kucg.korea.ac.kr

  16. Translation • Point p to p’ by displacing by a distance d kucg.korea.ac.kr

  17. Translation • Point p to p’ by displacing by a distance d • Inverse of a translation matrix ? kucg.korea.ac.kr

  18. Translation • Point p to p’ by displacing by a distance d • Inverse of a translation matrix kucg.korea.ac.kr

  19. Scaling • Scaling matrix with a fixed point of the origin ? scaling matrix kucg.korea.ac.kr

  20. Scaling • Scaling matrix with a fixed point of the origin kucg.korea.ac.kr

  21. Scaling • Scaling matrix with a fixed point of the origin • Inverse of a scaling matrix ? kucg.korea.ac.kr

  22. Scaling • Scaling matrix with a fixed point of the origin • Inverse of a scaling matrix kucg.korea.ac.kr

  23. Rotation (1/2) • Rotation with a fixed point at the origin ? rotation matrix kucg.korea.ac.kr

  24. Rotation (1/2) • Rotation with a fixed point at the origin ? kucg.korea.ac.kr

  25. Rotation (1/2) • Rotation with a fixed point at the origin ? kucg.korea.ac.kr

  26. Rotation (1/2) • Rotation with a fixed point at the origin kucg.korea.ac.kr

  27. Rotation (2/2) • Inverse of a rotation matrix ? kucg.korea.ac.kr

  28. Rotation (2/2) • Inverse of a rotation matrix : orthogonal matrix kucg.korea.ac.kr

  29. Shear (1/2) • One more affine transformation shear the object in the x direction ? kucg.korea.ac.kr

  30. Shear (1/2) • One more affine transformation shear the object in the x direction kucg.korea.ac.kr

  31. Shear (2/2) • Shear in the x direction ? shearing matrix kucg.korea.ac.kr

  32. Shear (2/2) • Shear in the x direction kucg.korea.ac.kr

  33. Shear (2/2) • Shear in the x direction • Inverse of a shearing matrix ? kucg.korea.ac.kr

  34. Shear (2/2) • Shear in the x direction • Inverse of a shearing matrix kucg.korea.ac.kr

  35. CBA p M q Concatenation of Transformations • Concatenating • affine transformations by multiplying together • sequences of the basic transformations  define an arbitrary transformation directly • ex) three successive transformations p A B C q kucg.korea.ac.kr

  36. Rotation about a Fixed Point (1/3) • Fixed point: pf • apply Rz() to rotation about a fixed point rotation of a cube about its center kucg.korea.ac.kr

  37. Rotation about a Fixed Point (2/3) sequence of transformations kucg.korea.ac.kr

  38. Rotation about a Fixed Point (3/3) kucg.korea.ac.kr

  39. 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 kucg.korea.ac.kr

  40. General Rotation (2/2) kucg.korea.ac.kr

  41. ? 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 kucg.korea.ac.kr

  42. Instance Transformation (2/2) kucg.korea.ac.kr

  43. Rotation about an Arbitrary Axis (1/6) • Needs • fixed point: p0 • rotation angle: θ • rotation axis: vector p2-p1 rotation of a cube about an arbitrary axis kucg.korea.ac.kr

  44. Rotation about an Arbitrary Axis (2/6) • First transformation is translation T(-p0) and the final one is T(p0) • Rotation problem!!! • we can get an arbitrary rotation from three rotations about individual axes • carry out two rotations to align the axis of rotation with the z axis • rotate by θ about the the z axis movement of the fixed point to the origin kucg.korea.ac.kr

  45. Rotation about an Arbitrary Axis (3/6) • Determine x and y • direction angles and cosines sequence of rotations direction angles kucg.korea.ac.kr

  46. Rotation about an Arbitrary Axis (4/6) • Determine x and y (cont’) • projection line segment into plane y=0 • look at the projection of line segment (before rotation) on the plane x=0 computation of the x rotation kucg.korea.ac.kr

  47. Rotation about an Arbitrary Axis (5/6) • Determine x and y (cont’) • projection line segment into z axis • rotation about y axis • caution!!! – clockwise angle computation of the y rotation kucg.korea.ac.kr

  48. Rotation about an Arbitrary Axis (6/6) • Finally concatenate all the matrices • Ex) rotate an object by 45 degrees about the line passing through the origin and the point (1,2,3), fixed point is the origin • solution – textbook p.195~196 kucg.korea.ac.kr

  49. OpenGL Transformation Matrices (1/2) • CTM (Current Transformation Matrix) • matrix that is applied to any vertex • part of the pipeline • : replacement • : initialization operation: • : postmultiplication vertices vertices CTM kucg.korea.ac.kr

  50. OpenGL Transformation Matrices (2/2) • Matrix modes • model-view and projection matrices • Three functions: rotation, translation, scaling vertices vertices model-view projection CTM glRotatef(angle, vx, vy, vz); glTranslatef(dx, dy, dz); glScalef(sx, sy, sz); kucg.korea.ac.kr

More Related