1 / 46

Chapter 10: Coordinate Systems

Chapter 10: Coordinate Systems. This Chapter: we will learn. the w2n transform World and Normalized Device Coordinate Systems World Coordinate Window Coordinate Transformation. Transformation of Tut 3.1 (10.1). In all tutorials, we … Initialize M W M V M P to identity

mikel
Download Presentation

Chapter 10: Coordinate Systems

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. Chapter 10: Coordinate Systems Chapter 10

  2. This Chapter: we will learn • the w2n transform • World and Normalized Device Coordinate Systems • World Coordinate Window • Coordinate Transformation Chapter 10

  3. Transformation of Tut 3.1 (10.1) • In all tutorials, we … • Initialize MW MV MP to identity • Compute world2ndc and load into MV Chapter 10

  4. The world2ndc transform Chapter 10

  5. All vertices are transformed! • D3D transforms all vertices (Vi) by • If • Then Chapter 10

  6. Tutorial 3.1: re-visit Transformed to … Chapter 10

  7. Tut 10.2: Drawing without w2n Observation: -1 ≤ x/y ≤ +1 Chapter 10

  8. Tut 10.3: Verify ±1 Range • Window Dimension • 200 pixels x 200 pixels • Draw a unit circle • Center at (0,0) • Radius = 1.0 • Observe indeed: • NDC – Normalized Device Coordinate Chapter 10

  9. Tut 10.4/10.5: Experiment with NDC • Tutorial 10.4: • Same Unit circle • 100x200 pixel area • Tutorial 10.5: • Same Unit circle • 200x100 pixel area Chapter 10

  10. Observations: • Remember: • In this case: • MV MW MP: are initialized to Identity • All vertices are in NDC (±1) • Output always forced into entire device drawing area! Chapter 10

  11. Conclusion: NDC to Device!! • NDC to Device Space automatically • Where: Chapter 10

  12. NDC to Device Transform Chapter 10

  13. Device Coordinate (DC) System • Defined on the device • Lower left as origin • For “Windows” • Units are in pixels • Compare to Hardware Coordinate • Origin at upper left Chapter 10

  14. Normalized Device Coordinate (NDC) System • X/Y ranges between -1 to +1 • 2x2 square area • All Graphics API • Expects NDC! • Automatically transforms from NDC to drawing area • Mn2d is automatic!! • True for ALL Graphics APIs!! Chapter 10

  15. Advantage of NDC • Consistency and Flexibility • Programmer does not need to aware of display dimension • Program will run on any display size • Convenience: • ±1 convenient for scaling • Problem with NDC: • ±1 are not intuitive to humans/programmers! Chapter 10

  16. Drawing a face … Chapter 10

  17. Transformation involve (Tut 9.9) Chapter 10

  18. We have to compute and apply in our program World CoordinateSystem (WC) Graphics API computes and applies automatically World Coordinate System (WC) • Convenient system for design! Chapter 10

  19. Graphics API computes and applies automatically Tut 10.6: DC independence! • Mn2d • Scale to Device Coordinate (DC) automatically by Graphics API • Can draw to any DC space! • Tut 10.6: draws 300x300 face to • 500x500 pixels DC space! • Looks Identical to Tut 9.9! • Tut 9.9: 300x300 pixels DC Chapter 10

  20. Tut 10.7: Same face in different WC Chapter 10

  21. Tut 10.7: WC Window • WC Window • The X/Y bounds that enclose the face Chapter 10

  22. Tut 10.7: Required Mw2n Chapter 10

  23. Tut 10.7: Implementation • Appears identical to Tut: 10.6 and 9.9 • Completely different Mw2n Chapter 10

  24. Tut 10.8: Location of WC Window Chapter 10

  25. Tut 10.8: Implementation • Define the entire geometric human • Draws with defined WC Window Chapter 10

  26. The WC Window and Mw2n • All vertices (Vi) goes through: • In our implementation: • Mw2n is stored in MV Chapter 10

  27. Vertex in Different Coordinate Spaces • Vwc – vetex in WC Space • Vndc – vetex in NDC Space • Vdc – vetex in DC Space Chapter 10

  28. Same Vertex in WC, NDC, DC … Chapter 10

  29. WC to DC transform (Mw2d) Given: Let Or Then Chapter 10

  30. More about Recall: Or Chapter 10

  31. 3 Important Pieces • Center (cxwc, cywc) – pan: what/where is visible • Dimension (Wwc, Hwc) – Zoom: size of visible objects • Ratio : WC to DC height/width ratio WC to DC Chapter 10

  32. Lib 10: WC Window Support Chapter 10

  33. Lib10: DC  WC Xform To cover later Chapter 10

  34. Lib10: LoadW2NDCXform() (to MV) Chapter 10

  35. Tut 10.9: Work with WC Window • Set WC Window • Must be done during initialization • Before each draw of model • Call LoadW2NDCXform() to define Mw2n Chapter 10

  36. Tut 10.10: Moving WC Window Chapter 10

  37. Tut 10.10: WindowHandler details Chapter 10

  38. Tut 10.10: Implementation Detail Chapter 10

  39. Tut 10.10: Handler::DrawGraphics() • Our App has two instances of WindowHandler • m_main_view instance of CMainHandler • m_small_view instance CDrawOnlyHandler • Both instances will invoke this DrawGraphics() • Each instance has an unique WC Window • Each invocation loads a different Mw2n Chapter 10

  40. Tut 10.11: Scaling WC Window Chapter 10

  41. Tut 10.11: Zooming … • Mw2n is computed and loaded into MV • Intuition … • Larger (WWC, HWC) corresponds to • Smaller scaling factors (in numerators) • Large (WWC, HWC) is zooming out • You see more in the given device space Chapter 10

  42. Width to Height ratios: • From WC to DC: • Translate: by World Center • Scale: from WC window to DC displace size • Translate: to position the drawing area • When: • Objects will be scaled differently in X and Y • Circles will not be round!! Chapter 10

  43. Aspect Ratio … • Define: • To maintain circle square … • Aspect ratio of WC Window must be the same as aspect ratio of DC display area Chapter 10

  44. Inverse Trasnform • Given vertex in WC: Vwc • We know .. • Now, mouse clicks are in DC space! • Given Vdc • How can we compute • what is Chapter 10

  45. Computing … Recall: Let: Then: Or: Finally: Chapter 10

  46. DC to WC: Chapter 10

More Related