1 / 70

H331: Computer Graphics

H331: Computer Graphics. http://www.cs.kuleuven.ac.be/~graphics/H331/ Philip Dutré Department of Computer Science Friday, October 12. Announcement. Practicum 1 available!!!. Today. Transformations of Objects Perspective Viewing Book: Chapter 5, 7. Transformations.

len
Download Presentation

H331: Computer Graphics

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. H331: Computer Graphics http://www.cs.kuleuven.ac.be/~graphics/H331/Philip Dutré Department of Computer Science Friday, October 12

  2. Announcement • Practicum 1 available!!!

  3. Today • Transformations of Objects • Perspective Viewing • Book: Chapter 5, 7

  4. Transformations • Last week: window-to-viewport transformation • But … we also want to transform objects in 2D and 3D.

  5. Why are transformations useful? • Define objects only once, then transform to compose bigger objects • Translations, rotations, scaling, …

  6. Why are transformations useful? • Define motif, then construct object from motif Use 8 times

  7. Why are transformations useful? • Move camera around

  8. Why are transformations useful? • Computer animation • Translate / rotate / warp object over time

  9. 2D transformations • Each point can be expressed in a coordinate system: P = Pxi + Pyj + origin P (Px, Py,1) j Homogeneous coordinates origin i

  10. 2D Transformations • Q = T(P) • Affine transformation: coordinates of Q are linear combination of coordinates of P

  11. Affine 2D Transformations translation rotation scaling shear

  12. 2D Translation Y Y (Qx, Qy,1) Tx Ty (Px, Py,1) X X

  13. 2D Scaling Y Y (Qx, Qy,1) (Px, Py,1) X X

  14. 2D Rotation Y (Qx, Qy,1) (Px, Py,1) R  R + f X

  15. 2D Shear Y Y (Qx, Qy,1) (Px, Py,1) X X

  16. Inverse transformations

  17. Inverse transformations

  18. Composing transformations • Rotate over 30 degrees • Translate Matrix multiply

  19. Composite transformations • Order is important!!! Y Y Y rotate translate X X X Y Y Y rotate translate X X X

  20. Composite transformations • E.g. Rotating about point • Standard rotation is about origin • Translate rotation centre to origin • Rotate around origin • Translate origin back to rotation centre

  21. Composite transformations Y R X Y X Y Y X X R Tx -Ty Ty -Tx X

  22. Composite transformations

  23. Window to viewport: revisited • Window to viewport transformation can also be expressed as 2D transform!!! Object Coordinate System Screen Coordinate System viewport window

  24. Properties of 2D transforms • Affine transformations preserve affine linear combinations

  25. Properties of 2D transforms • Affine transformations preserve lines and planes • Line:

  26. Properties of 2D transforms • Parallellism of lines and planes is preserved • Parallel lines:

  27. Transform of coordinate system • origin = (0 0 1); i = (1 0 0); j = (0 1 0)

  28. Transform of coordinate system m2 m1 m3 j origin i

  29. Other properties • Relative ratios are preserved • Areas:

  30. 3D affine transformations • Same idea, but 4x4 matrices

  31. 3D Translation Z Z Y Y TZ TY X X TX

  32. 3D Scaling Z Z Y Y SY SZ X X SX

  33. 3D Rotation around X-axis Z Z qx Y Y X X

  34. 3D Rotation around Y-axis Z Z qy Y Y X X

  35. 3D Rotation around Z-axis Z Z Y Y qz X X

  36. Composite 3D transformations • Same ideas as 2D • E.g. rotation around arbitrary axis u • 2 rotations such that u is aligned with x-axis • X-rotation over desired angle • Undo the two rotations to restore u to original direction

  37. Properties of 3D transformations • Preservation of affine linear combinations • Preservation of lines and planes • Parallelism of lines and planes is preserved • Columns reveal transformed coordinate frame • Ratios are preserved • Volumes are scaled by |detM|

  38. Changing coordinate systems • Different way of thinking about coordinate transforms • More natural: • Objects are modeled in their own coordinate system • What are the coordinates of the the transformed object in the world coordinate system?

  39. Changing coordinate systems World coordinate system Object coordinate systems

  40. Changing coordinate systems j’ i’ o’=M.origin i’ = M.i j’ = M.j o’ j origin i M transforms (origin, i, j) to (o’, i’, j’)

  41. Changing coordinate systems j’ P b d i’ P = (c,d,1) in (o’, i’, j’) c o’ j origin a i What are the coordinates (a,b,1) of P in (origin, i, j)?

  42. Changing coordinate systems j’ P b d i’ c o’ j origin a i

  43. Changing coordinate systems • M1 to change coordinate system 1 to 2 • M2 to change coordinate system 2 to 3 • What are the coordinates of P in 1? • Different order of matrices as transforms for points!

  44. Changing coordinate systems Local object coordinate system P Express P in world coordinates: R.T.P First R, then T

  45. Viewing in 3D • Camera has its own coordinate system

  46. What do we know so far? • Objects are described in their own coordinate system • To place objects in the world, we need to apply transformation matrices • Transformations: • Translation; scaling; rotations

  47. Viewing in 3D • Perspective! • Precise control over camera position and orientation

  48. Perspective

  49. Perspective

  50. Camera setup Z Camera Near plane X Y Far plane View direction

More Related