1 / 80

H331: Computer Graphics

H331: Computer Graphics. http://www.cs.kuleuven.ac.be/~graphics/H331/ Philip Dutré Department of Computer Science Wednesday, March 3. Today. Transformations of Objects Perspective Viewing Book: Chapter 5, 7. Transformations. Last week: window-to-viewport transformation

michi
Télécharger la présentation

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 Wednesday, March 3

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

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

  4. Coordinate systems: 2D & 3D Y Z Y X Y X Left-handed Z X Right-handed

  5. 3D Vectors • 3 scalars to describe vector • Add: a+b • Subtract: a-b b a b a

  6. 3D Vectors • Linear combination (s and t scalars) c = s.a + t.b • Affine: s + t = 1 • Convex: s, t >= 0

  7. 3D Vectors b c Convex combinations a

  8. 3D Vectors • Length: |a| = sqrt(ax*ax+ay*ay+az*az) • Dot-product (inner product): a.b = ax*bx + ay*by + az*bz

  9. 3D Vectors • Angle between 2 vectors • b.c = |b||c|cos(f) cos(f) = b.c / |b||c| b f a

  10. 3D Vectors • Cross-product (outer product) a x b = (ay*bz - az*by, az*bx - ax*bz, ax*by - ay*bx ) Area = |a x b| b a x b a

  11. Homogeneous coordinates • Points: (x y z 1) • Vectors: (x y z 0) • Why?Points and vectors can now be mixed in operations • Key concept in computer graphics

  12. Homogeneous coordinates • E.g. subtraction:(* * * 1) – (* * * 1) = (* * * 0) • E.g. addition(* * * 1) + (* * * 0) = (* * * 1) • Affine linear combinations of points produce another point

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

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

  15. Why are transformations useful? • Move camera around

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

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

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

  19. Affine 2D Transformations translation rotation scaling shear

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

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

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

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

  24. Inverse transformations

  25. Inverse transformations

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

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

  28. 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

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

  30. Composite transformations

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

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

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

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

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

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

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

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

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

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

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

  42. 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

  43. 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|

  44. 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?

  45. Changing coordinate systems World coordinate system Object coordinate systems

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

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

  48. 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’)

  49. 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)?

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

More Related