1 / 33

159.235 Graphics & Graphical Programming

159.235 Graphics & Graphical Programming. Lecture - Projections - Part 2. Projections Part 2 - Outline. Mathematics of Projections Perspective Transforms Stereo Orthographic 3D Clipping Homogeneous Coordinates (again). Mathematics of Viewing.

brooklyn
Download Presentation

159.235 Graphics & Graphical Programming

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. 159.235 Graphics & Graphical Programming Lecture - Projections - Part 2 Graphics

  2. Projections Part 2 - Outline • Mathematics of Projections • Perspective Transforms • Stereo • Orthographic • 3D Clipping • Homogeneous Coordinates (again) Graphics

  3. Mathematics of Viewing • Need to generate the transformation matrices for perspective and parallel projections • Should be 4x4 matrices to allow general concatenation Graphics

  4. Perspective Projection – Simplest Case Centre of projection at the origin, Projection plane at z=d. Projection Plane. y P(x,y,z) x Pp(xp,yp,d) z d Graphics

  5. x P(x,y,z) xp z d y d P(x,y,z) z x Pp(xp,yp,d) yp P(x,y,z) z d y Perspective Projection – Simplest Case Graphics

  6. Perspective Projection Graphics

  7. Perspective Projection Graphics

  8. Perspective Projection Trouble with this formulation : Centre of projection fixed at the origin. Graphics

  9. Finding Vanishing Points • Recall : An axis vanishing point is the point where the axis intercepts the projection plane  point at infinity. Graphics

  10. d x z P(x,y,z) xp yp P(x,y,z) z y d Projection plane at z = 0 Centre of projection at z = -d Alternative Formulation Graphics

  11. d x z P(x,y,z) xp yp P(x,y,z) z y d Projection plane at z = 0, Centre of projection at z = -d Now we can allow d Alternative Formulation Graphics

  12. l Left eye x r E z object l E Right eye r Max effect at 50cm display screen Stereo Projection • Stereo projection is just two perspective projections : Graphics

  13. Stereo Projection E is the interocular separation, typically 2.5cm to 3cm. d is the distance of viewer from display, typically 50cm. Let 2E = 5cm: Graphics

  14. View as an Anaglyph (Red/Green) Graphics

  15. Orthographic Projection Orthographic Projection onto a plane at z = 0. xp = x , yp = y , z = 0. Graphics

  16. Implementation of Viewing • Transform into world coordinates. • Perform projection into view volume or eye coordinates. • Clip geometry outside the view volume. • Perform projection into screen coordinates. • Remove hidden lines. Graphics

  17. left Far c lipping plane. Near clipping plane Need to calculate intersection With 6 planes. right 3D Clipping • For orthographic projection, view volume is a box. • For perspective projection, view volume is a frustrum. Graphics

  18. Speeding up Projection • Can always place camera at origin ! • OpenGL , Renderman. • Much easier to clip lines to unit cube • Define canonical view volumes. • Define normalising transformations that project view volume into canonical view volume. • Clip, transform to screen coordinates. Graphics

  19. 3D Clipping • Can use Cohen-Sutherland algorithm. • Now 6-bit outcode. • Trivial acceptance where both endpoint outcodes are all zero. • Perform logical AND, reject if non-zero. • Find intersect with a bounding plane and add the two new lines to the line queue. • Line-primitive algorithm. Graphics

  20. 3D Polygon Clipping • Sutherland-Hodgman extends easily to 3D. • Call ‘CLIP’ procedure 6 times rather than 4 • Polygon-primitive algorithm. Graphics

  21. Four cases of polygon clipping : Inside Outside Inside Outside Inside Outside Inside Outside First Output Output Vertex Output Intersection Second Output Case 3 No output. Case 1 Case 2. Case 4 Sutherland-Hodgman Algorithm Graphics

  22. Clipping and Homogeneous Coordinates • Efficient to transform frustrum into perspective canonical view volume – unit slope planes. • Even better to transform to parallel canonical view volume • Clipping must be done in homogeneous coordinates. • Points can appear with –ve W and cannot be clipped properly in 3D. Graphics

  23. Transforming between canonical view-volumes • The perspective canonical view-volume can be transformed to the parallel canonical view-volume with the following matrix: • Derivation left as an exercise :-) Graphics

  24. Clipping in 3D. • 3D parallel projection volume is defined by: -1x 1, -1 y 1 , -1 z 0 • Replace by X/W,Y/W,Z/W: -1X/W 1, -1 Y/W 1 , -1 Z/W 0 • Corresponding plane equations are : X= -W, X=W, Y=-W, Y=W, Z=-W, Z=0 Graphics

  25. Clipping in W • If W>0 , multiplication by W doesn’t change sign. W>0: -W X W, -W Y W, -W Z 0 • However if W<0, need to change sign : W<0: -WX W,-W Y W, -W Z 0 Graphics

  26. W P1=[1 2 3 4]T W=1 Projection of P1 and P2 onto W=1 plane X or Y P2=[-1 –2 –3 –4]T Points in Homogeneous Coordinates Graphics

  27. W P1=[1 2 3 4]T W=1 Region A Projection of P1 and P2 onto W=1 plane X or Y Region B Need to consider both regions when Performing clipping. P2=[-1 –2 –3 –4]T Points in Homogeneous Coordinates Graphics

  28. Clipping in Homogeneous Coordinates • Could clip twice – once for region B, once for region A. • Expensive. • Check for negative W values and negate points before clipping. • What about lines with endpoints in each region ? Graphics

  29. W P1 Projection of points. W=1 X P2 Lines in Homogeneous Coordinates Graphics

  30. Lines in Homogeneous Coordinates W P1 Clipped lines W=X W=1 X Solution : Clip line segments, negate both endpoints, clip again. W=-X P2 Graphics

  31. Final Step • Divide by W to get back to 3-D • Divide by z. • Where the perspective projection actually gets done – perspective foreshortening. • Now we have a ‘view volume’. • Don’t flatten z due to hidden line calculations. Graphics

  32. Projections in Java • Use Java 3D package • Or can DIY! Graphics

  33. Projections - Summary • Orthographic matrix - replace (z) axis with point. • Perspective matrix – multiply w by z. • Clip in homogeneous coordinates. • Preserve z for hidden surface calculations. • Can find number of vanishing points • Acknowledgments - thanks to Eric McKenzie, Edinburgh, from whose Graphics Course some of these slides were adapted. Graphics

More Related