Csting II Lst Time? Csting / Tring Orthogrphi Cmer epresenttion (t) = origin + t * diretion -Sphere Intersetion -lne Intersetion Impliit vs. Epliit epresenttions MIT EECS 6.837, Cutler nd Durnd 1 MIT EECS 6.837, Cutler nd Durnd 2 Epliit vs. Impliit? Epliit rmetri Genertes points Hrd to verif tht point is on the ojet Impliit Solution of n eqution Does not generte points Verifies tht point is on the ojet Assignment 1: Csting Write si r ster Orthogrphi mer Sphere Intersetion Min loop rendering 2 Displ modes: olor nd distne We provide: (origin, diretion) Hit (t, Mteril) Sene rsing MIT EECS 6.837, Cutler nd Durnd 3 MIT EECS 6.837, Cutler nd Durnd 4 Ojet-Oriented Design We wnt to e le to dd primitives esil Inheritne nd virtul methods Even the sene is derived from Ojet3D! Ojet3D ool interset(, Hit, tmin) Grphis Tetooks eommended for 6.837: eter Shirle Fundmentls of Computer Grphis AK eters Tring lne ool interset(, Hit, tmin) Sphere ool interset(, Hit, tmin) Tringle ool interset(, Hit, tmin) Group ool interset(, Hit, tmin) MIT EECS 6.837, Cutler nd Durnd 5 MIT EECS 6.837, Cutler nd Durnd 6
Liner Alger eview Session Questions? Mond Sept. 20 (this Mond!) oom 2-105 (we hope) 7:30 9 M Imge Henrik Wnn Jensen MIT EECS 6.837, Cutler nd Durnd 7 MIT EECS 6.837, Cutler nd Durnd 8 Overview of Tod -Bo Intersetion -olgon Intersetion -Bo Intersetion Ais-ligned Bo: (X 1, Y 1, Z 1 ) (X 2, Y 2, Z 2 ) : (t) = + t -Tringle Intersetion -Bunn Intersetion & etr topis =Y 2 =Y 1 =X 1 =X 2 MIT EECS 6.837, Cutler nd Durnd 9 MIT EECS 6.837, Cutler nd Durnd 10 Nïve -Bo Intersetion 6 plne equtions: ompute ll intersetions eturn losest intersetion inside the o Verif intersetions re on the orret side of eh plne: A+B+C+D < 0 eduing Totl Computtion irs of plnes hve the sme norml Normls hve onl one non-0 omponent Do omputtions one dimension t time =Y 2 =Y 2 =Y 1 =Y 1 =X 1 =X 2 =X 1 =X 2 MIT EECS 6.837, Cutler nd Durnd 11 MIT EECS 6.837, Cutler nd Durnd 12
Test if rllel If = 0 (r is prllel) AND < X 1 or > X 2 no intersetion Find Intersetions er Dimension Clulte intersetion distne t 1 nd t 2 t 1 = (X 1 - ) / t 2 = (X 2 - ) / t 2 =Y 2 =Y 2 t 1 =Y 1 =Y 1 =X1 =X2 =X 1 =X 2 MIT EECS 6.837, Cutler nd Durnd 13 MIT EECS 6.837, Cutler nd Durnd 14 Mintin t ner & t fr Closest & frthest intersetions on the ojet If t 1 > t ner, t ner = t 1 If t 2 < t fr, t fr = t 2 Is there n Intersetion? If t ner > t fr o is missed =Y 2 t ner t fr t 2 =Y 2 t fr t ner t 1 =Y 1 =X1 =X2 =Y 1 =X1 =X2 MIT EECS 6.837, Cutler nd Durnd 15 MIT EECS 6.837, Cutler nd Durnd 16 Is the Bo Behind the Eepoint? eturn the Corret Intersetion If t fr < t min o is ehind If t ner > t min losest intersetion t t ner Else losest intersetion t t fr t fr t fr =Y 2 t ner =Y 2 t ner =Y 1 =Y 1 =X 1 =X 2 MIT EECS 6.837, Cutler nd Durnd 17 =X 1 =X 2 MIT EECS 6.837, Cutler nd Durnd 18
-Bo Intersetion Summr For eh dimension, If = 0 (r is prllel) AND < X 1 or > X 2 no intersetion For eh dimension, lulte intersetion distnes t 1 nd t 2 t 1 = (X 1 - ) / t 2 = (X 2 - ) / If t 1 > t 2, swp Mintin t ner nd t fr (losest & frthest intersetions so fr) If t 1 > t ner, t ner = t 1 If t 2 < t fr, t fr = t 2 If t ner > t fr o is missed If t fr < t min o is ehind If t ner > t min losest intersetion t t ner Else losest intersetion t t fr Effiien Issues 1/, 1/ nd 1/ n e pre-omputed nd shred for mn oes Unroll the loop Loops re ostl (euse of termintion if) Avoid the t ner & t fr omprison for first dimension MIT EECS 6.837, Cutler nd Durnd 19 MIT EECS 6.837, Cutler nd Durnd 20 Questions? Overview of Tod -Bo Intersetion -olgon Intersetion -Tringle Intersetion -Bunn Intersetion & etr topis Imge Henrik Wnn Jensen MIT EECS 6.837, Cutler nd Durnd 21 MIT EECS 6.837, Cutler nd Durnd 22 -olgon Intersetion -plne intersetion Test if intersetion is in the polgon Solve in the 2D plne oint Inside/Outside olgon intersetion definition: Cst r in n diretion (is-ligned is smrter) Count intersetions If odd numer, point is inside Works for onve nd str-shped MIT EECS 6.837, Cutler nd Durnd 23 MIT EECS 6.837, Cutler nd Durnd 24
reision Issue Wht if we interset verte? We might wrongl ount n intersetion for etl one djent edge Deide tht the verte is lws ove the r Winding Numer To solve prolem with str pentgon: Oriented edges Signed ount of intersetions Outside if 0 intersetions + - +- MIT EECS 6.837, Cutler nd Durnd 25 MIT EECS 6.837, Cutler nd Durnd 26 Alterntive Definition Sum of the signed ngles from point to edges ±360, ± 720, point is inside 0 point is outside How Do We rojet into 2D? Along norml Costl Along is Smrter (just drop 1 oordinte) Bewre of degeneries! MIT EECS 6.837, Cutler nd Durnd 27 MIT EECS 6.837, Cutler nd Durnd 28 Questions? Overview of Tod -Bo Intersetion -olgon Intersetion -Tringle Intersetion -Bunn Intersetion & etr topis Imge Henrik Wnn Jensen MIT EECS 6.837, Cutler nd Durnd 29 MIT EECS 6.837, Cutler nd Durnd 30
-Tringle Intersetion Use r-polgon Or tr to e smrter Use rentri oordintes Brentri Definition of lne (α, β, γ) = α + β + γ with α + β + γ =1 Is it epliit or impliit? [Möius, 1827] is the renter: the single point upon whih the plne would lne if weights of sie α, β, & γ re pled on points,, &. MIT EECS 6.837, Cutler nd Durnd 31 MIT EECS 6.837, Cutler nd Durnd 32 Brentri Definition of Tringle (α, β, γ) = α + β + γ with α + β + γ =1 AND 0 < α < 1 & 0 < β < 1 & 0 < γ < 1 How Do We Compute α, β, γ? tio of opposite su-tringle re to totl re α = A /A β = A /A γ = A /A Use signed res for points outside the tringle A A MIT EECS 6.837, Cutler nd Durnd 33 MIT EECS 6.837, Cutler nd Durnd 34 Intuition Behind Are Formul is renter of nd Q A is the interpoltion oeffiient on Q All points on lines prllel to hve the sme α (All suh tringles hve sme height/re) Simplif Sine α + β + γ =1, we n write α =1 β γ (α, β, γ) = α + β + γ rewrite (β, γ) = (1 β γ) + β + γ = + β(-) + γ(-) A A Q Non-orthogonl oordinte sstem of the plne MIT EECS 6.837, Cutler nd Durnd 35 MIT EECS 6.837, Cutler nd Durnd 36
Intersetion with Brentri Tringle Set r eqution equl to rentri eqution (t) = (β, γ) + t * = + β(-) + γ(-) Intersetion if β + γ < 1 & β > 0 & γ > 0 (nd t > t min ) MIT EECS 6.837, Cutler nd Durnd 37 Intersetion with Brentri Tringle + t * = + β(-) + γ(-) + t = + β( - ) + γ( - ) + t = + β( ȳ ) + γ( ȳ ) + t = + β( - ) + γ( - ) egroup & write in mtri form: β o d o γ = t o 3 equtions, 3 unknowns MIT EECS 6.837, Cutler nd Durnd 38 Crmer s ule Used to solve for one vrile t time in sstem of equtions β = o o o A d d d γ = A o o o d d d Advntges of Brentri Intersetion Effiient Stores no plne eqution Get the rentri oordintes for free Useful for interpoltion, teture mpping t = A o o o denotes the determinnt Cn e opied mehnill into ode MIT EECS 6.837, Cutler nd Durnd 39 MIT EECS 6.837, Cutler nd Durnd 40 Questions? Imge omputed using the ADIANCE sstem Greg Wrd Overview of Tod -Bo Intersetion -olgon Intersetion -Tringle Intersetion -Bunn Intersetion & etr topis MIT EECS 6.837, Cutler nd Durnd 41 MIT EECS 6.837, Cutler nd Durnd 42
Tringle Meshes (.oj) verties tringles v -1-1 -1 v 1-1 -1 v -1 1-1 v 1 1-1 v -1-1 1 v 1-1 1 v -1 1 1 v 1 1 1 f 1 3 4 f 1 4 2 f 5 6 8 f 5 8 7 f 1 2 6 f 1 6 5 f 3 7 8 f 3 8 4 f 1 5 7 f 1 7 3 f 2 4 8 f 2 8 6 MIT EECS 6.837, Cutler nd Durnd 43 Aquiring Geometr 3D Snning Digitl Mihelngelo rojet (Stnford) Cerwre MIT EECS 6.837, Cutler nd Durnd 44 reision Wht hppens when Origin is on n ojet? Gring rs? rolem with floting-point pproimtion The evil ε In r tring, do NOT report intersetion for rs strting t the surfe (no flse positive) Beuse seondr rs equires epsilons refletion shdow refrtion MIT EECS 6.837, Cutler nd Durnd 45 MIT EECS 6.837, Cutler nd Durnd 46 The evil ε: hint of nightmre Edges in tringle meshes Must report intersetion (otherwise not wtertight) No flse negtive Construtive Solid Geometr (CSG) Given overlpping shpes A nd B: Union Intersetion Sutrtion MIT EECS 6.837, Cutler nd Durnd 47 MIT EECS 6.837, Cutler nd Durnd 48
For emple: How n we implement CSG? oints on A, Outside of B oints on B, Outside of A oints on B, Inside of A oints on A, Inside of B Union Intersetion Sutrtion MIT EECS 6.837, Cutler nd Durnd 49 MIT EECS 6.837, Cutler nd Durnd 50 Collet ll the intersetions Implementing CSG 1. Test "inside" intersetions: Find intersetions with A, test if the re inside/outside B Find intersetions with B, test if the re inside/outside A Union Intersetion Sutrtion 2. Overlpping intervls: Find the intervls of "inside" long the r for A nd B Compute union/intersetion/sutrtion of the intervls MIT EECS 6.837, Cutler nd Durnd 51 MIT EECS 6.837, Cutler nd Durnd 52 Erl CSG tred Imge Questions? MIT EECS 6.837, Cutler nd Durnd 53 MIT EECS 6.837, Cutler nd Durnd 54
Net week: Trnsformtions MIT EECS 6.837, Cutler nd Durnd 55