INTERSECTIONS OF LINE SEGMENTS AND POLYGONS



Similar documents
Outside Cut 1 of fabric Cut 1 of interfacing

CPS 220 Theory of Computation REGULAR LANGUAGES. Regular expressions

5.4 Exponential Functions: Differentiation and Integration TOOTLIFTST:

The example is taken from Sect. 1.2 of Vol. 1 of the CPN book.

Question 3: How do you find the relative extrema of a function?

Outline. Binary Tree

Change Your History How Can Soccer Knowledge Improve Your Business Processes?

Last time Interprocedural analysis Dimensions of precision (flow- and context-sensitivity) Flow-Sensitive Pointer Analysis

Lecture 20: Emitter Follower and Differential Amplifiers

HOW Interactive Design Conference Advanced HTML 5 / CSS 3 / jquery Chris Converse. codify kōd fī

A Note on Approximating. the Normal Distribution Function

Uses for Binary Trees -- Binary Search Trees

CPU. Rasterization. Per Vertex Operations & Primitive Assembly. Polynomial Evaluator. Frame Buffer. Per Fragment. Display List.

5 2 index. e e. Prime numbers. Prime factors and factor trees. Powers. worked example 10. base. power

by John Donald, Lecturer, School of Accounting, Economics and Finance, Deakin University, Australia

Repulsive Force

Probabilistic maintenance and asset management on moveable storm surge barriers

Magic Message Maker Amaze your customers with this Gift of Caring communication piece

QUANTITATIVE METHODS CLASSES WEEK SEVEN

Reading. Minimum Spanning Trees. Outline. A File Sharing Problem. A Kevin Bacon Problem. Spanning Trees. Section 9.6

Lecture 3: Diffusion: Fick s first law

C H A P T E R 1 Writing Reports with SAS

AP Calculus AB 2008 Scoring Guidelines

CIRCUITS AND ELECTRONICS. Basic Circuit Analysis Method (KVL and KCL method)

New Basis Functions. Section 8. Complex Fourier Series

Factorials! Stirling s formula

Fetch. Decode. Execute. Memory. PC update

AP Calculus Multiple-Choice Question Collection connect to college success

Traffic Flow Analysis (2)

SPECIAL VOWEL SOUNDS

Rural and Remote Broadband Access: Issues and Solutions in Australia

Cloud and Big Data Summer School, Stockholm, Aug., 2015 Jeffrey D. Ullman

Econ 371: Answer Key for Problem Set 1 (Chapter 12-13)

Using SAS s PROC GPLOT to plot data and lines

Mathematics. Mathematics 3. hsn.uk.net. Higher HSN23000

Sharp bounds for Sándor mean in terms of arithmetic, geometric and harmonic means

STATEMENT OF INSOLVENCY PRACTICE 3.2

Meerkats: A Power-Aware, Self-Managing Wireless Camera Network for Wide Area Monitoring

Chapter 3 Chemical Equations and Stoichiometry

CHAPTER 4c. ROOTS OF EQUATIONS

Maintain Your F5 Solution with Fast, Reliable Support

Long run: Law of one price Purchasing Power Parity. Short run: Market for foreign exchange Factors affecting the market for foreign exchange

Architecture of the proposed standard

Rent, Lease or Buy: Randomized Algorithms for Multislope Ski Rental

Taiwan Stock Forecasting with the Genetic Programming

Parallel and Distributed Programming. Performance Metrics

HOMEWORK FOR UNIT 5-1: FORCE AND MOTION

Cisco Data Virtualization

Version 1.0. General Certificate of Education (A-level) January Mathematics MPC3. (Specification 6360) Pure Core 3. Final.

TELL YOUR STORY WITH MYNEWSDESK The world's leading all-in-one brand newsroom and multimedia PR platform

Usability Test of UCRS e-learning DVD

Lecture notes: 160B revised 9/28/06 Lecture 1: Exchange Rates and the Foreign Exchange Market FT chapter 13

MAXIMAL CHAINS IN THE TURING DEGREES

A Project Management framework for Software Implementation Planning and Management

Introduction to Physical Systems Modelling with Bond Graphs

Approximate Subtree Identification in Heterogeneous XML Document Collections

(Analytic Formula for the European Normal Black Scholes Formula)

AVAIL A. Magnum or Banana Cut. Here is the HOTTEST fletching on the market today.

FACULTY SALARIES FALL NKU CUPA Data Compared To Published National Data


Free ACA SOLUTION (IRS 1094&1095 Reporting)

Basis risk. When speaking about forward or futures contracts, basis risk is the market

Remember you can apply online. It s quick and easy. Go to Title. Forename(s) Surname. Sex. Male Date of birth D

Finite Dimensional Vector Spaces.

Development of Financial Management Reporting in MPLS

Distributed Systems Principles and Paradigms. Chapter 11: Distributed File Systems. Distributed File Systems. Example: NFS Architecture

Job shop scheduling with unit processing times

Cookie Policy- May 5, 2014

Use a high-level conceptual data model (ER Model). Identify objects of interest (entities) and relationships between these objects

AC Circuits Three-Phase Circuits

Binary Search Trees. Definition Of Binary Search Tree. The Operation ascend() Example Binary Search Tree

AOFP/CrossFit Austere Program DRAFT 1 Mr. Greg Glassman, Capt Wade Rutland, and Capt JT Williams. AOFP Austere Program

Caution laser! Avoid direct eye contact with the laser beam!

UNIVERSITY OF SWAZILAND DEPARTMENT OF ACCOUNTING MAIN EXAMINATION PAPER DECEMBER, 2012 DEGREEIDIPLOMA AND YEAR STUDY:IDE D COM YEAR 2

YouthWorks Youth Works (yüth- w rkz), n.

Current and Resistance

Section 7.4: Exponential Growth and Decay

Projections - 3D Viewing. Overview Lecture 4. Projection - 3D viewing. Projections. Projections Parallel Perspective

Authenticated Encryption. Jeremy, Paul, Ken, and Mike

Financial Mathematics

Category 7: Employee Commuting

Adverse Selection and Moral Hazard in a Model With 2 States of the World

Capacitance and Dielectrics

union scholars program APPLICATION DEADLINE: FEBRUARY 28 YOU CAN CHANGE THE WORLD... AND EARN MONEY FOR COLLEGE AT THE SAME TIME!

Teaching Computer Networking with the Help of Personal Computer Networks

Who uses our services? We have a growing customer base. with institutions all around the globe.

Nimble Storage Exchange ,000-Mailbox Resiliency Storage Solution

Algorithmic Aspects of Access Networks Design in B3G/4G Cellular Networks

LAB 3: VELOCITY AND ACCELERATION GRAPHS

est with berkeley / uc berkeley With Berkeley exten be your best with berkeley c berkeley extension / be your best w

Vector Network Analyzer

Analyzing Failures of a Semi-Structured Supercomputer Log File Efficiently by Using PIG on Hadoop

Oracle PL/SQL Programming Advanced

Hi-trac Luminaire LED

EFFECT OF GEOMETRICAL PARAMETERS ON HEAT TRANSFER PERFORMACE OF RECTANGULAR CIRCUMFERENTIAL FINS

Budget Optimization in Search-Based Advertising Auctions

E X C H A N G E R U L E S A N D C L E A R I N G R U L E S O F N A S D A Q O M X D E R I V A T I V E S M A R K E T S

Key Management System Framework for Cloud Storage Singa Suparman, Eng Pin Kwang Temasek Polytechnic

WORKERS' COMPENSATION ANALYST, 1774 SENIOR WORKERS' COMPENSATION ANALYST, 1769

Transcription:

INTERSECTIONS OF LINE SEGMENTS AND POLYGONS PETR FELKEL FEL CTU PRAGUE lkl@l.cvut.cz https://cw.lk.cvut.cz/oku.php/courss/am9vg/start Bas on [Brg], [Mount], [Kukral], an [Drtina] Vrsion rom 19.11.01

Talk ovrviw Intrsctions o lin sgmnts (Bntly-Ottmann) Motivation Swp lin algorithm rcapitulation Swp lin intrsctions o lin sgmnts Intrsction o polygons or planar suivisions S assignmnt [1] or [Brg, Sction.] Intrsction o axis paralll rctangls S assignmnt [6] ( / 71)

Gomtric intrsctions what ar thy or? On o th most asic prolms in computational gomtry Soli moling Intrsction o ojct ounaris in CSG Ovrlay o suivisions,.g. layrs in GIS Brigs on intrsctions o roas an rivrs Maintnanc rsponsiilitis (roa ntwork X county ounaris) Rootics Collision tction an collision avoianc Computr graphics Rnring via ray shooting (intrsction o th ray with ojcts) ( / 71)

Lin sgmnt intrsction Intrsction o complx shaps is otn ruc to simplr an simplr intrsction prolms Lin sgmnt intrsction is th most asic intrsction algorithm Prolm statmnt: Givn n lin sgmnts in th plan, rport all points whr a pair o lin sgmnts intrsct. Prolm complxity Worst cas I = O(n ) intrsctions Practical cas only som intrsctions Us an output snsitiv algorithm O(n log n + I) optimal ranomiz algorithm O(n log n + I log n ) swp lin algorithm -% [Brg] ( / 71)

Plan swp lin algorithm rcapitulation Horizontal lin (swp lin, scan lin) l movs top-own (or vrtical lin: lt to right) ovr th st o ojcts Th mov is not continuous, ut l jumps rom on vnt point to anothr Evnt points ar in priority quu or sort list (~y) Th (lt) top-most vnt point is rmov irst Nw vnt points may crat (usually as intraction o nighors on th swp lin) an insrt in th quu Scan-lin status Stors inormation aout th ojcts intrsct y l It is upat whil stopping on vnt point ( / 71)

Lin sgmnt intrsction - Swp lin alg. Avoi tsting o pairs o sgmnts ar apart Comput intrsctions o nighors on th swp lin only O(n log n + I log n ) tim in O(n) mmory n stps or n points, I stps or intrsctions, log n sarch th status tr Ignor nasty cass (most o thm will solv latr on) No sgmnt is paralll to th swp lin Sgmnts intrsct in on point an o not ovrlap No thr sgmnts mt in a common point (6 / 71)

Lin sgmnt intrsctions Status = orr squnc o sgmnts intrscting th swp lin l Evnts (waiting in th priority quu) = points, whr th algorithm actually os somthing Sgmnt n-points known at algorithm start Sgmnt intrsctions twn nighoring sgmnts along SL Discovr as th swp xcuts (7 / 71)

Dtcting intrsctions Intrsction vnts must tct an insrt to th vnt quu or thy occur Givn two sgmnts a, intrscting in a point p, thr must a placmnt o swp lin l prior to p, such that sgmnts a, ar ajacnt along l (only ajacnt will tst or intrsction) sgmnts a, ar not ajacnt whn th alg. starts sgmnts a, ar ajacnt just or p => thr must an vnt point whn a, com ajacnt an thror ar tst or intrsction (8 / 71) [Brg]

Data structurs Swp lin l status = orr o sgmnts along l Balanc inary sarch tr o sgmnts Coors o intrsctions with l vary as l movs => stor pointrs to lin sgmnts in tr nos Position o l is plugg in th y=mx+ to gt th x-ky [Brg] (9 / 71)

Data structurs Evnt quu (postupový plán, časový plán) y top-own Din: Orr (top-own, lxicographic) p q i p y > q y or p y = q y an p x < q x top-own, lt-right approach (points on l trat lt to right) x Oprations Insrtion o comput intrsction points Ftching th nxt vnt (highst y low l ) Tst, i th sgmnt is alray prsnt in th quu (Locat an lt intrsction vnt in th quu) (10 / 71)

Prolm with uplicitis o intrsctions 1 x tct intrsction (11 / 71)

Data structurs Evnt quu ata structur Hap Prolm: can not chck uplicat intrsction vnts (rinvnt mor than onc) Intrsctions procss twic or vn mor Mmory complxity up to O(n ) Orr ictionary (alanc inary tr) Can chck uplicat vnts (as just constant actor) Nothing insrt twic I non-nighor intrsctions ar lt i.., i only intrsctions o nighors along l ar stor thn mmory complxity just O(n) (1 / 71) 1 x tct intrsction

Lin sgmnt intrsction algorithm FinIntrsctions(S) Input: Output: A st S o lin sgmnts in th plan Th st o intrsction points + pointrs to sgmnts in ach 1. init an mpty vnt quu Q an insrt th sgmnt npoints. init an mpty status structur T. whil Q in not mpty. rmov nxt vnt p rom Q. hanlevntpoint(p) Uppr npoint Intrsction Lowr npoint Not: Uppr-n-point vnts stor ino aout th sgmnt (1 / 71)

hanlevntpoint() principl Uppr npoint U(p) insrt p (on s j ) to status T a intrsctions with lt an right nighors to Q Intrsction C(p) switch orr o sgmnts in T a intrsctions o lt an right nighors to Q Lowr npoint L(p) rmov p (on s l ) rom T a intrsctions o lt an right nighors to Q [Brg] (1 / 71)

Mor than two sgmnts incint U(p)= {s } C(p)= {s 1, s } start hr cross on l L(p) = {s, s } n hr [Brg] (1 / 71)

Hanl Evnts [Brg, pag ] hanlevntpoint(p) U(p) 1. Lt U(p) = st o sgmnts whos Uppr npoint is p. Ths sgmts ar stor with th vnt point p (will a to T). Sarch T or all sgmnts S(p) that contain p (ar ajacnt in T): Lt L(p) S(p) = sgmnts whos Lowr npoint is p Lt C(p) S(p) = sgmnts that Contain p in intrior. i( L(p) U(p) C(p) contains mor than on sgmnt ). rport p as intrsction togthr with L(p), U(p), C(p) p p. Dlt th sgmnts in L(p) C(p) rom T 6. Insrt th sgmnts in U(p) C(p) into T Rvrs orr o C(p) in T (orr as low l, horizontal sgmnt as th last) 7. i( U(p) C(p) = ) thn innwevnt(s l, s r, p) // lt & right nighors 8. ls s = ltmost sgmnt o U(p) C(p); innwevnt(s l, s, p) s = rightmost sgmnt o U(p) C(p); innwevnt(s, s r, p) s l p s r p L(p) C(p) (16 / 71)

Dtction o nw intrsctions innwevnt(s l, s r, p) // with hanling o horizontal sgmnts Input: two sgmnts (lt & right rom p in T) an a currnt vnt point p Output: upat vnt quu Q with nw intrsction 1. i [ ( s l an s r intrsct low th swp lin l ) or ( intrsct on l an to th right o p ) ] an // horizontal sgmnts ( th intrsction is not prsnt in Q ). thn insrt intrsction as a nw vnt into Q s = ltmost sgmnt o U(p) C(p); s l p s r s l p s s r s l p s r s s l an s r intrsct low s = ltmost rom C(p) s r an s intrsct on l an to th right o p s (17 / 71)

Lin sgmnt intrsctions Mmory O(I) = O(n ) with uplicitis in Q or O(n ) with uplicitis in Q lt Oprational complxity n + I stops log n ach => O( I + n) log n total Th algorithm is y Bntly-Ottmann Bntly, J. L.; Ottmann, T. A. (1979), "Algorithms or rporting an counting gomtric intrsctions", IEEE Transactions on Computrs C-8 (9): 6-67, oi:10.1109/tc.1979.167. S also http://wapia.moi/n/bntly%e%80%9ottmann_algorithm (18 / 71)

Intrsction o axis paralll rctangls Givn th collction o n isothtic rctangls, rport all intrscting parts r 6 Altrnat sis Ovrlap long to two r 7 r r pncils o lins (trsy přímk) (otn us with r 8 Inclusion r points in ininity = axis paralll) r 1 r r 9 Answr: (r 1, r ) (r 1, r ) (r 1, r 8 ) (r, r ) (r, r ) (r, r 9 ) (r, r ) (r 7, r 8 ) [?] (19 / 71)

Brut orc intrsction Brut orc algorithm Input: st S o axis paralll rctangls Output: pairs o intrsct rctangls 1. For vry pair (r i, r j ) o rctangls S, i j. i (r i r j ) thn. rport (r i, r j ) Analysis Prprocssing: Non. Qury: = ( ). Storag: (0 / 71)

Plan swp intrsction algorithm Vrtical swp lin movs rom lt to right Stops at vry x-coorinat o a rctangl (ithr its lt si or its right si). activ rctangls a st = rctangls currntly intrscting th swp lin lt si vnt o a rctangl => th rctangl is a to th activ st. right si => th rctangl is lt rom th activ st. Th activ st us to tct rctangl intrsction (1 / 71)

Exampl rctangls an swp lin y activ rctangl not activ rctangl swp lin [Drtina] ( / 71)

Intrval tr as swp lin status structur Vrtical swp-lin => Only y-coorinats along it Turn our viw in slis 90 right Swp lin (y-axis) will rawn as horizontal y activ rctangl not activ rctangl L R y swp lin [Drtina] ( / 71)

Intrsction tst twn pair o intrvals Givn two intrvals R = [y 1, y ] an R = [y 1, y ] th conition R R is quivalnt to on o ths mutually xclusiv conitions: y 1 y a) y 1 y 1 y y 1 y ) y 1 y 1 y y 1 y y 1 y Intrvals along th swp lin a) ) ) Intrsction (ork) ( / 71)

Static intrval tr stors all n points Lt v = y m th mian o n-points o sgmnts S l : sgmnts o S that ar compltly to th lt o y m S m : sgmnts o S that contain y m S r : sgmnts o S that ar compltly to th right o y m y m [Vignron] ( / 71)

Static intrval tr Exampl L(v) R(v) S m Lt ns ascning Right ns scning S l S r [Vignron] (6 / 71)

Static intrval tr [Elsrunnr80] Stors intrvals along y swp lin kins o inormation - n points - incint intrvals - activ nos, 6, 1 1 6 1 6 [Kukral] (7 / 71)

Primary structur static tr or npoints v = mipoint o all sgmnt npoints H(v) = valu (y-coor) o v, 6, 1 1 6 1 6 [Kukral] (8 / 71)

Sconary lists o incint intrval n-pts. ML(v) lt npoints o intrval containing v (sort ascning) MR(v) right npoints (scning) 1 1 1 6, 6, ML(v) MR(v) 6 [Kukral] (9 / 71)

Activ nos intrsct y th swp lin Sust o all nos at prsnt intrsct y swp lin (nos with intrvals) LPTR Activ no RPTR Activ no, 6, Activ no 1 1 6 1 6 [Kukral] (0 / 71)

Qury = swp an rport intrsctions RctanglIntrsctions( S ) Input: St S o rctangls Output: Intrsct rctangl pairs 1. Prprocss( S ) // crat th intrval tr T (or y-coors) // an vnt quu Q (or x-coors). whil ( Q ) o. Gt nxt ntry (x i, y il, y ir, t) rom Q // t { lt right }. i ( t = lt ) // lt g. a) QuryIntrval ( y il, y ir, root(t)) // rport intrsctions 6. ) InsrtIntrval ( y il, y ir, root(t)) // insrt nw intrval 7. ls // right g 8. c) DltIntrval ( y il, y ir, root(t) ) (1 / 71)

Prprocssing Prprocss( S ) Input: St S o rctangls Output: Primary structur o th intrval tr T an th vnt quu Q 1. T = PrimaryTr(S) // Construct th static primary structur // o th intrval tr -> swp lin STATUS T. // Init vnt quu Q with vrtical rctangl gs in ascning orr ~x // Put th lt gs with th sam x aha o right ons. or i = 1 to n. insrt( ( x il, y il, y ir, lt ), Q) // lt gs o i-th rctangl. insrt( ( x ir, y il, y ir, right ), Q) // right gs ( / 71)

Intrval tr primary structur construction PrimaryTr(S) // only th y-tr structur, without intrvals Input: Output: St S o rctangls Primary structur o an intrval tr T 1. S y = Sort npoints o all sgmnts in S accoring to y-coorinat. T = BST( S y ). rturn T BST( S y ) 1. i( S y = 0 ) rturn null. ym = mian o S y. L = npoints p y ym. R = npoints p y > ym. t = nw IntrvalTrNo( ym ) 6. t.lt = BST(L) 7. t.right = BST(R) 8. rturn t ( / 71)

Intrval tr sarch th intrsctions QuryIntrval (,, T ) Input: Intrval o th g an currnt tr T Output: Rport th rctangls that intrsct [, ] H(v) Nw intrval ing tst or intrsction 1. i( T = null ) rturn. i=0; i( < H(v) < ) // orks at this no. whil ( MR(v).[i] >= ) && (i < Count(v)).. Rport all intrvals inm. RportIntrsction; i++ Othr nw intrval ing. QuryIntrval(,,T.LPTR ) tst or intrsction 6. QuryIntrval(,,T.RPTR ) 7. ls i (H(v) < ) // sarch RIGHT ( ) 8. whil (MR(v).[i] >= ) && (i < Count(v)) Crosss A,B 9. RportIntrsction; i++ Crosss A,B,C 10. QuryIntrval(,,T.RPTR ) Crosss A,B,C 11. ls // < H(v) //sarch LEFT( ) 1. whil (ML(v).[i] <= ) 1. RportIntrsction; i++ 1. QuryIntrval(,,T.LPTR ) Crosss nothing Crosss C Stor intrvals o activ rctangls C A B Cross.B T.LPTR ( / 71) T.RPTR

Intrval tr - intrval insrtion InsrtIntrval (,, T ) Input: Output: Intrval [,] an intrval tr T T atr insrtion o th intrval 1. v = root(t ). whil( v!= null ) // in th ork no. i (H(v) < < ). v = v.right // continu right. ls i ( < < H(v)) 6. v = v.lt // continu lt 7. ls // H(v) // insrt intrval 8. st v no to activ 9. connct LPTR rsp. RPTR to its parnt 10. insrt [,] into list ML(v) sort in ascning orr o s 11. insrt [,] into list MR(v) sort in scning orr o s 1. rak 1. nwhil 1. rturn T ( / 71) H(v) Nw intrval ing insrt

Exampl 1 (6 / 71)

Exampl 1 static tr on npoints Y H(v) valu o no v B A 1 1 0 X 1 B A [Drtina] (7 / 71)

Intrval insrtion [1,] a) Qury Intrval Y B Sarch MR(v) or ML(v): MR(v) is mpty No activ sons, stop < H(v) < 1 < < A 1 1 1 0 Activ rctangl Currnt no X A B Activ no [Drtina] (8 / 71)

Intrval insrtion [1,] ) Insrt Intrval Y B H(v)? 1? A 1 1 1 0 Activ rctangl Currnt no X A B Activ no [Drtina] (9 / 71)

Intrval insrtion [1,] ) Insrt Intrval Y B H(v) 1 ork => to lists A 1 1 1 1 0 Activ rctangl Currnt no X A B Activ no [Drtina] (0 / 71)

Intrval insrtion [,] a) Qury Intrval Y Sarch MR(v) only: H(v) < B MR(v)[1] =? => intrsction < A 1 1 R(v) 1 1 0 Activ rctangl Currnt no X A B Activ no [Drtina] (1 / 71)

Y Intrval insrtion [,] ) Insrt Intrval B H(v) ork => to lists A 1 1,, 1 0 Activ rctangl Currnt no Activ no X 1 B A [Drtina] ( / 71)

Intrval lt [1,] Y B A 1 1,, 1 1 0 Activ rctangl Currnt no X A B Activ no [Drtina] ( / 71)

Intrval lt [1,] Y B A 1 1 1 0 Activ rctangl Currnt no X A B Activ no [Drtina] ( / 71)

Intrval lt [,] Y B A 1 1 1 0 Activ rctangl Currnt no X A B Activ no [Drtina] ( / 71)

Intrval lt [,] Y B A 1 1 0 X 1 B A [Drtina] (6 / 71)

Exampl RctanglIntrsctions( S ) // this is a copy o th sli or Input: St S o rctangls // just to rmmr th algorithm Output: Intrsct rctangl pairs 1. Prprocss( S ) // crat th intrval tr T an vnt quu Q. whil ( Q ) o. Gt nxt ntry (x il, y il, y ir, t) rom Q // t { lt right }. i ( t = lt ) // lt g. a) QuryIntrval ( y il, y ir, root(t)) // rport intrsctions 6. ) InsrtIntrval ( y il, y ir, root(t)) // insrt nw intrval 7. ls // right g 8. c) DltIntrval ( y il, y ir, root(t) ) (7 / 71)

Exampl Y 8 7 6 1 7 1 c a 0 6 0 X 0 1 6 7 8 a c [Drtina] (8 / 71)

Insrt [,] mpty => ) Insrt Intrval H(v) Y 8 7 6 Insrt th nw intrval to sconary lists?? ork no => activ => to lists 1 7 1 c a 0 6 0 X 0 1 6 7 8 Activ rctangl Currnt no Activ no a c [Drtina] (9 / 71)

Insrt [,7] a) Qury Intrval H(v) < Y 8 7 6 or (all in MR(v)) tst MR(v)[i] >= => rport intrsction c 1 7? < 7? 1 c a 0 6 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (0 / 71)

Y Insrt [,7] ) Insrt Intrval Insrt th nw intrval to sconary lists H(v) 7 8 7 6 ork no => activ => to lists, 7, 1 7 1 c a 0 6 0 X 0 1 6 7 8 Activ rctangl a c Currnt no Activ no [Drtina] (1 / 71)

Y 8 7 6 1 Insrt [0,] a) Qury Intrval c or (all in ML(v)) tst ML(v).[i] => rport intrsction c go lt, nil, stop a, 7, 1 7 0 6 < H(v)? 0 <? 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] ( / 71)

Insrt [0,] ) Insrt Intrval 1/ < <H(v) Y 8 7 6, 7, 1 7? 0 < <? => insrt lt 1 c a 0 6 0 X 0 1 6 7 8 Activ rctangl a c Currnt no Activ no [Drtina] ( / 71)

Y 8 7 6 1 Insrt [0,] ) Insrt Intrval / c Insrt th nw intrval to sconary lists o th lt son LPTR link to parnt a, 7, 1 7 0 0 6 H(v)? 0 1? ork no => activ => to lists 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] ( / 71)

Y 8 7 6 1 Insrt [1,] a) Qury Intrval 1/ c or (all in MR(v)) => rport intrsction c, go lt -> 1 go right - nil a, 7, 1 7 0 0 6 < H(v) <? 1 < <? 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] ( / 71)

Y 8 7 6 1 Insrt [1,] a) Qury Intrval / c or (all in MR(v)) tst MR(v)[i] 1 => rport intrsction go right, nil, stop a, 7, 1 7 0 0 6 H(v) <? 1 1 <? 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (6 / 71)

Y 8 7 6 1 Insrt [1,] ) Insrt Intrval H(v) Insrt th nw intrval to sconary lists? 1? 1,, 7,, 1 7 c 0 0 6 a 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (7 / 71)

Y 8 7 6 1 Insrt [7,8] a) Qury Intrval c or (all in MR(v)) tst MR(v).[i] 7 => rport intrsction go right, nil, stop a 1,, 7,, 1 7 0 0 6 H(v) <? 7 < 8? 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (8 / 71)

Y 8 7 6 1 Insrt [7,8] ) Insrt Intrval c Insrt th nw intrval to sconary lists link to parnt a H(v) right <=? 7 < 8? right <=? 7 < 8? 7 7 8 1,, 7,, 1 7 0 0 6 7 8 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (9 / 71)

Y 8 7 6 1 Dlt [,7] Dlt Intrval H(v) Dlt th intrval [,7] rom sconary lists? 7 8? 1,, 1 7 c 0 0 6 7 8 a 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (60 / 71)

Y 8 7 6 1 Insrt [,6] a) Qury Intrval c H(v) < or (all in MR(v)) tst MR(v).[i] => rport intrsction < 6? or (all in ML(v)) tst ML(v).[i] 6 < 6 7? => no intrsction 1,, 1 7 a 0 0 6 7 8 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (61 / 71)

Y 8 7 6 1 Insrt [,6] ) Insrt Intrval c Insrt th nw intrval to sconary lists a 1,, 1 6 7 0 0 6 7 8 H(v) <? < 6?? 6? 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (6 / 71)

Y 8 7 6 1 Dlt [1,] Dlt Intrval Dlt th intrval [1,] rom sconary lists H(v)? 1? 1 6 7 c 0 0 6 7 8 a 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (6 / 71)

Y 8 7 6 1 Dlt [0,] Dlt Intrval 1/ Sarch or no with intrval [0,] < H(v)? 0 <? 1 6 7 c 0 0 6 7 8 a 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (6 / 71)

Y 8 7 6 1 Dlt [0,] Dlt Intrval / Dlt th intrval [0,] rom sconary lists o no 1 H(v)? 0 1? 1 6 7 c 0 0 6 7 8 a 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (6 / 71)

Y 8 7 6 1 Dlt [7,8] Dlt Intrval Sarch or an lt no with intrval [7,8] c a 1 6 7 0 6 H(v)? 7 < 8?? 7 < 8?? 7 7 8? 7 8 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (66 / 71)

Y 8 7 6 1 Dlt [,] Dlt Intrval Sarch or an lt no with intrval [,] H(v)?? 1 6 7 c 0 6 a 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (67 / 71)

Dlt [,6] Dlt Intrval H(v) Y 8 7 6 1 Sarch or an lt no with intrval [,6]? 6? 1 6 7 c 0 6 a 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (68 / 71)

Empty tr Y 8 7 6 1 Sarch or an lt no with intrval [,6] 1 7 c 0 6 a 0 Activ rctangl Currnt no Activ no X 0 1 6 7 8 a c [Drtina] (69 / 71)

Complxitis o rctangl intrsctions n rctangls, s intrsct pairs oun O(n log n) prprocssing tim to sparatly sort x-coorinats o th rctangls or th plan swp th y-coorinats or initializing th intrval tr. Th plan swp itsl taks O(n log n + s) tim, so th ovrall tim is O(n log n + s) O(n) spac This tim is optimal or a cision-tr algorithm (i.., on that only maks comparisons twn rctangl coorinats). (70 / 71)

Rrncs [Brg] Mark Brg, Otri Chong, Marc van Krvl, Mark Ovrmars: Computational Gomtry: Algorithms an Applications, Springr- Vrlag, r rv.. 008. 86 pags, 70 ig. ISBN: 978--0-7797-, Chaptrs an 9, http://www.cs.uu.nl/goook/ [Mount] Davi Mount, - CMSC 7: Computational Gomtry, Lctur Nots or Spring 007, Univrsity o Marylan, Lcturs 7,, 1,1, an 0. http://www.cs.um.u/class/spring007/cmsc7/lcturs.shtml [Rourk] Josph O Rourk:.: Computational Gomtry in C, Camrig Univrsity Prss, 199, ISBN 0-1- 9- http://mavn.smith.u/~orourk/ooks/compgom.html [Drtina] Tomáš Drtina: Intrsction o rctangls. Smstral Assignmnt. Computational Gomtry cours, FEL CTU Pragu, 006 [Kukral] Ptr Kukrál: Intrsction o rctangls. Smstral Assignmnt. Computational Gomtry cours, FEL CTU Pragu, 006 [Vignron] Sgmnt trs an intrval trs, prsntation, INRA, Franc, http://w.jouy.inra.r/units/miaj/pulic/vignron/cs/slis.html (71 / 71)