Computational Geometry Exercise session #1 Yaron Ostrovsky-Berman, - - PDF document

computational geometry
SMART_READER_LITE
LIVE PREVIEW

Computational Geometry Exercise session #1 Yaron Ostrovsky-Berman, - - PDF document

Computational Geometry Exercise session #1 Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 1 Administrivia Exercise sessions (Shprinzak 202): Wednesday, 11:00 11:45. Course web page: www.cs.huji.ac.il/~compgeom


slide-1
SLIDE 1

1

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 1

Computational Geometry

Exercise session #1

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 2

Administrivia

  • Exercise sessions (Shprinzak 202):

Wednesday, 11:00 – 11:45.

  • Course web page:

www.cs.huji.ac.il/~compgeom

  • Course email:

compgeom@cs.huji.ac.il

  • Reception hours (Ross 28):

Wednesday, 10:00 – 11:00 (notify by email to course)

slide-2
SLIDE 2

2

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 3

Mission statement

  • Complement main lectures:

Technical details Algorithm Examples

  • Present and discuss homework.
  • Give examples related to homework.
  • New material related to current topic.

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 4

Session 1 topics

  • Geometric primitives

Distance measures Vector cross products Geometric predicates

  • Point in polygon queries

Simple polygons Convex polygons

  • Closest pair of points
slide-3
SLIDE 3

3

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 5

Geometric primitives

  • Distance between two planar points p and q

d(p,q) = [(p1-q1)2 + (p2-q2)2]1/2

  • Lw metric distance between points in Rd

dw(p,q) = [Σd

i=1(pi-qi)w]1/w

  • Signed distance between point p=(p1,p2) and

line L: ax+by+c=0 (with a2+b2=1) d(p,L) = ap1+bp2+c

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 6

Vector cross products (3D)

k b a b a j b a b a i b a b a b b b a a a k j i b a ) ( ) ( ) (

1 2 2 1 3 1 1 3 2 3 3 2 3 2 1 3 2 1

− + − + − = = × a = (a1,a2,a3) b = (b1,b2,b3)

) sin(α ab b a = ×

α

slide-4
SLIDE 4

4

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 7

Vector cross products (2D)

) (

1 2 2 1 2 1 2 1

b a b a b b a a b a − = = ×

) sin(α ab b a = ×

a = (a1,a2) b = (b1,b2) α p q r

1 2 2 1 1 1 2 2 2 1 2 1 2 1 2 1

) ( ) ( 1 1 1 ) , , ( 2 r q r q q r p r q p r r q q p p r q p area − + − + − = =

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 8

Geometric Predicates

  • Building blocks of geometric algorithms
  • Require two properties:

Efficiency Robustness

p q r

Is r to the left of the segment pq ?

p q r w

Do the segments pq and rw intersect?

slide-5
SLIDE 5

5

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 9

Point-Line orientation

p q r p q r p q r

          − = = colinear CW right CCW left r q p area sign

  • ri

) ( 1 ) ( 1 )) , , ( (

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 10

Segment intersection

p q r w

Do the segments pq and rw intersect?

Suggestions?

slide-6
SLIDE 6

6

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 11

Segment intersection I

  • Quick filter – bounding box test

For segments to intersect, both x and y intervals must

  • verlap.

{p1,p2} and {p3,p4} are {lower left, upper right} vertices of bounding boxes. Condition for overlap: (p2x ≥ p3x) & (p4x ≥ p1x) & (p2y ≥ p3y) & (p4y ≥ p1y) p1 p2 p3 p4

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 12

Segment intersection II

p q r w

  • ri(p,q,r)*ori(p,q,w) = -1 & ori(w,r,p)*ori(w,r,q) = -1
slide-7
SLIDE 7

7

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 13

Segment intersection - special cases

improper intersection segments overlap impossible after filter

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 14

Point in simple polygon

slide-8
SLIDE 8

8

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 15

Point in convex polygon

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 16

Point in star-shaped polygon

kernel

slide-9
SLIDE 9

9

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 17

Closest pair of points

S1 S2 δ1 δ2

Yaron Ostrovsky-Berman, Computational Geometry, Spring 2005 18

Closest pairs – the merge step

δ δ δ p