Ray-triangle intersection

Similar documents
U8L1: Sec Equations of Lines in R 2

R is a scalar defined as follows:

September 2012 C1 Note. C1 Notes (Edexcel) Copyright - For AS, A2 notes and IGCSE / GCSE worksheets 1

CALCULUS BASIC SUMMER REVIEW

Section 1.1. Calculus: Areas And Tangents. Difference Equations to Differential Equations

Problem Cosider the curve give parametrically as x = si t ad y = + cos t for» t» ß: (a) Describe the path this traverses: Where does it start (whe t =

The picture in figure 1.1 helps us to see that the area represents the distance traveled. Figure 1: Area represents distance travelled

SNAP Centre Workshop. Basic Algebraic Manipulation

U8L1: Sec Equations of Lines in R 2

Review Problems for the Final

Summary: CORRELATION & LINEAR REGRESSION. GC. Students are advised to refer to lecture notes for the GC operations to obtain scatter diagram.

STRAIGHT LINES & PLANES

NICK DUFRESNE. 1 1 p(x). To determine some formulas for the generating function of the Schröder numbers, r(x) = a(x) =

Math 113, Calculus II Winter 2007 Final Exam Solutions

Infinite Sequences and Series

Complex Numbers Solutions

Machine Learning for Data Science (CS 4786)

Calculus 2 Test File Fall 2013

Recurrence Relations

Polynomial Functions and Their Graphs

SECTION 2 Electrostatics

GRAPHING LINEAR EQUATIONS. Linear Equations ( 3,1 ) _x-axis. Origin ( 0, 0 ) Slope = change in y change in x. Equation for l 1.

The z-transform. 7.1 Introduction. 7.2 The z-transform Derivation of the z-transform: x[n] = z n LTI system, h[n] z = re j

Fundamental Concepts: Surfaces and Curves

Chapter 4. Fourier Series

If the escalator stayed stationary, Billy would be able to ascend or descend in = 30 seconds. Thus, Billy can climb = 8 steps in one second.

3. Z Transform. Recall that the Fourier transform (FT) of a DT signal xn [ ] is ( ) [ ] = In order for the FT to exist in the finite magnitude sense,

Complex Numbers Primer

Sequences A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

Let us give one more example of MLE. Example 3. The uniform distribution U[0, θ] on the interval [0, θ] has p.d.f.

ACCESS TO SCIENCE, ENGINEERING AND AGRICULTURE: MATHEMATICS 1 MATH00030 SEMESTER / Statistics

WHAT IS THE PROBABILITY FUNCTION FOR LARGE TSUNAMI WAVES? ABSTRACT

The Random Walk For Dummies

10-701/ Machine Learning Mid-term Exam Solution

Estimation of a population proportion March 23,

Complex Numbers Primer

Chapter Vectors

NUMERICAL METHODS FOR SOLVING EQUATIONS

A sequence of numbers is a function whose domain is the positive integers. We can see that the sequence

REFLECTION AND REFRACTION

Quadratic Functions. Before we start looking at polynomials, we should know some common terminology.

PROPERTIES OF SQUARES

Statistics 511 Additional Materials

Review Problems Math 122 Midterm Exam Midterm covers App. G, B, H1, H2, Sec , 8.9,

Calculus with Analytic Geometry 2

Lemma Let f(x) K[x] be a separable polynomial of degree n. Then the Galois group is a subgroup of S n, the permutations of the roots.

6.3 Testing Series With Positive Terms

FLC Ch 8 & 9. Evaluate. Check work. a) b) c) d) e) f) g) h) i) j) k) l) m) n) o) 3. p) q) r) s) t) 3.

2 Geometric interpretation of complex numbers

Discrete-Time Systems, LTI Systems, and Discrete-Time Convolution

Final Review for MATH 3510

Introduction to Machine Learning DIS10

ES.182A Topic 40 Notes Jeremy Orloff

Section 11.8: Power Series

Linear Regression Demystified

JEE ADVANCED 2013 PAPER 1 MATHEMATICS

Mathematics Extension 2

ECE-S352 Introduction to Digital Signal Processing Lecture 3A Direct Solution of Difference Equations

5.6 Absolute Convergence and The Ratio and Root Tests

AP Calculus BC Review Applications of Derivatives (Chapter 4) and f,

CHAPTER 8 SYSTEMS OF PARTICLES

Question 1: The magnetic case

Orthogonal transformations

Math 475, Problem Set #12: Answers

Section 11.6 Absolute and Conditional Convergence, Root and Ratio Tests

CHAPTER 10 INFINITE SEQUENCES AND SERIES

MATH 31B: MIDTERM 2 REVIEW

6 Integers Modulo n. integer k can be written as k = qn + r, with q,r, 0 r b. So any integer.

UNIVERSITY OF NORTHERN COLORADO MATHEMATICS CONTEST. First Round For all Colorado Students Grades 7-12 November 3, 2007

TEACHER CERTIFICATION STUDY GUIDE

1 1 2 = show that: over variables x and y. [2 marks] Write down necessary conditions involving first and second-order partial derivatives for ( x0, y

4x 2. (n+1) x 3 n+1. = lim. 4x 2 n+1 n3 n. n 4x 2 = lim = 3

Topic 9: Sampling Distributions of Estimators

PAPER : IIT-JAM 2010

Name: Math 10550, Final Exam: December 15, 2007

Algebra II Notes Unit Seven: Powers, Roots, and Radicals

Balancing. Rotating Components Examples of rotating components in a mechanism or a machine. (a)

1 Generating functions for balls in boxes

Stokes Theorem is an extension of Green s Theorem. It states that given a. (curl F) n ds

6.003 Homework #3 Solutions

Math 5311 Problem Set #5 Solutions

Machine Learning for Data Science (CS 4786)

ChE 471 Lecture 10 Fall 2005 SAFE OPERATION OF TUBULAR (PFR) ADIABATIC REACTORS

(3) If you replace row i of A by its sum with a multiple of another row, then the determinant is unchanged! Expand across the i th row:

Calculus 2 Test File Spring Test #1

Inverse Matrix. A meaning that matrix B is an inverse of matrix A.

MA131 - Analysis 1. Workbook 2 Sequences I

from definition we note that for sequences which are zero for n < 0, X[z] involves only negative powers of z.

Principle Of Superposition

The Method of Least Squares. To understand least squares fitting of data.

Math 155 (Lecture 3)

In algebra one spends much time finding common denominators and thus simplifying rational expressions. For example:

Sequences I. Chapter Introduction

Physics 324, Fall Dirac Notation. These notes were produced by David Kaplan for Phys. 324 in Autumn 2001.

Some examples of vector spaces

Discrete Mathematics for CS Spring 2005 Clancy/Wagner Notes 21. Some Important Distributions

Mathematics Extension 2

ALGEBRAIC GEOMETRY COURSE NOTES, LECTURE 5: SINGULARITIES.

Recursive Algorithms. Recurrences. Recursive Algorithms Analysis

Ma 530 Introduction to Power Series

Transcription:

Ray-triagle itersectio ria urless October 2006 I this hadout, we explore the steps eeded to compute the itersectio of a ray with a triagle, ad the to compute the barycetric coordiates of that itersectio. First, we cosider the geometry of such a itersectio: P d where a ray with origi P ad directio d itersects a triagle defied by its vertices,,, ad at itersectio poit. The square regio diagrammatically surroudig triagle represets the supportig plae of the triagle, i.e., the plae that the triagle lies o. To perform ray-triagle itersectio, we must perform two steps: 1. Determie the poit of itersectio,. 2. Determie if lies iside of triagle. Fially, we ll compute the barycetric coordiates of with respect to. Determiig Determiig the poit of itersectio i tur requires us to take two more steps: 1. Determie the equatio of the supportig plae for triagle. 2. Itersect the ray with the supportig plae. We ll hadle these steps i reverse order. Ray-plae itersectio It is well kow that the equatio of a plae ca be writte as: ax + by + cz = d The coefficiets a, b, ad c form a vector that is ormal to the plae, = [a b c] T. Thus, we ca re-write the plae equatio as: x = d 1

where x = [x y z] T. Now we cosider the ray determied by P ad d: Rt ( ) = P+ td To solve for the itersectio of ray R(t) with the plae, we simply substitute x = R(t) ito the plae equatio ad solve for t: Rt ( ) = d [ P+ td] = d P+ t d= d d P t = d Note that if d =0, the d is parallel to the plae ad the ray does ot itersect the plae (i.e., the itersectio is at ifiity). e sure to check for this case! The itersectio poit ca thus be determied by pluggig the resultig t ito the ray equatio for R(t). Solvig for the supportig plae To itersect with a triagle, we eed to solve for the equatio of its supportig plae. s oted above, we eed oly solve for the ormal to the plae ad the coefficiet d. The figure below illustrates how we might solve for the ormal usig cross products. - - I particular, we ca costruct the vectors - ad - ad compute their ormalized cross product: = ( ) ( ) ( ) ( ) [Strictly speakig, does ot eed to be ormalized (i.e., of uit legth) i order for ray-plae ad ray-triagle itersectio to work; however, for shadig purposes, a ormalized ormal is ecessary ayway, so we preset the ormalized result.] 2

We should take a momet here to make a few commets. First, if we view the ormal to a triagle as simply beig a uit vector that is perpedicular to the supportig plae, the, i fact, both the computed above ad would satisfy our defiitio. Which oe is right? We ll assume that a triagle is actually oe-sided so that there is a correct ormal directio that poits to the outside of the object that the triagle belogs to. I additio, we ll assume that this directio is implicit i the orderig of the vertices. I particular, if you curl the figers of your right had from to to, the your thumb will poit i the directio of the ormal. This right-had rule is aother way of sayig that we expect the vertices to be arraged i couter-clockwise order with respect to the ormal. Next, we chose to cross - ito -. Did the order matter? Yes! If we had doe it the other way aroud, we would have bee computig. Fially, could we have chose other vectors for computig the ormal? Defiitely! y two vectors that are taget to the plae ca be crossed ito each other (i the correct order!) to yield the ormal vector. For istace, we could have crossed - with -, i that order, to compute the ormal. Gettig back to the sub-problem at had, how do we compute the remaiig coefficiet d i order to establish the supportig plae equatio? Earlier we stated the plae equatio as x = d. y x that satisfies this equatio must lie o the plae. Thus, if we pick a poit that lies o the plae, ad plug it ito the equatio, the the equatio must be satisfied. learly, the vertices of the triagle lie o the supportig plae, so we just eed to pick oe ay oe of them. We ll pick. Now we fid that, simply: d = t this poit, we have ow computed all the coefficiets eeded to describe the supportig plae of the triagle ad ca go ahead ad compute the itersectio. Triagle iside-outside testig Now we ve got the situatio where we have a triagle ad a itersectio poit, but we do t kow if actually lies iside the triagle. To determie this, we eed to perform a iside-outside test. I particular, lies iside of triagle if it lies o the iside of all of the lies determied by edges,, ad. elow, o the left, we see that satisfies this requiremet. O the right, we see that is iside of edges ad, but ot, ad is therefore outside the triagle. We ca ow use cross products to determie which side of each edge is o. osider the edge. If we form the vectors - ad -, the their cross product should poit i the same directio as the ormal. I other words, is o the iside of if: [( ) ( )] 3

The figure below, o the left, illustrates this idea for the two cases where is iside ad outside of the edge. I the secod case, the cross product will poit i the opposite directio of the ormal. - - - - We ca develop similar coditios for the other edges. s a result, is iside of if all of the followig coditios are met simultaeously: [( ) ( )] [( ) ( )] [( ) ( )] If ay oe of these tests fails, the is ot iside of, ad the result is o itersectio. Note that we used the greater tha or equal to compariso here. We do this i order to isure that the vertices,, ad ad the edges,, ad are all cosidered to be part of the triagle. For istace if were equal to, the the first test would retur a value of zero. Or, if were alog the edge, the the secod test would retur a value of zero (parallel vectors have a cross product of zero). I both cases, however, we would wat to declare to have itersected with the triagle; thus, the tests must have the greater tha or equal to comparisos. Note that the triagle-itersectio procedure described i this documet is ot as efficiet as it could be. s oted i class, you ca speed up the procedure by first projectig the triagle oto a axis aliged plae ad the perform the calculatios i 2D. The details of this procedure are beyod the scope of this documet. omputig barycetric coordiates s a fial step, if is iside of, we will compute the barycetric coordiates of with respect to. Recall from lecture that the barycetric coordiates ca be calculated i terms of area ratios: rea( ) rea( ) rea( ) α = β = γ = rea( ) rea( ) rea( ) I fact, these areas are each proportioal to the legths of the correspodig cross products described above. For istace, rea( ) = ( ) ( ) / 2 4

Sice the cross product poits i the directio (give that is iside of ), the we ca actually compute the legth of the cross product as simply: ( ) ( ) = [( ) ( )] Fially, we have the equatios for the barycetric coordiates of : [( ) ( )] [( ) ( )] [( ) ( )] α = β = γ = [( ) ( ) ] [( ) ( ) ] [( ) ( ) ] Note that we already computed the umerators i the previous sectios, as well as the terms eeded for the deomiator, so very little extra work is eeded to establish the barycetric coordiates. Oce these coordiates are calculated it is possible to, e.g., iterpolate ormals stored at vertices. I that case, oe would compute the ormal N at poit to be a weighted sum of the ormals N, N, ad N at vertices,, ad, respectively: N = αn + βn + γn αn + βn + γn The deomiator is required so that N is of uit legth ad ca be used i subsequet shadig, reflectio, ad refractio calculatios. 5