Lecture16-RayTracingIntersections

Determine the dominant coordinate as the largest

This preview shows page 37 - 49 out of 53 pages.

Determine the dominant coordinate as the largest magnitude component of Pn 2. For each vertex (xn, yn, zn), n = 0, 1, …, N-1 of the polygon, project the vertex onto the dominant coordinate axis, giving (un, vn) vertices. 3. Project the intersection point (xint, yint, zint) onto the same coordinate plane as the vertices. 4. Translate all polygon vertices by (-uint, -vint), giving (un’, vn’) vertices. 5. Set numCrossings = 0
Image of page 37

Subscribe to view the full document.

The Actual Algorithm - part 2 6. If v0’ < 0 , set signHolder = -1 , otherwise set signHolder = 1 7. For i = 0 to N-1 (note - when i = N-1, i+1 should be 0) a. if vi+1’ < 0 set nextSignHolder = -1 else set nextSignHolder = 1 b. if ( signHolder <> nextSignHolder ) i. if ( ui’ > 0 and ui+1’ > 0 ) this edge crosses +u’ so increment numCrossings ii. else if ( ui’ > 0 or ui+1’>0 ) the edge might cross +u’, so compute the intersection with the u’ axis ucross= ui’ -vi’ * (ui+1’ -ui’)/(vi+1’ -vi’) v. if ucross > 0 the edge crosses +u so increment numCrossings c. set signHolder = nextSignHolder 8. If numCrossings is odd, the point is inside the polygon
Image of page 38
Example Given a polygon: G0 = (-3, -3, 7) G1 = (3, -4, 3) G2 = (4, -5, 4) and intersection point Ri = (-2, -2, 4) Does the intersection point lie within the polygon? G0 G1 G2
Image of page 39

Subscribe to view the full document.

Step 1: Get the plane normal, determine dominant coordinate Pn can be computed from the cross product of two vectors in the plane The vertices of the polygon can be used to compute vectors in the plane Example G0 G1 G2 G0 = (-3, -3, 7) G1 = (3, -4, 3) G2 = (4, -5, 4) Ri = (-2, -2, 4)
Image of page 40
Compute the Normal: § First, compute edge vectors from the vertices Example v1 = G0 - G1 = (-3, -3, 7) - (3, -4, 3) = (-6, 1, 4) v2 = G2 - G1 = (4, -5, 4) - (3, -4, 3) = (1, -1, 1) G0 G1 G2 G0 = (-3, -3, 7) G1 = (3, -4, 3) G2 = (4, -5, 4) Ri = (-2, -2, 4)
Image of page 41

Subscribe to view the full document.

The plane normal is then v2 x v1 Example Pn = (-6, 1, 4) x (1, -1, 1) = (5, 10, 5) So the dominant coordinate is y G0 G1 G2 G0 = (-3, -3, 7) G1 = (3, -4, 3) G2 = (4, -5, 4) Ri = (-2, -2, 4)
Image of page 42
Step 2: Project the vertices Step 3: Project the intersection point Example G0 G1 G2 G0 = proj of (-3, -3, 7) ⇒(-3, 729 G1 = proj of (3, -4, 3) ⇒(3, 329 G2 = proj of (4, -5, 4) ⇒(4, 429 Ri Ri = proj of (-2, -2, 4) ⇒(-2, 429
Image of page 43

Subscribe to view the full document.

Step 4: Translate the vertices Example G0’ G1’ G2’ G0’ = (-3, 7) - (-2, 4) ⇒(-1, 329 G1’ = (3, 3) - (-2, 4) ⇒(5, -129 G2’ = (4, 4) - (-2, 4) ⇒(6, 029 Ri’ = (-2, 4) - (-2, 4) ⇒(0, 029 Ri’
Image of page 44
Step 5: Set numCrossings = 0 Step 6: v0’= 3 , so signHolder = 1 Example G0’ = (-1, 3) G1’ = (5, -1) G2’ = (6, 0) Ri’
Image of page 45

Subscribe to view the full document.

Step 7: i signHolder nextSignHolder numCrossings intersection point Example G0’ = (-1, 3) G1’ = (5, -1) G2’ = (6, 0) Ri’ 1 2 0 +1 +1 -1 +1 -1 +1 v u 0 2 1 -1-3*(5-(-1))/(-1-3) = 3.5 Since numCrossings is even, the point is outside the polygon r i = 0 to N-1 (note - when i = N-1, i+1 should be 0) if vi+1’ < 0 set nextSignHolder = -1 else set nextSignHolder = 1 if (signHolder <> nextSignHolder) if (ui’ > 0 and ui+1’ > 0) this edge crosses +u’ so increment numCrossings else if (ui’ > 0 or ui+1’>0) the edge might cross +u’, so compute the intersection with the u’ axis ucross= ui’ -vi’ * (ui+1’ -ui’)/(vi+1’ -vi’) if ucross > 0 the edge crosses +u so increment numCrossings set signHolder = nextSignHolder
Image of page 46
Shadows Send a shadow ray from intersection point to the light: § Compute the following shadow ray properties: - Shadow ray direction: s d = ( l p ) / || l p || - Distance to the light from the intersection point: tl = || l p || § Test if shadow ray intersects an object before reaching the light: - In theory, the possible range of t -values is t  [0, tl ] - Due to numerical (floating-point) error, test in the range t  [ ε , t 1] where ε is some small value (such as 2–16)
Image of page 47

Subscribe to view the full document.

Recursive Ray Tracing
Image of page 48
Image of page 49
You've reached the end of this preview.
  • Spring '08
  • Jones,M
  • Angle of Incidence, Euclidean geometry, Total internal reflection

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern