Ray Polygon Intersection.

Similar documents
Camera Placement for Ray Tracing

Geometric Queries for Ray Tracing

Overview: Ray Tracing & The Perspective Projection Pipeline

Today. Parity. General Polygons? Non-Zero Winding Rule. Winding Numbers. CS559 Lecture 11 Polygons, Transformations

Lecture 19: All Together with Refraction

Computer Vision Project-1

Chapter 8 Three-Dimensional Viewing Operations

Questions??? Announcements Assignment 3 due today

CS770/870 Spring 2017 Ray Tracing Implementation

3D Modeling & Sketchup

1999, Denis Zorin. Ray tracing

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

CS 325 Computer Graphics

CS251 Spring 2014 Lecture 7

1.5 Equations of Lines and Planes in 3-D

MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review.

COMP30019 Graphics and Interaction Perspective & Polygonal Geometry

CSE452 Computer Graphics

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

High-Dimensional Computational Geometry. Jingbo Shang University of Illinois at Urbana-Champaign Mar 5, 2018

Math 21a Tangent Lines and Planes Fall, What do we know about the gradient f? Tangent Lines to Curves in the Plane.

Section 13.5: Equations of Lines and Planes. 1 Objectives. 2 Assignments. 3 Lecture Notes

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

Lecture 11: Ray tracing (cont.)

Introduction to Computer Vision

CS6670: Computer Vision

3D Rendering and Ray Casting

Reflection and Refraction

N-Views (1) Homographies and Projection

Homework #1. Displays, Alpha Compositing, Image Processing, Affine Transformations, Hierarchical Modeling

Geometric Transformations

Reflection and Refraction

CSE328 Fundamentals of Computer Graphics

The Graphics Pipeline. Interactive Computer Graphics. The Graphics Pipeline. The Graphics Pipeline. The Graphics Pipeline: Clipping

COSC579: Scene Geometry. Jeremy Bolton, PhD Assistant Teaching Professor

Ray casting. Ray casting/ray tracing

True/False. MATH 1C: SAMPLE EXAM 1 c Jeffrey A. Anderson ANSWER KEY

Worksheet 3.1: Introduction to Double Integrals

CMSC427: Computer Graphics Lecture Notes Last update: November 21, 2014

Three-Dimensional Viewing Hearn & Baker Chapter 7

Intersecting Simple Surfaces. Dr. Scott Schaefer

Camera Model and Calibration

3D Rendering and Ray Casting

Introduction Ray tracing basics Advanced topics (shading) Advanced topics (geometry) Graphics 2010/2011, 4th quarter. Lecture 11: Ray tracing

GEOMETRIC TRANSFORMATIONS AND VIEWING

(Refer Slide Time: 00:04:20)

Hidden-Surface Removal.

Agenda. Rotations. Camera models. Camera calibration. Homographies

Computer Vision cmput 428/615

CS452/552; EE465/505. Geometry Transformations

Math (Spring 2009): Lecture 5 Planes. Parametric equations of curves and lines

DH2323 DGI13. Lab 2 Raytracing

COMP30019 Graphics and Interaction Perspective Geometry

Discriminant Functions for the Normal Density

Image Warping and Mosacing

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Generalized Hough Transforms

Geometric camera models and calibration

2D/3D Geometric Transformations and Scene Graphs

12.6 Cylinders and Quadric Surfaces

ECE 600, Dr. Farag, Summer 09

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Specifying Complex Scenes

DD2429 Computational Photography :00-19:00

1 EquationsofLinesandPlanesin 3-D

Homework #2. Hidden Surfaces, Projections, Shading and Texture, Ray Tracing, and Parametric Curves

Last week. Machiraju/Zhang/Möller

1.5 Equations of Lines and Planes in 3-D

Announcements. Mosaics. How to do it? Image Mosaics

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects

Scene Modeling for a Single View

Image warping and stitching

Three-Dimensional Coordinate Systems

Chapter 5. Projections and Rendering

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52

Homework #1. Displays, Image Processing, Affine Transformations, Hierarchical Modeling

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52

(Refer Slide Time: 00:01:26)

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Institutionen för systemteknik

Revision Problems for Examination 2 in Algebra 1

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Single View Geometry. Camera model & Orientation + Position estimation. What am I?

Review for Mastery Using Graphs and Tables to Solve Linear Systems

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CS4670: Computer Vision

Computer Graphics 7: Viewing in 3-D

Motion Planning. O Rourke, Chapter 8

Lecture 4. Viewing, Projection and Viewport Transformations

Illumination Models III: Ray Tracing (View Dependent Global Illumination)

Computer Graphics Ray Casting. Matthias Teschner

Computer Vision Projective Geometry and Calibration. Pinhole cameras

Midterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer

Image warping and stitching

8.1 Geometric Queries for Ray Tracing

Ray Tracing I. History

METRIC PLANE RECTIFICATION USING SYMMETRIC VANISHING POINTS

Background for Surface Integration

18.02 Final Exam. y = 0

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination (Total: 100 marks)

Transcription:

Ray Polygon Intersection. Lecture #17 Thursday, October 28th, 2014 Review - Ray Casting! Goal: throw rays through pixels, intersect them with surfaces! Compute surface reflectance at points of intersection PRP (fp) 10/28/14 Bruce Draper & J. Ross Beveridge 2014 2

Review - Cameras & Ray Casting Given PRP, then where is pixel P x,y?! Remember the camera s rotation matrix:! N is the vector in the direction of the VPN! U is the camera s x axis in world coordinates! V is the camera s y axis in world coordinates! N, U, V are all unit length! Focal length d from PRP to image plane P α,β = PRP dvpn +αu + βv 10/28/14 Bruce Draper & J. Ross Beveridge 2014 3 Review - Cameras (II)! A ray is a parametric line for t > 0.! Move away from PRP, here called Q! in direction of vector with base at Q! and tip at P R α,β R α,β P α,β = Q +αu + βv dvpn ( t) = Q + t(p α,β Q) ( t) = Q + t αu + βv dvpn ( ) 10/28/14 Bruce Draper & J. Ross Beveridge 2014 4

Ray/Surface Intersection! Implicit surfaces are defined by f (P) = 0! Given a ray R t ( ) = Q + tw! The intersection is solved by ( ) = 0 f Q + tw 10/28/14 Bruce Draper & J. Ross Beveridge 2014 5 Intersect a Polygon Face! Find intersection point P on infinite plane.! Test if point P is inside polygon (later).! General equation for a plane in 3D: ax + by + cz ρ = 0! Recall an (x,y,z) point P is on a plane iff: N P = ρ where N = a b c 10/28/14 Bruce Draper & J. Ross Beveridge 2014 6

Here is a worked Example 10/28/14 Bruce Draper & J. Ross Beveridge 2014 7 Planar Intersection Find t-star Commonly described as t-star, the value of t along the ray where the ray punches through the infinite plane. N ( Q + t * W ) = ρ t * N W = ρ N Q t * = ρ N Q N W The 3D point of intersection is: ( ) = Q + t * W R t * Be careful. What if this is zero? Cost: 6 mults, 1 div, 5 adds, 1 negation 10/28/14 Bruce Draper & J. Ross Beveridge 2014 8

Now About Inside/Outside! Finding point of intersection arguably easy.! Is the point inside the bounded polygon?! Multiple ways to approach this question! Odd/even parity for general polygons! Divide convex polygons into triangles, perform triangle inside/outside test 10/28/14 Bruce Draper & J. Ross Beveridge 2014 9 Arbitrary polygons Step 1: project from 3D to 2D! Polygon edges are vectors in 3D! Point of ray/plane intersection is in 3D! but they all reside on the same plane! test inside/outside in 2D, not 3D! Not just faster; fewer stability issues! How do we project onto a 2D plane? 10/28/14 Bruce Draper & J. Ross Beveridge 2014 10

But, there is a faster way.! Orthographic projection onto either:! XY, YZ or XZ plane.! How? Just drop one dimension (set it to zero).! But, be careful! If your polygon is in the XY plane (z=const)! and you drop X or Y,! your polygon collapses to a line.! Close to parallel is essentially just as bad.! If your polygon is almost in the XY plane (Δz 0), then round-off can create problems 10/28/14 Bruce Draper & J. Ross Beveridge 2014 11 Illustration favored choice! Six sided polygon nearly parallel with?! See the trap. XY Plane View (red,green) XZ Plane View (red,blue) YZ Plane View (green,blue) 10/28/14 Bruce Draper & J. Ross Beveridge 2014 12

Projections for Intersection (II)! To be safe, drop the dimension with the largest value in N (the plane normal)! This is the coordinate most orthogonal to the plane, and therefore the safest to drop! Alternative: rotate the coordinate system to make N the Z axis! Rotation matrix is easy to compute! More multiplies, but no round-off issues! Fewer cases in your code 10/28/14 Bruce Draper & J. Ross Beveridge 2014 13 Rotate align N with Z! Equation of the plane. ˆN P = ρ where ˆN = a b c and ˆN ˆN =1! Rotation R =?????? a b c There are a variety of ways to selection the other to orthogonal basis vectors. 10/28/14 Bruce Draper & J. Ross Beveridge 2014 14

2D Polygon Membership! Either way,! We now have a 2D problem:! Polygon specified with 2D vertices! Point P (of planar intersection) is a 2D point! Task:! is P inside or outside of the polygon? 10/28/14 Bruce Draper & J. Ross Beveridge 2014 15 Odd/Even Parity Rule! Tests whether a 2D point P is inside or outside of a polygon! Step 1: draw a ray from P in any direction in the plane. (we overwork word ray here)! Step 2: count boundary crossings! Odd # of intersections inside! Even # of intersections outside 10/28/14 Bruce Draper & J. Ross Beveridge 2014 16

Odd/Even Illustrated Direction doesn t matter! 10/28/14 Bruce Draper & J. Ross Beveridge 2014 17 Odd/Even Intersections! Represent boundaries as rays! B i = V i+1 + t b (V i+1 V i )! Start ray at intersection P in any direction! R = P + t p (1,0) works nicely! To intersect ray R with polygon P! Intersect R with every boundary! An intersection is valid iff! t p 0 and 0 t b < 1.0! Odd # intersections => inside, even outside. 10/28/14 Bruce Draper & J. Ross Beveridge 2014 18

Is this efficient?! No!!!! But it s easy! and anyone in graphics ought to know it.! because it is general, works for! non-convex polygons,! self-intersection polygons.! However, efficiency matters! There are better methods for special cases! We will teach one in particular for triangles. 10/28/14 Bruce Draper & J. Ross Beveridge 2014 19 Ray/Triangle Intersections! Ray/Triangle intersections are efficient and can be computed directly in 3D! They rely on the following implicit definition of a triangle: P = A + β ( B A) +γ ( C A) β > 0,γ > 0, β +γ <1 10/28/14 Bruce Draper & J. Ross Beveridge 2012 20

Visualize the Math P = A + 0.50( B A) + 0.48( C A) P β = 0.5 γ = 0.48 A C-A 10/28/14 Bruce Draper & J. Ross Beveridge 2012 21 Think About a Trapezoid P = A + β ( B A) +γ ( C A) C-A β >1 γ < 0 β > 0, γ > 0 β > 0, γ > 0 1< β +γ < 2 γ >1 0 < β +γ <1 A C-A β < 0 10/28/14 Bruce Draper & J. Ross Beveridge 2012 22

Solve for implicit intersections! To find intersection, f(l+tu) = 0 (slide #4) Q + tw = A + β ( B A) +γ(c A)! This is a set of 3 linear equations with 3 unknowns: unkowns t, β, γ Q x + tw x = A x + β ( B x A x ) +γ ( C x A x ) Q y + tw y = A y + β B y A y ( ) +γ ( C y A y ) Q z + tw z = A z + β ( B z A z ) +γ ( C z A z ) 10/28/14 Bruce Draper & J. Ross Beveridge 2012 23 Push it through! Constants on one side. Q x A x = β ( B x A x ) +γ ( C x A x ) tw x Q y A y = β B y A y ( ) +γ ( C y A y ) tw y Q z A z = β ( B z A z ) +γ ( C z A z ) tw z! Now in Matrix Form ( B x A x ) ( C x A x ) W x ( B y A y ) C y A y ( B z A z ) C z A z ( ) W y ( ) W z β γ t = Q x A x Q y A y Q z A z 10/28/14 Bruce Draper & J. Ross Beveridge 2012 24

And, how to solve! Use a numerical solver, or! thanks to Wikipedia 10/28/14 Bruce Draper & J. Ross Beveridge 2014 25