Data Structures and Algorithms: Cross Products, Convex Hull, and Closest Pair of Points - , Study notes of Data Structures and Algorithms

Various topics in computational geometry, including cross products, convex hull, and the closest pair of points. It provides explanations, diagrams, and algorithms for these concepts, such as graham's scan and jarvis's march for finding the convex hull and divide-and-conquer methods for finding the closest pair of points.

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-lpj
koofers-user-lpj 🇺🇸

10 documents

1 / 77

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Data Structures and Algorithms
CS245-2009S-24
Computational Geometry
David Galles
Department of Computer Science
University of San Francisco
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d

Partial preview of the text

Download Data Structures and Algorithms: Cross Products, Convex Hull, and Closest Pair of Points - and more Study notes Data Structures and Algorithms in PDF only on Docsity!

Data Structures and Algorithms

CS245-2009S-

Computational Geometry

David Galles

Department of Computer Science

University of San Francisco

Cross Products

Given any two points

p

1

x

, y 1

1

and

p

2

x

2

, y

Cross Product:

p

1

×

p

2

x

y 1

2

x

2

y

1

p

1

×

p

2

x

1

y

2

x

y 2

1

x

y 2

1

x

y 1

p

2

×

p

1

Cross Products

Given two vectors that share an origin:

p

p 0

1

and

p

0

p

2

Is

−→p^0

p

2

clockwise or counterclockwise relative to

p

p 0

2

?

24-3:

Cross Products

p^1

p^2

p^0

p^2

p^1

p^0

Counterclockwise

Clockwise

Cross Products

Given two line segments

p

p 0

1

and

p

1

p

2

, which

direction does angle

p

p 0

p 1

2

turn?

p^1

p^0

Left Turn

p^2

p^1

p^0 Right Turn

p^2

Cross Products

Given two line segments

p

p 0

1

and

p

1

p

2

, which

direction does angle

p

p 0

p 1

2

turn?

p

2

p

×

p

1

p

0

is positive, left turn

p

2

p

×

p

1

p

0

is negative, right turn

p

2

p

×

p

1

p

0

is zero, no turn (colinear)

Convex Hull

Convex Hull

Convex Hull

Graham’s Scan Algorithm

Go through all the points in order Push points onto a stack Pop off points that don’t form part of the convexhull When we’re done, stack contains the points inthe convex hull

Convex Hull

Gram-Scan

Let

p

0

be the point with the minimum

y

-coordinate

Sort the points by increasing polar angle around

p

0

Push

p

, 0 p

1

, and

p

2

on the stack

S

for

i

3 to

n

do

while angle formed by top two points on

S

doesn’t turn left do

Pop

Push(

p

)i

return

S

Graham’s Scan

 - p - p - p - p - p - p 
  • p - p
    • p - p - p Graham’s Scan - p - p - p
      • p
        • p
  • p - p
    • p - p - p^2 p^1 p Stack - p Graham’s Scan - p - p - p
      • p
        • p
  • p - p
    • p - p - p^3 p^2 p^1 p Stack - p Graham’s Scan - p - p - p
      • p
        • p
  • p - p
    • p - p - p^4 p^3 p^2 p^1 p Stack - p Graham’s Scan - p - p - p
      • p
        • p
  • p - p
    • p - p - p^4 p^2 p^1 p Stack