1 / 21

Ray Tracing Polyhedra

Ray Tracing Polyhedra. ©Anthony Steed 1999-2005. Overview. Barycentric coordinates Ray-Polygon Intersection Test Affine Transformations. Line Equation . Recall that given p 1 and p 2 in 3D space, the straight line that passes between is: for any real number t

maynard
Download Presentation

Ray Tracing Polyhedra

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. Ray Tracing Polyhedra ©Anthony Steed 1999-2005

  2. Overview • Barycentric coordinates • Ray-Polygon Intersection Test • Affine Transformations

  3. Line Equation • Recall that given p1 and p2 in 3D space, the straight line that passes between is: for any real number t • This is a simple example of a barycentric combination

  4. A Barycentric Combination is • a weighted sum of points, where weight sum to 1. • Let p1,p2,…,pn be points • Let a1,a2,…,an be weights

  5. Implications • If p1,p2,…,pn are co-planar points then p as defined will be inside the polygon defined by the points • Proof of this is out of scope, but a few diagrams should convince you of the outline of a proof …

  6. Ray Tracing a Polygon • Three steps • Does the ray intersect the plane of the polygon? • i.e. is the ray not orthogonal to the plane normal • Intersect ray with plane • Test whether intersection point lies within polygon on the plane

  7. Does the ray intersect the plane? • Ray eq. is p0 + t.d • Plane eq. is n.(x,y,z) = k • Then test is n.d !=0

  8. Where does it intersect? • Substitute line equation into plane equation • Solve for t • Find pi

  9. Is this point inside the polygon? • If it is then it can be represented in barycentric co-ordinates • There are potentially several barycentric combinations • Many tests are possible • Winding number (can be done in 3D) • Infinite ray test (done in 2D) • Half-space test (done in 2D for convex poylgons)

  10. Winding number test • Sum the angles subtended by the vertices. If sum is zero, then outside. If sum is +/-2, inside. • With non convex shapes, can get +/-4, +-6, etc… p2 1 p1 n-1 pn-1

  11. Infinite Ray Test • Draw a line from the test point to the outside • Count +1 if you cross an edge in an anti-clockwise sense • Count -1 if you cross and edge in a clockwise sense • For convex polygons you can just count the number of crossings, ignoring the sign • If total is even then point is outside, otherwise inside -1 +1

  12. Half-Space Test (Convex Polygons) • A point p is inside a polygon if it is in the negative half-space of all the line segments

  13. Note • That the winding angle and half-space tests only tell you if the point is inside the polygon, they do not get you a barycentric combination • With some minor extensions, its easy to show that the infinite ray test finds a barycentric combination.

  14. Transforming Polygons • Although its sort of “obvious” that transformations of object preserve flatness and shape, we need to convince ourselves of something specific: that barycentric coordinates are preserved under affine transformations • If they weren’t it would be extremely hard to shade and texture polygons later on in the course • If a rotation, scale, translation are affine then barycentricity is preserved • If barycentricity is preserved then polygons are still “flat” after transformation

  15. Transformations Revisited • Homogenous transform as described is affine • Preserves barycentric co-ordinates • f is affine iff

  16. To Show Transformation is Affine • Unit vectors e1=(1 0 0), e2=(0 1 0), e3=(0 0 1) and e4=(0 0 0) • p=(x1 x2 x3) • Let x4=1-x1-x2-x3 • Thus

  17. ... • But for unit vectors, mapping is easy to derive

  18. • So combine those two

  19. ... • But we know x4=1-x1-x2-x3

  20. ... • Expand that, remembering what ei is • But this is the matrix transformation

  21. Recap • Lines and polygons (and volumes) can be determined in terms of barycentric coordinates • We have shown that homogenous transformations are, by definition, affine • This polygons remain “flat” • Thus we now can use arbitrary transformations on polyhedra

More Related