Computational Geometry Methods and Applications - Chen
-
Upload
alejandro-jimenez -
Category
Documents
-
view
218 -
download
0
Transcript of Computational Geometry Methods and Applications - Chen
-
8/23/2019 Computational Geometry Methods and Applications - Chen
1/227
C o m p u t a t i o n a l G e o m e t r y :
M e t h o d s a n d A p p l i c a t i o n s
J i a n e r C h e n
C o m p u t e r S c i e n c e D e p a r t m e n t
T e x a s A & M U n i v e r s i t y
F e b r u a r y 1 9 , 1 9 9 6
-
8/23/2019 Computational Geometry Methods and Applications - Chen
2/227
C h a p t e r 1
I n t r o d u c t i o n
G e o m e t r i c o b j e c t s s u c h a s p o i n t s , l i n e s , a n d p o l y g o n s a r e t h e b a s i s o f a
b r o a d v a r i e t y o f i m p o r t a n t a p p l i c a t i o n s a n d g i v e r i s e t o a n i n t e r e s t i n g s e t
o f p r o b l e m s a n d a l g o r i t h m s . T h e n a m e g e o m e t r y r e m i n d s u s o f i t s e a r l i e s t
u s e : f o r t h e m e a s u r e m e n t o f l a n d a n d m a t e r i a l s . T o d a y , c o m p u t e r s a r e b e i n g
u s e d m o r e a n d m o r e t o s o l v e l a r g e r - s c a l e g e o m e t r i c p r o b l e m s . O v e r t h e p a s t
t w o d e c a d e s , a s e t o f t o o l s a n d t e c h n i q u e s h a s b e e n d e v e l o p e d t h a t t a k e s
a d v a n t a g e o f t h e s t r u c t u r e p r o v i d e d b y g e o m e t r y . T h i s d i s c i p l i n e i s k n o w n
a s C o m p u t a t i o n a l G e o m e t r y
T h e d i s c i p l i n e w a s n a m e d a n d l a r g e l y s t a r t e d a r o u n d 1 9 7 5 b y S h a m o s ,
w h o s e P h . D . t h e s i s a t t r a c t e d c o n s i d e r a b l e a t t e n t i o n . A f t e r a d e c a d e o f d e v e l -
o p m e n t t h e e l d c a m e i n t o i t s o w n i n 1 9 8 5 , w h e n t h r e e c o m p o n e n t s o f a n y
h e a l t h y d i s c i p l i n e w e r e r e a l i z e d : a t e x t b o o k , a c o n f e r e n c e , a n d a j o u r n a l .
P r e p a r a t a a n d S h a m o s ' s b o o k C o m p u t a t i o n a l G e o m e t r y : A n I n t r o d u c t i o n
2 3 ] , t h e r s t t e x t b o o k s o l e l y d e v o t e d t o t h e t o p i c , w a s p u b l i s h e d a t a b o u t
t h e s a m e t i m e a s t h e r s t A C M S y m p o s i u m o n C o m p u t a t i o n a l G e o m e t r y w a s
h e l d , a n d j u s t p r i o r t o t h e s t a r t o f a n e w S p r i n g e r - V e r l a g j o u r n a l D i s c r e t e a n d
C o m p u t a t i o n a l G e o m e t r y . T h e e l d i s c u r r e n t l y t h r i v i n g . S i n c e 1 9 8 5 , s e v -
e r a l t e x t s , c o l l e c t i o n s , a n d m o n o g r a p h s h a v e a p p e a r e d 1 , 1 0 , 1 8 , 2 0 , 2 5 , 2 6 ] .
T h e a n n u a l s y m p o s i u m h a s a t t r a c t e d 1 0 0 p a p e r s a n d 2 0 0 a t t e n d e e s s t e a d i l y .
T h e r e i s e v i d e n c e t h a t t h e e l d i s b r o a d e n i n g t o t o u c h g e o m e t r i c m o d e l i n g
a n d g e o m e t r i c t h e o r e m p r o v i n g . P e r h a p s m o s t i m p o r t a n t l y , t h e r s t s t u d e n t s
w h o o b t a i n e d t h e i r P h . D . s i n c o m p u t e r s c i e n c e w i t h t h e s e s i n c o m p u t a t i o n a l
g e o m e t r y h a v e g r a d u a t e d , o b t a i n e d p o s i t i o n s , a n d a r e n o w t r a i n i n g t h e n e x t
g e n e r a t i o n o f r e s e a r c h e r s .
C o m p u t a t i o n a l g e o m e t r y i s o f p r a c t i c a l i m p o r t a n c e b e c a u s e E u c l i d e a n
1
-
8/23/2019 Computational Geometry Methods and Applications - Chen
3/227
2 I N T R O D U C T I O N
s p a c e o f t w o a n d t h r e e d i m e n s i o n s f o r m s t h e a r e n a i n w h i c h r e a l p h y s i c a l
o b j e c t s a r e a r r a n g e d . A l a r g e n u m b e r o f a p p l i c a t i o n s a r e a s s u c h a s p a t t e r n
r e c o g n i t i o n 2 8 ] , c o m p u t e r g r a p h i c s 1 9 ] , i m a g e p r o c e s s i n g 2 2 ] , o p e r a t i o n s
r e s e a r c h , s t a t i s t i c s 4 , 2 7 ] , c o m p u t e r - a i d e d d e s i g n , r o b o t i c s 2 5 , 2 6 ] , e t c . , h a v e
b e e n t h e i n c u b a t i o n b e d o f t h e d i s c i p l i n e s i n c e t h e y p r o v i d e i n h e r e n t l y g e o -
m e t r i c p r o b l e m s f o r w h i c h e c i e n t a l g o r i t h m s h a v e t o b e d e v e l o p e d . A l a r g e
n u m b e r o f m a n u f a c t u r i n g p r o b l e m s i n v o l v e w i r e l a y o u t , f a c i l i t i e s l o c a t i o n ,
c u t t i n g - s t o c k a n d r e l a t e d g e o m e t r i c o p t i m i z a t i o n p r o b l e m s . S o l v i n g t h e s e
e c i e n t l y o n a h i g h - s p e e d c o m p u t e r r e q u i r e s t h e d e v e l o p m e n t o f n e w g e o -
m e t r i c a l t o o l s , a s w e l l a s t h e a p p l i c a t i o n o f f a s t - a l g o r i t h m t e c h n i q u e s , a n d
i s n o t s i m p l y a m a t t e r o f t r a n s l a t i n g w e l l - k n o w n t h e o r e m s i n t o c o m p u t e r
p r o g r a m s . F r o m a t h e o r e t i c a l s t a n d p o i n t , t h e c o m p l e x i t y o f g e o m e t r i c a l g o -
r i t h m s i s o f i n t e r e s t b e c a u s e i t s h e d s n e w l i g h t o n t h e i n t r i n s i c d i c u l t y o f
c o m p u t a t i o n .
I n t h i s b o o k , w e c o n c e n t r a t e o n f o u r m a j o r d i r e c t i o n s i n c o m p u t a t i o n a l
g e o m e t r y : t h e c o n s t r u c t i o n o f c o n v e x h u l l s , p r o x i m i t y p r o b l e m s , s e a r c h i n g
p r o b l e m s a n d i n t e r s e c t i o n p r o b l e m s .
-
8/23/2019 Computational Geometry Methods and Applications - Chen
4/227
C h a p t e r 2
A l g o r i t h m i c F o u n d a t i o n s
F o r t h e p a s t t w e n t y y e a r s t h e a n a l y s i s a n d d e s i g n o f c o m p u t e r a l g o r i t h m s
h a s b e e n o n e o f t h e m o s t t h r i v i n g e n d e a v o r s i n c o m p u t e r s c i e n c e . T h e f u n d a -
m e n t a l w o r k s o f K n u t h 1 4 ] a n d A h o - H o p c r o f t - U l l m a n 2 ] h a v e b r o u g h t o r d e r
a n d s y s t e m a t i z a t i o n t o a r i c h c o l l e c t i o n o f i s o l a t e d r e s u l t s , c o n c e p t u a l i z e d
t h e b a s i c p a r a d i g m s , a n d e s t a b l i s h e d a m e t h o d o l o g y t h a t h a s b e c o m e t h e
s t a n d a r d o f t h e e l d . I t i s b e y o n d t h e s c o p e o f t h i s b o o k t o r e v i e w i n d e t a i l
t h e m a t e r i a l o f t h o s e e x c e l l e n t t e x t s , w i t h w h i c h t h e r e a d e r i s a s s u m e d t o
b e r e a s o n a b l y f a m i l i a r . I t i s a p p r o p r i a t e h o w e v e r , a t l e a s t f r o m t h e p o i n t o f
v i e w o f t e r m i n o l o g y , t o b r i e y r e v i e w t h e b a s i c c o m p o n e n t s o f t h e l a n g u a g e
i n w h i c h c o m p u t a t i o n a l g e o m e t r y w i l l b e d e s c r i b e d . T h e s e c o m p o n e n t s a r e
a l g o r i t h m s a n d d a t a s t r u c t u r e s . A l g o r i t h m s a r e p r o g r a m s t o b e e x e c u t e d o n
a s u i t a b l e a b s t r a c t i o n o f a c t u a l \ v o n N e u m a n n " c o m p u t e r s d a t a s t r u c t u r e s
a r e w a y s t o o r g a n i z e i n f o r m a t i o n , w h i c h , i n c o n j u n c t i o n w i t h a l g o r i t h m s ,
p e r m i t t h e e c i e n t a n d e l e g a n t s o l u t i o n o f c o m p u t a t i o n a l p r o b l e m s .
2 . 1 A C o m p u t a t i o n a l m o d e l
M a n y f o r m a l m o d e l s o f c o m p u t a t i o n a p p e a r i n t h e l i t e r a t u r e . T h e r e i s n o
g e n e r a l c o n s e n s u s a s t o w h i c h o f t h e s e i s t h e b e s t . I n t h i s b o o k , w e w i l l
a d o p t t h e m o s t c o m m o n l y - u s e d m o d e l . M o r e s p e c i c a l l y , w e w i l l a d o p t
r a n d o m a c c e s s m a c h i n e s ( R A M ) a s o u r c o m p u t a t i o n a l m o d e l .
3
-
8/23/2019 Computational Geometry Methods and Applications - Chen
5/227
4 A L G O R I T H M I C F O U N D A T I O N S
R a n d o m a c c e s s m a c h i n e ( R A M )
A r a n d o m a c c e s s m a c h i n e ( R A M ) m o d e l s a s i n g l e - p r o c e s s o r c o m p u t e r w i t h
a r a n d o m a c c e s s m e m o r y .
A R A M c o n s i s t s o f a r e a d - o n l y i n p u t t a p e , a w r i t e - o n l y o u t p u t t a p e , a
p r o g r a m a n d a ( r a n d o m a c c e s s ) m e m o r y . T h e m e m o r y c o n s i s t s o f r e g i s t e r s
e a c h c a p a b l e o f h o l d i n g a r e a l n u m b e r o f a r b i t r a r y p r e c i s i o n . T h e r e i s a l s o
n o u p p e r b o u n d o n t h e m e m o r y s i z e . A l l c o m p u t a t i o n s t a k e p l a c e i n t h e
p r o c e s s o r . A R A M c a n a c c e s s ( r e a d o r w r i t e ) a n y r e g i s t e r i n t h e m e m o r y i n
o n e t i m e u n i t w h e n i t h a s t h e c o r r e c t a d d r e s s o f t h a t r e g i s t e r .
T h e f o l l o w i n g o p e r a t i o n s o n r e a l n u m b e r s c a n b e d o n e i n u n i t t i m e b y a
r a n d o m a c c e s s m a c h i n e :
1 ) A r i t h m e t i c o p e r a t i o n s : , = , + , ; , l o g , e x p , s i n .
2 ) C o m p a r i s o n s
3 ) I n d i r e c t a c c e s s
2 . 2 C o m p l e x i t y o f a l g o r i t h m s a n d p r o b l e m s
T h e f o l l o w i n g n o t a t i o n s h a v e b e c o m e s t a n d a r d :
O ( f ( n ) ) : t h e c l a s s C
1
o f f u n c t i o n s s u c h t h a t f o r a n y g 2 C
1
, t h e r e i s a
c o n s t a n t c
g
s u c h t h a t f ( n ) c
g
g ( n ) f o r a l l b u t a n i t e n u m b e r o f n ' s
R o u g h l y s p e a k i n g , O ( f ( n ) ) i s t h e c l a s s o f f u n c t i o n s t h a t a r e a t m o s t
a s l a r g e a s f ( n )
o ( f ( n ) ) : t h e c l a s s C
2
o f f u n c t i o n s s u c h t h a t f o r a n y g 2 C
2
,
l i m
n ! 1
g ( n ) = f ( n ) = 0 . R o u g h l y s p e a k i n g , o ( f ( n ) ) i s t h e c l a s s o f f u n c -
t i o n s t h a t a r e l e s s t h a n f ( n )
( f ( n ) ) : t h e c l a s s C
3
o f f u n c t i o n s s u c h t h a t f o r a n y g 2 C
3
, t h e r e i s a
c o n s t a n t c
g
s u c h t h a t f ( n ) c
g
g ( n ) f o r a l l b u t a n i t e n u m b e r o f n ' s
R o u g h l y s p e a k i n g , ( f ( n ) ) i s t h e c l a s s o f f u n c t i o n s w h i c h a r e a t l e a s t
a s l a r g e a s f ( n )
! ( f ( n ) ) : t h e c l a s s C
4
o f f u n c t i o n s s u c h t h a t f o r a n y g 2 C
4
,
l i m
n ! 1
f ( n ) = g ( n ) = 0 . R o u g h l y s p e a k i n g , ! ( f ( n ) ) i s t h e c l a s s o f
f u n c t i o n s t h a t a r e l a r g e r t h a n f ( n )
( f ( n ) ) : t h e c l a s s C
5
o f f u n c t i o n s s u c h t h a t f o r a n y g 2 C
5
, g ( n ) =
O ( f ( n ) a n d g ( n ) = ( f ( n ) ) . R o u g h l y s p e a k i n g , ( f ( n ) ) i s t h e c l a s s
o f f u n c t i o n s w h i c h a r e o f t h e s a m e o r d e r a s f ( n )
-
8/23/2019 Computational Geometry Methods and Applications - Chen
6/227
D A T A S T R U C T U R E 5
C o m p l e x i t y o f a l g o r i t h m s
L e t A b e a n a l g o r i t h m i m p l e m e n t e d o n a R A M . I f f o r a n i n p u t o f s i z e n , A
h a l t s a f t e r m s t e p s , w e s a y t h a t t h e r u n n i n g t i m e o f t h e a l g o r i t h m A i s m
o n t h a t i n p u t .
T h e r e a r e t w o t y p e s o f a n a l y s e s o f a l g o r i t h m s : w o r s t c a s e a n d e x p e c t e d
c a s e . F o r t h e w o r s t c a s e a n a l y s i s , w e s e e k t h e m a x i m u m a m o u n t o f t i m e u s e d
b y t h e a l g o r i t h m f o r a l l p o s s i b l e i n p u t s . F o r t h e e x p e c t e d c a s e a n a l y s i s w e
n o r m a l l y a s s u m e a c e r t a i n p r o b a b i l i s t i c d i s t r i b u t i o n o n t h e i n p u t a n d s t u d y
t h e p e r f o r m a n c e o f t h e a l g o r i t h m f o r a n y i n p u t d r a w n f r o m t h e d i s t r i b u -
t i o n . M o s t l y , w e a r e i n t e r e s t e d i n t h e a s y m p t o t i c a n a l y s i s , i . e . , t h e b e h a v i o r
o f t h e a l g o r i t h m a s t h e i n p u t s i z e a p p r o a c h e s i n n i t y . S i n c e e x p e c t e d c a s e
a n a l y s i s i s u s u a l l y h a r d e r t o t a c k l e , a n d m o r e o v e r t h e p r o b a b i l i s t i c a s s u m p -
t i o n s o m e t i m e s i s d i c u l t t o j u s t i f y , e m p h a s i s w i l l b e p l a c e d o n t h e w o r s t
c a s e a n a l y s i s . U n l e s s o t h e r w i s e s p e c i e d , w e s h a l l c o n s i d e r o n l y w o r s t c a s e
a n a l y s i s .
D e n i t i o n L e t A b e a n a l g o r i t h m . T h e t i m e c o m p l e x i t y o f A i s O ( f ( n ) )
i f t h e r e e x i s t s a c o n s t a n t c s u c h t h a t f o r e v e r y i n t e g e r n 0 , t h e r u n n i n g
t i m e o f A i s a t m o s t c f ( n ) f o r a l l i n p u t s o f s i z e n
C o m p l e x i t y o f p r o b l e m s
W h i l e t i m e c o m p l e x i t y f o r a n a l g o r i t h m i s x e d , t h i s i s n o t s o f o r p r o b l e m s .
F o r e x a m p l e , S o r t i n g c a n b e i m p l e m e n t e d b y a l g o r i t h m s o f d i e r e n t t i m e
c o m p l e x i t y . T h e t i m e c o m p l e x i t y o f a k n o w n a l g o r i t h m f o r a p r o b l e m g i v e s u s
t h e i n f o r m a t i o n a b o u t a t m o s t h o w m u c h t i m e w e n e e d t o s o l v e t h e p r o b l e m .
W e w o u l d a l s o l i k e t o k n o w t h e m i n i m u m a m o u n t o f t i m e w e n e e d t o s o l v e
t h e p r o b l e m .
D e n i t i o n A f u n c t i o n u ( n ) i s a n u p p e r b o u n d o n t h e t i m e c o m p l e x i t y o f a
p r o b l e m P i f t h e r e i s a n a l g o r i t h m A s o l v i n g P s u c h t h a t t h e r u n n i n g t i m e
o f A i s u ( n ) . A f u n c t i o n l ( n ) i s a l o w e r b o u n d o n t h e t i m e c o m p l e x i t y o f a
p r o b l e m P i f a n y a l g o r i t h m s o l v i n g P h a s t i m e c o m p l e x i t y a t l e a s t l ( n )
-
8/23/2019 Computational Geometry Methods and Applications - Chen
7/227
6 A L G O R I T H M I C F O U N D A T I O N S
2 . 3 A d a t a s t r u c t u r e s u p p o r t i n g s e t o p e r a t i o n s
A s e t i s a c o l l e c t i o n o f e l e m e n t s . A l l e l e m e n t s o f a s e t a r e d i e r e n t , w h i c h
m e a n s n o s e t c a n c o n t a i n t w o c o p i e s o f t h e s a m e e l e m e n t .
W h e n u s e d a s t o o l s i n c o m p u t a t i o n a l g e o m e t r y , e l e m e n t s o f a s e t u s u a l l y
a r e n o r m a l g e o m e t r i c o b j e c t s , s u c h a s p o i n t s , s t r a i g h t l i n e s , l i n e s e g m e n t s ,
a n d p l a n e s i n E u c l i d e a n s p a c e s .
W e s h a l l s o m e t i m e s a s s u m e t h a t e l e m e n t s o f a s e t a r e l i n e a r l y o r d e r e d
b y a r e l a t i o n , u s u a l l y d e n o t e d \
-
8/23/2019 Computational Geometry Methods and Applications - Chen
8/227
D A T A S T R U C T U R E 7
T h e o r e m 2 . 3 . 1 A 2 - 3 t r e e o f n l e a v e s h a s h e i g h t O ( l o g n )
A l i n e a r l y o r d e r e d s e t o f e l e m e n t s c a n b e r e p r e s e n t e d b y a 2 - 3 t r e e b y
a s s i g n i n g t h e e l e m e n t s t o t h e l e a v e s o f t h e t r e e i n s u c h a w a y t h a t f o r a n y
n o n - l e a f n o d e o f t h e t r e e , a l l e l e m e n t s s t o r e d i n i t s r s t c h i l d a r e l e s s t h a n
a n y e l e m e n t s s t o r e d i n i t s s e c o n d c h i l d , a n d a l l e l e m e n t s s t o r e d i n i t s s e c o n d
c h i l d a r e l e s s t h a n a n y e l e m e n t s s t o r e d i n i t s t h i r d c h i l d ( i f i t h a s a t h i r d
c h i l d ) .
E a c h n o n - l e a f n o d e v o f a 2 - 3 t r e e k e e p s t h r e e p i e c e s o f i n f o r m a t i o n f o r
t h e c o r r e s p o n d i n g s u b t r e e .
L ( v ) : t h e l a r g e s t e l e m e n t s t o r e d i n t h e s u b t r e e r o o t e d a t i t s r s t c h i l d .
M ( v ) : t h e l a r g e s t e l e m e n t s t o r e d i n t h e s u b t r e e r o o t e d a t i t s s e c o n d
c h i l d .
H ( v ) : t h e l a r g e s t e l e m e n t s t o r e d i n t h e s u b t r e e r o o t e d a t i t s t h i r d
c h i l d ( i f i t h a s o n e ) .
2 . 3 . 1 M e m b e r
T h e a l g o r i t h m f o r d e c i d i n g t h e m e m b e r s h i p o f a n e l e m e n t i n a 2 - 3 t r e e i s
g i v e n a s f o l l o w s , w h e r e T i s a 2 - 3 t r e e , t i s t h e r o o t o f T , a n d u i s t h e e l e m e n t
t o b e s e a r c h e d i n t h e t r e e .
A l g o r i t h m M E M B E R ( T , u )
B E G I N
I F T i s a l e a f n o d e t h e n r e p o r t p r o p e r l y
E L S E I F L ( t ) > = u t h e n M E M B E R ( c h i l d 1 ( T ) , u )
E L S E I F M ( t ) > = u t h e n M E M B E R ( c h i l d 2 ( T ) , u )
E L S E I F t h a s a t h i r d c h i l d
T H E N M E M B E R ( c h i l d 3 ( T ) , u )
E L S E r e p o r t f a i l u r e .
E N D
S i n c e t h e h e i g h t o f t h e t r e e i s O ( l o g n ) , a n d t h e a l g o r i t h m s i m p l y f o l l o w s a
p a t h i n t h e t r e e f r o m t h e r o o t t o a l e a f , t h e t i m e c o m p l e x i t y o f t h e a l g o r i t h m
M E M B E R i s O ( l o g n )
-
8/23/2019 Computational Geometry Methods and Applications - Chen
9/227
8 A L G O R I T H M I C F O U N D A T I O N S
2 . 3 . 2 I n s e r t
T o i n s e r t a n e w e l m e n t x i n t o a 2 - 3 t r e e , w e p r o c e e d a t r s t a s i f w e w e r e
t e s t i n g m e m b e r s h i p o f x i n t h e s e t . H o w e v e r , a t t h e l e v e l j u s t a b o v e t h e
l e a v e s , w e s h a l l b e a t a n o d e v t h a t s h o u l d b e t h e p a r e n t o f x I f v h a s o n l y
t w o c h i l d r e n , w e s i m p l y m a k e x t h e t h i r d c h i l d o f v , p l a c i n g t h e c h i l d r e n i n
t h e p r o p e r o r d e r . W e t h e n a d j u s t t h e i n f o r m a t i o n c o n t a i n e d b y t h e n o d e v
t o r e e c t t h e n e w s i t u a t i o n .
S u p p o s e , h o w e v e r , t h a t x i s t h e f o u r t h c h i l d o f t h e n o d e v . W e c a n n o t
h a v e a n o d e w i t h f o u r c h i l d r e n i n a 2 - 3 t r e e , s o w e s p l i t t h e n o d e v i n t o t w o
n o d e s , w h i c h w e c a l l v a n d v
0
. T h e t w o s m a l l e s t e l e m e n t s a m o n g t h e f o u r
c h i l d r e n o f v s t a y w i t h v , w h i l e t h e t w o l a r g e r e l e m e n t s b e c o m e c h i l d r e n o f
n o d e v
0
. N o w , w e m u s t i n s e t v
0
a m o n g t h e c h i l d r e n o f p , t h e p a r e n t o f v
T h e p r o b l e m n o w i s s o l v e d r e c u r s i v e l y .
O n e s p e c i a l c a s e o c c u r s w h e n w e w i n d u p s p l i t t i n g t h e r o o t . I n t h a t c a s e
w e c r e a t e a n e w r o o t , w h o s e t w o c h i l d r e n a r e t h e t w o n o d e s i n t o w h i c h t h e
o l d r o o t w a s s p l i t . T h i s i s h o w t h e n u m b e r o f l e v e l s i n a 2 - 3 t r e e i n c r e a s e s .
T h e a b o v e d i s c u s s i o n i s i m p l e m e n t e d a s t h e f o l l o w i n g a l g o r i t h m s , w h e r e
T i s a 2 - 3 t r e e a n d x i s t h e e l e m e n t t o b e i n s e r t e d .
A l g o r i t h m I N S E R T ( T , x )
B E G I N
1 . F i n d t h e p r o p e r n o d e v i n t h e t r e e T s u c h t h a t
v i s g o i n g t o b e t h e p a r e n t o f x
2 . C r e a t e a l e a f n o d e d f o r t h e e l e m e n t x
3 . A D D S O N ( v , d )
E N D
W h e r e t h e p r o c e d u r e A D D S O N i s i m p l e m e n t e d b y t h e f o l l o w i n g r e c u r s i v e
a l g o r i t h m , w h i c h a d d s a c h i l d d t o a n o n - l e a f n o d e v i n a 2 - 3 t r e e .
A l g o r i t h m A D D S O N ( v , d )
B E G I N
1 . I F v i s t h e r o o t o f t h e t r e e , a d d t h e n o d e d p r o p e r l y .
O t h e r w i s e , d o t h e f o l l o w i n g .
2 . I F v h a s t w o c h i l d r e n , a d d d d i r e c t l y
3 . E L S E
3 . 1 . S u p p o s e v h a s t h r e e c h i l d r e n c 1 , c 2 , a n d c 3 . P a r t i t i o n c 1 ,
-
8/23/2019 Computational Geometry Methods and Applications - Chen
10/227
D A T A S T R U C T U R E 9
c 2 , c 3 a n d d p r o p e r l y i n t o t w o g r o u p s ( g 1 , g 2 ) a n d ( g 3 , g 4 ) .
L e t v b e t h e p a r e n t o f ( g 1 , g 2 ) a n d c r e a t e a n e w n o d e v ' a n d
l e t v ' b e t h e p a r e n t o f ( g 3 , g 4 ) .
3 . 2 . R e c u r s i v e l y c a l l A D D S O N ( f a t h e r ( v ) , v ' ) .
E N D
A n a l y s i s : T h e a l g o r i t h m I N S E R T c a n n d t h e p r o p e r p l a c e i n t h e t r e e f o r
t h e e l e m e n t x i n O ( l o g n ) t i m e s i n c e a l l i t n e e d s t o d o i s t o f o l l o w a p a t h
f r o m t h e r o o t t o a l e a f . S t e p 2 i n t h e a l g o r i t h m I N S E R T c a n b e d o n e i n
c o n s t a n t t i m e . T h e c a l l t o t h e p r o c e d u r e A D D S O N i n S t e p 3 c a n r e s u l t i n
a t m o s t O ( l o g n ) r e c u r s i v e c a l l s t o t h e p r o c e d u r e A D D S O N s i n c e e a c h c a l l
w i l l j u m p a t l e a s t o n e l e v e l u p i n t h e 2 - 3 t r e e , a n d e a c h r e c u r s i v e c a l l t a k e s
c o n s t a n t t i m e t o p e r f o r m S t e p s 1 , 2 , a n d 3 . 1 i n t h e a l g o r i t h m A D D S O N . S o
S t e p 3 i n t h e a l g o r i t h m I N S E R T t a k e s a l s o O ( l o g n ) t i m e . T h e r e f o r e , t h e
o v e r a l l t i m e c o m p l e x i t y o f t h e a l g o r i t h m I N S E R T i s O ( l o g n )
2 . 3 . 3 M i n i m u m
G i v e n a 2 - 3 t r e e T w e w a n t t o n d o u t t h e m i n i m u m e l e m e n t s t o r e d i n
t h e t r e e . R e c a l l t h a t i n a 2 - 3 t r e e t h e n u m b e r s a r e s t o r e d i n l e a f n o d e s
i n a s c e n d i n g o r d e r f r o m l e f t t o r i g h t . T h e r e f o r e t h e p r o b l e m i s r e d u c e d t o
g o i n g d o w n t h e t r e e , a l w a y s s e l e c t i n g t h e l e f t m o s t l i n k , u n t i l a l e a f n o d e i s
r e a c h e d . T h i s l e a f n o d e s h o u l d c o n t a i n t h e m i n i m u m e l e m e n t s t o r e d i n t h e
t r e e . E v i d e n t l y , t h e t i m e c o m p l e x i t y o f t h i s a l g o r i t h m i s O ( l o g n ) f o r a 2 - 3
t r e e w i t h n l e a v e s .
A l g o r i t h m M I N I M U M ( T , m i n )
B E G I N
I F T i s a l e a f T H E N
m i n : = T
E L S E c a l l M I N I M U M ( c h i l d 1 ( T ) , m i n )
E N D
2 . 3 . 4 D e l e t e
W h e n w e d e l e t e a l e a f f r o m a 2 - 3 t r e e , w e m a y l e a v e i t s p a r e n t v w i t h o n l y
o n e c h i l d . I f v i s t h e r o o t , d e l e t e v a n d l e t i t s l o n e c h i l d b e t h e n e w r o o t .
O t h e r w i s e , l e t p b e t h e p a r e n t o f v I f p h a s a n o t h e r c h i l d , a d j a c e n t t o v o n
-
8/23/2019 Computational Geometry Methods and Applications - Chen
11/227
1 0 A L G O R I T H M I C F O U N D A T I O N S
e i t h e r t h e r i g h t o r t h e l e f t , a n d t h a t c h i l d o f p h a s t h r e e c h i l d r e n , w e c a n
t r a n s f e r t h e p r o p e r o n e o f t h o s e t h r e e t o v . T h e n v h a s t w o c h i l d r e n , a n d w e
a r e d o n e .
I f t h e c h i l d r e n o f p a d j a c e n t t o v h a v e o n l y t w o c h i l d r e n , t r a n s f e r t h e l o n e
c h i l d o f v t o a n a d j a c e n t s i b l i n g o f v , a n d d e l e t e v . S h o u l d p n o w h a v e o n l y
o n e c h i l d , r e p e a t a l l t h e a b o v e , r e c u r s i v e l y , w i t h p i n p l a c e o f v
S u m m a r i z i n g t h e s e d i s c u s s i o n s t o g e t h e r , w e g e t t h e a l g o r i t h m D E L E T E ,
a s s h o w n b e l o w . W h e r e p r o c e d u r e D E L E T E ( ) i s m e r e l y a d r i v e r f o r s u b -
p r o c e d u r e D E L ( ) i n w h i c h t h e a c t u a l w o r k i s d o n e .
T h e v a r i a b l e s d o n e a n d 1 s o n i n D E L ( ) a r e b o o l e a n a g s u s e d t o i n d i c a t e
s u c c e s s f u l d e l e t i o n a n d t o d e t e c t t h e c a s e w h e n a n o d e i n t h e t r e e h a s o n l y
o n e c h i l d , r e s p e c t i v e l y .
I n t h e w o r s t c a s e w e n e e d t o t r a v e r s e a p a t h i n t h e t r e e f r o m r o o t t o a
l e a f t o l o c a t e t h e n o d e t o b e d e l e t e d , t h e n f r o m t h a t l e a f n o d e t o t h e r o o t ,
i n c a s e t h a t e v e r y n o n - l e a f n o d e o n t h e p a t h h a s o n l y t w o c h i l d r e n i n t h e
o r i g i n a l 2 - 3 t r e e T . T h u s t h e t i m e c o m p l e x i t y o f D E L E T E a l g o r i t h m f o r a
t r e e w i t h n n o d e s i s O ( l o g n )
A l g o r i t h m D E L E T E ( T , x )
B E G I N
C a l l D E L ( T , x , d o n e , 1 s o n )
I F d o n e i s t r u e T H E N
I F 1 s o n i s t r u e T H E N T : = c h i l d 1 ( T )
E L S E x w a s n o t f o u n d i n T , h a n d l e p r o p e r l y
E N D
A l g o r i t h m D E L ( T , x , d o n e , 1 s o n )
B E G I N
1 . I F c h i l d r e n o f T a r e l e a v e s T H E N p r o c e s s p r o p e r l y , i . e . , i f
x i s f o u n d , d e l e t e i t u p d a t e t h e v a r i a b l e s d o n e a n d 1 s o n
2 . E L S E I N C A S E O F
x < = L ( T ) : s o n : = c h i l d 1 ( T )
L ( T ) < x < = M ( T ) : s o n : = c h i l d 2 ( T )
M ( T ) < x < = H ( T ) : s o n : = c h i l d 3 ( T )
3 . C a l l D E L ( s o n , x , d o n e , 1 s o n 1 )
4 . I F 1 s o n 1 i s t r u e T H E N
4 . 1 . I F t h e n o d e T h a s a n o t h e r c h i l d b t h a t h a s t h r e e c h i l d r e n ,
T H E N r e o r g a n i z e t h e g r a n d c h i l d r e n a m o n g t h e n o d e s s o n a n d
-
8/23/2019 Computational Geometry Methods and Applications - Chen
12/227
D A T A S T R U C T U R E 1 1
b t o m a k e b o t h h a v e t w o c h i l d r e n , a n d s e t 1 s o n : = f a l s e
4 . 2 . E L S E m a k e t h e o n l y c h i l d o f t h e n o d e s o n a c h i l d o f a
s i b l i n g o f i t , a n d d e l e t e t h e n o d e s o n f r o m T . I f T h a s
o n l y o n e c h i l d t h e n s e t 1 s o n : = t r u e .
E N D
2 . 3 . 5 S p l i c e
S p l i c i n g t w o t r e e s i n t o o n e b i g t r e e i s a s p e c i a l c a s e o f t h e m o r e g e n e r a l
o p e r a t i o n o f m e r g i n g t w o t r e e s . S p l i c e a s s u m e s t h a t a l l t h e k e y s i n o n e o f t h e
t r e e s a r e l a r g e r t h a n a l l t h o s e i n t h e o t h e r t r e e . T h i s a s s u m p t i o n e e c t i v e l y
r e d u c e s t h e p r o b l e m o f m e r g i n g t h e t r e e s i n t o \ p a s t i n g " t h e s m a l l e r t r e e i n t o
a p r o p e r p o s i t i o n i n t h e l a r g e r t r e e . \ P a s t i n g " t h e s m a l l e r t r e e i s a c t u a l l y
n o m o r e t h a n p e r f o r m i n g a n A D D S O N o p e r a t i o n t o a p r o p e r n o d e i n t h e
l a r g e r t r e e .
T o b e m o r e s p e c i c , l e t T
1
a n d T
2
b e 2 - 3 t r e e s w h i c h w e w i s h t o s p l i c e i n t o
t h e 2 - 3 t r e e T , w h e r e a l l k e y s i n T
1
a r e s m a l l e r t h a n t h o s e i n T
2
. F u r t h e r m o r e ,
a s s u m e t h a t t h e h e i g h t o f T
1
i s l e s s t h a n o r e q u a l t o t h a t o f T
2
s o t h a t T
1
i s
\ p a s t e d " t o T
2
a s a l e f t c h i l d o f a l e f t m o s t n o d e a t t h e p r o p e r l e v e l i n T
2
I n
t h e c a s e w h e r e t h e h e i g h t s a r e e q u a l , b o t h T
1
a n d T
2
a r e m a d e c h i l d r e n o f
t h e c o m m o n r o o t T o t h e r w i s e t h e p r o p e r l e v e l i n T
2
i s g i v e n b y
h e i g h t ( T
2
) ; h e i g h t ( T
1
) ; 1
I t i s c l e a r t h a t t h e a l g o r i t h m S P L I C E r u n s i n t i m e O ( l o g n ) . I n f a c t ,
t h e r u n n i n g t i m e i s p r o p o r t i o n a l t o t h e h e i g h t d i e r e n c e h e i g h t ( T
2
) ;
h e i g h t ( T
1
) ; 1
T h e i m p l e m e n t a t i o n o f t h e a l g o r i t h m S P L I C E i s g i v e n b e l o w .
A l g o r i t h m S P L I C E ( T , T 1 , T 2 )
{ S u p p o s e t h a t a l l e l e m e n t s i n T 1 a r e l e s s t h a n a n y e l e m e n t s i n T 2 ,
a n d t h a t t h e h e i g h t o f T 1 i s a t m o s t t h a t o f T 2 . O t h e r c a s e s c a n
b e d e a l t w i t h s i m i l a r l y . }
B E G I N
I F h e i g h t ( T 1 ) = h e i g h t ( T 2 )
T H E N m a k e T a p a r e n t o f T 1 a n d T 2 .
E L S E
W H I L E h e i g h t ( T 2 ) - 1 > h e i g h t ( T 1 ) D O
-
8/23/2019 Computational Geometry Methods and Applications - Chen
13/227
1 2 A L G O R I T H M I C F O U N D A T I O N S
T 2 : = c h i l d 1 ( T 2 )
C a l l A D D S O N ( T 2 , T 1 ) .
E N D
2 . 3 . 6 S p l i t
B y s p l i t t i n g a g i v e n 2 - 3 t r e e T i n t o t w o 2 - 3 t r e e s , T
1
a n d T
2
, a t a g i v e n
e l e m e n t x , w e m e a n t o s p l i t t h e t r e e T i n s u c h a w a y t h a t a l l e l e m e n t s i n T
t h a t a r e l e s s t h a n o r e q u a l t o x g o t o T
1
w h i l e t h e r e m a i n i n g e l e m e n t s i n T
g o t o T
2
T h e i d e a i s a s f o l l o w s : a s t h e t r e e i s s e a r c h e d f o r x , w e s t o r e t h e s u b t r e e s
t o t h e l e f t a n d r i g h t o f t h e t r a v e r s e d p a t h ( s p l i t p a t h ) . F o r t h i s p u r p o s e t w o
s t a c k s a r e u s e d , o n e f o r e a c h s i d e o f t h e s p l i t p a t h . A s w e g o d e e p e r i n t o
T , s u b t r e e s a r e p u s h e d i n t o t h e p r o p e r s t a c k . F i n a l l y , t h e s u b t r e e s i n e a c h
s t a c k a r e s p l i c e d t o g e t h e r t o f o r m t h e d e s i r e d t r e e s T
1
a n d T
2
, r e s p e c t i v e l y .
T h e a l g o r i t h m i s g i v e n a s f o l l o w s .
A l g o r i t h m S P L I T ( T , x , T 1 , T 2 )
{ S p l i t T i n t o T 1 a n d T 2 s u c h t h a t a l l e l e m e n t s i n T 1 a r e l e s s
t h a n o r e q u a l t o x , a n d a l l e l e m e n t s i n T 2 a r e g r e a t e r t h a n x .
T h e s t a c k s S 1 a n d S 2 a r e u s e d t o s t o r e t h e s u b t r e e s t o t h e l e f t
a n d r i g h t o f t h e p a t h i n t h e 2 - 3 t r e e T f r o m t h e r o o t t o t h e
l e a f x , r e s p e c t i v e l y . }
B E G I N
1 . W H I L E T i s n o t l e a f D O
I F x < = L ( T ) T H E N
S 2 < - - c h i l d 3 ( T ) , c h i l d 2 ( T )
T : = c h i l d 1 ( T )
I F L ( T ) < x < = M ( T ) T H E N
S 1 < - - c h i l d 1 ( T ) S 2 < - - c h i l d 3 ( T )
T : = c h i l d 2 ( T )
I F M ( T ) < x < = H ( T ) T H E N
S 1 < - - c h i l d 1 ( T ) , c h i l d 2 ( T )
T : = c h i l d 3 ( T )
{ R e c o n s t r u c t T 1 }
2 . T 1 < - - S 1
3 . W H I L E S 1 i s n o t e m p t y D O
t < - - S 1
C a l l S P L I C E ( T 1 , t , T 1 )
-
8/23/2019 Computational Geometry Methods and Applications - Chen
14/227
D A T A S T R U C T U R E 1 3
{ R e c o n s t r u c t T 2 }
4 . T 2 < - - S 2
5 . W H I L E S 2 i s n o t e m p t y D O
t < - - S 2
C a l l S P L I C E ( T 2 , T 2 , t )
E N D
I t i s e a s y t o s e e t h a t t h e W H I L E l o o p i n S t e p 1 t a k e s t i m e O ( l o g n ) . T h e
a n a l y s i s f o r t h e r e s t o f t h e a l g o r i t h m i s a b i t m o r e c o m p l i c a t e d . N o t e t h a t
t h e u s e o f t h e s t a c k s S 1 a n d S 2 t o s t o r e t h e s u b t r e e s g u a r a n t e e s t h a t t h e
h e i g h t o f a s u b t r e e c l o s e r t o a s t a c k t o p i s l e s s t h a n o r e q u a l t o t h e h e i g h t o f
t h e s u b t r e e i m m e d i a t e l y d e e p e r i n t h e s t a c k . A c r u c i a l o b s e r v a t i o n i s t h a t
s i n c e w e s p l i c e s h o r t e r t r e e s r s t ( w h i c h a r e o n t h e t o p p a r t o f t h e s t a c k s ) ,
t h e d i e r e n c e b e t w e e n t h e h e i g h t s o f t w o t r e e s t o b e s p l i c e d i s a l w a y s v e r y
s m a l l . I n f a c t , t h e t o t a l t i m e s p e n t o n s p l i c i n g a l l t h e s e s u b t r e e s i s b o u n d e d
b y O ( l o g n ) . W e g i v e a f o r m a l p r o o f a s f o l l o w s .
A s s u m e t h a t t h e s u b t r e e s s t o r e d i n s t a c k S 1 a r e
t
1
t
2
t
r
( 2 1 )
i n t h e o r d e r f r o m t h e s t a c k t o p t o s t a c k b o t t o m . L e t h ( t ) b e t h e h e i g h t o f
t h e 2 - 3 t r e e t . A c c o r d i n g t o t h e a l g o r i t h m S P L I T , w e h a v e
h ( t
1
) h ( t
2
) h ( t
r
)
a n d n o t h r e e c o n s e c u t i v e s u b t r e e s i n t h e s t a c k h a v e t h e s a m e h e i g h t . T h u s ,
w e c a n p a r t i t i o n s e q u e n c e ( 1 ) i n t o \ s e g m e n t s " w h i c h c o n t a i n s t h e s u b t r e e s
o f t h e s a m e h e i g h t i n t h e s e q u e n c e :
s
1
s
2
s
q
E a c h s
i
e i t h e r i s a s i n g l e s u b t r e e o r c o n s i s t s o f t w o c o n s e c u t i v e s u b t r e e s o f
t h e s a m e h e i g h t i n s e q u e n c e ( 1 ) . M o r e o v e r , q l o g n . L e t h ( s
i
) b e t h e
h e i g h t o f t h e s u b t r e e s c o n t a i n e d i n t h e s e g m e n t s
i
. W e h a v e
h ( s
1
) < h ( s
2
)
-
8/23/2019 Computational Geometry Methods and Applications - Chen
15/227
1 4 A L G O R I T H M I C F O U N D A T I O N S
L e m m a 2 . 3 . 2 F o r a l l i = 2 : : : q , w e h a v e
h ( s
i ; 1
) h ( T
( i ; 1 )
1
) h ( s
i
) < h ( s
i + 1
) 2 , s i n c e T
( i ; 1 )
1
i s o b t a i n e d b y
s p l i c i n g t h e t r e e T
( i ; 2 )
1
a n d t h e s u b t r e e s i n s
i ; 1
, a n d t h e s u b t r e e s i n s
i ; 1
h a v e
h e i g h t h ( s
i ; 1
) . T h u s , t h e h e i g h t o f t h e 2 - 3 t r e e T
( i ; 1 )
1
i s a t l e a s t h ( s
i ; 1
)
N o w w e p r o v e t h e r e s t i n e q u a l i t i e s .
S i n c e t h e 2 - 3 t r e e T
( 1 )
1
i s o b t a i n e d b y s p l i c i n g t h e s u b t r e e s i n t h e s e g m e n t
s
1
, a n d s e g m e n t s
1
c o n t a i n s a t m o s t t w o s u b t r e e s , b o t h o f h e i g h t h ( s
1
) . T h u s ,
t h e h e i g h t o f t h e 2 - 3 t r e e T
( 1 )
1
i s a t m o s t h ( s
1
) + 1 , w h i c h i s n o t l a r g e r t h a n
h ( s
2
) . T h u s , t h e l e m m a i s t r u e f o r t h e c a s e i = 2
N o w a s s u m e t h a t t h e l e m m a i s t r u e f o r t h e c a s e i ; 1 ,
h ( T
( i ; 1 )
1
) h ( s
i
) < h ( s
i + 1
)
-
8/23/2019 Computational Geometry Methods and Applications - Chen
16/227
G E O M E T R I C G R A P H S 1 5
N o w w e a r e r e a d y f o r t h e f o l l o w i n g t h e o r e m
T h e o r e m 2 . 3 . 3 T h e W H I L E l o o p i n S t e p 3 o f t h e a l g o r i t h m S P L I T t a k e s
t i m e O ( l o g n )
p r o o f . F i r s t w e s t u d y t h e c o m p l e x i t y o f c o n s t r u c t i n g t h e 2 - 3 t r e e T
( i )
1
f r o m t h e 2 - 3 t r e e T
( i ; 1 )
1
a n d t h e t r e e s i n t h e s e g m e n t s
i
. A c c o r d i n g t o
L e m m a 2 . 3 . 2 , w e h a v e
h ( T
( i ; 1 )
1
) h ( s
i
)
T h u s , i f s
i
i s a s i n g l e s u b t r e e t
i
, t h e n a c c o r d i n g t h e a n a l y s i s o f t h e t i m e
c o m p l e x i t y o f t h e a l g o r i t h m S P L I C E , t h e t i m e o f s p l i c i n g T
( i ; 1 )
1
a n d t
i
i s
b o u n d e d b y a c o n s t a n t t i m e s
h ( s
i
) ; h ( T
( i ; 1 )
1
)
O n t h e o t h e r h a n d , i f s
i
c o n s i s t s o f t w o s u b t r e e s t
0
i
a n d t
0 0
i
, t h e n t h e
t i m e f o r s p l i c i n g T
( i ; 1 )
1
a n d t
0
i
i s a g a i n b o u n d e d b y a c o n s t a n t t i m e s h ( s
i
) ;
h ( T
( i ; 1 )
1
) . M o r e o v e r , n o t e t h a t t h e h e i g h t o f t h e r e s u l t i n g t r e e T
0
f r o m
s p l i c i n g T
( i ; 1 )
1
a n d t
0
i
i s e i t h e r h ( s
i
) o r h ( s
i
) + 1 , a n d t h a t t h e h e i g h t o f
t h e s u b t r e e t
0 0
i
i s h ( s
i
) . T h u s , s p l i c i n g T
0
a n d t
0 0
i
t a k e s o n l y c o n s t a n t t i m e .
T h e r e f o r e , i n t h i s c a s e , t h e t o t a l t i m e t o c o n s t r u c t T
( i )
1
f r o m T
( i ; 1 )
1
a n d s
i
i s
b o u n d e d b y a c o n s t a n t t i m e s
h ( s
i
) ; h ( T
( i ; 1 )
1
) + 1
T h e r e f o r e , t o c o n s t r u c t t h e n a l 2 - 3 t r e e T
( q )
1
, t h e t o t a l t i m e o f t h e
W H I L E l o o p i n S t e p 3 i s b o u n d e d b y a c o n s t a n t t i m e s
q
X
i = 2
( h ( s
i
) ; h ( T
( i ; 1 )
1
) + 1 )
B y L e m m a 2 . 3 . 2 , w e h a v e h ( s
i ; 1
) h ( T
( i ; 1 )
1
) . T h u s , t h e t i m e c o m p l e x i t y
o f t h e W H I L E l o o p i n S t e p 3 i s b o u n d e d b y a c o n s t a n t t i m e s
q
X
i = 2
( h ( s
i
) ; h ( s
i ; 1
) + 1 )
w h i c h i s e q u a l t o h ( s
q
) ; h ( s
1
) + q . S i n c e a l l q u a n t i t i e s h ( s
q
) , h ( s
1
) , a n d
q a r e b o u n d e d b y l o g n , w e c o n c l u d e t h a t t h e W H I L E l o o p i n S t e p 3 t a k e s
t i m e O ( l o g n )
T h e s a m e p r o o f s h o w s t h a t t h e W H I L E l o o p i n S t e p 5 a l s o t a k e s t i m e
O ( l o g n ) . I n c o n c l u s i o n , t h e a l g o r i t h m S P L I T t a k e s t i m e O ( l o g n )
-
8/23/2019 Computational Geometry Methods and Applications - Chen
17/227
1 6 A L G O R I T H M I C F O U N D A T I O N S
2 . 4 G e o m e t r i c g r a p h s i n t h e p l a n e
A g r a p h G = ( V E ) i s p l a n a r i f i t c a n b e e m b e d d e d i n t h e p l a n e w i t h o u t
e d g e c r o s s i n g s .
A p l a n a r e m b e d d i n g o f a p l a n a r g r a p h G = ( V E ) i s a m a p p i n g o f e a c h
v e r t e x i n V t o a p o i n t i n t h e p l a n e a n d e a c h e d g e i n E t o a s i m p l e c u r v e
b e t w e e n t h e t w o i m a g e s o f e x t r e m e v e r t i c e s o f t h e e d g e , s o t h a t n o t w o i m a g e s
o f e d g e s i n t e r s e c t e x c e p t a t t h e i r e n d p o i n t s . T h e i m a g e o f t h e m a p p i n g i s
c a l l e d a g e o m e t r i c g r a p h i n t h e p l a n e .
I f a l l e d g e s o f a g e o m e t r i c g r a p h G a r e s t r a i g h t - l i n e s e g m e n t s i n t h e p l a n e ,
G i s c a l l e d a p l a n a r s t r a i g h t - l i n e g r a p h , o r P S L G . A P S L G G d e t e r m i n e s i n
g e n e r a l a s u b d i v i s i o n o f t h e p l a n e . E a c h r e g i o n R o f t h e s u b d i v i s i o n , t o g e t h e r
w i t h t h e e d g e s o f G t h a t a r e o n t h e b o u n d a r y o f R , f o r m s a p o l y g o n i n t h e
p l a n e .
E u l e r ' s f o r m u l a
L e t v e a n d f d e n o t e t h e n u m b e r o f v e r t i c e s , e d g e s a n d r e g i o n s ( i n c l u d i n g
t h e u n b o u n d e d r e g i o n ) o f a P S L G , r e s p e c t i v e l y . T h e f a m o u s E u l e r ' s f o r m u l a
r e l a t e s t h e s e p a r a m e t e r s b y
v ; e + f = 2
i f w e h a v e a n a d d i t i o n a l p r o p e r t y t h a t e a c h v e r t e x h a s d e g r e e a t l e a s t 3
t h e n w e c a n p r o v e t h e f o l l o w i n g r e l a t i o n s :
v
2
3
e
e 3 f ; 6
f
2
3
e
v 2 f ; 4
e 3 v ; 6
f 2 v ; 4
T h a t i s , w e h a v e
( v ) = ( e ) = ( f )
T h e r e f o r e , f o r a p l a n a r g r a p h , t h e n u m b e r o f v e r t i c e s , t h e n u m b e r o f e d g e s ,
a n d t h e n u m b e r o f r e g i o n s a r e a l l l i n e a r l y r e l a t e d .
-
8/23/2019 Computational Geometry Methods and Applications - Chen
18/227
G E O M E T R I C G R A P H S 1 7vv v vf ff fe e ee ee 12 341 23 41 234 56F i g u r e 2 . 1 : T h e p l a n a r i m b e d d i n g o f K
4
D o u b l y C o n n e c t e d E d g e L i s t ( D C E L )
G i v e n a p l a n a r i m b e d d i n g I o f t h e c o m p l e t e g r a p h K
4
, a s d e p i c t e d i n F i g -
u r e 2 . 1 , w h a t i n f o r m a t i o n s h o u l d w e k e e p f o r t h i s i m b e d d i n g ? O f c o u r s e , t h e
s e t o f v e r t i c e s , a n d t h e s e t o f e d g e s o f K
4
s h o u l d b e k e p t . M o r e o v e r , i t i s
a l s o n e c e s s a r y t o k e e p t h e i n f o r m a t i o n a b o u t t h e r e g i o n s o f t h e i m b e d d i n g I
T o r e p r e s e n t t h e i n f o r m a t i o n o f t h e r e g i o n s , w e m u s t k n o w w h i c h e d g e w i l l
f o l l o w w h i c h e d g e w h e n w e t r a v e l a r o u n d a v e r t e x c o u n t e r c l o c k w i s e , i . e . , w e
m u s t k n o w t h e c y c l i c o r d e r i n g f o r t h e e d g e s i n c i d e n t o n e a c h v e r t e x o f t h e
i m b e d d i n g I
T h e D o u b l y C o n n e c t e d E d g e L i s t ( D C E L ) i s a n e c i e n t d a t a s t r u c t u r e
t o r e p r e s e n t a P S L G . T h e m a i n c o m p o n e n t o f D C E L f o r a P S L G G i s t h e
e d g e n o d e . T h e r e i s a o n e - t o - o n e c o r r e s p o n d e n c e b e t w e e n t h e e d g e s o f G
a n d e d g e n o d e s i n t h e c o r r e s p o n d i n g D C E L . A n e d g e n o d e c o n s i s t s o f f o u r
i n f o r m a t i o n e l d s V 1 V 2 F 1 a n d F 2 , a n d t w o p o i n t e r e l d s P 1 a n d P 2
T h e e l d s V 1 a n d V 2 c o n t a i n t h e s t a r t i n g v e r t e x a n d e n d i n g v e r t e x o f t h e
e d g e , r e s p e c t i v e l y . ( S o w e g i v e e a c h e d g e o f t h e P S L G G a n o r i e n t a t i o n .
T h i s o r i e n t a t i o n c a n b e d e n e d a r b i t r a r i l y . ) T h e e l d s F 1 a n d F 2 c o n t a i n
t h e n a m e s o f t h e r e g i o n s w h i c h l i e r e s p e c t i v e l y t o t h e l e f t a n d r i g h t o f t h e
e d g e o r i e n t e d f r o m V 1 t o V 2 . T h e p o i n t e r P 1 ( o r P 2 ) p o i n t s t o t h e e d g e
n o d e c o n t a i n i n g t h e r s t e d g e e n c o u n t e r e d a f t e r t h e e d g e ( V 1 V 2 ) w h e n o n e
p r o c e e d s c o u n t e r c l o c k w i s e a r o u n d V 1 ( o r V 2 ) . T h e r e f o r e , t h e e d g e P 1 i s t h e
-
8/23/2019 Computational Geometry Methods and Applications - Chen
19/227
1 8 A L G O R I T H M I C F O U N D A T I O N S
e d g e f o l l o w i n g t h e e d g e ( V 1 V 2 ) a t t h e v e r t e x V 1 , w h i l e t h e e d g e P 2 i s t h e
e d g e f o l l o w i n g t h e e d g e ( V 1 V 2 ) a t t h e v e r t e x V 2 i n t h e i m b e d d i n g I ( G )
T h e f o l l o w i n g i s t h e D C E L f o r t h e P S L G , w h i c h i s t h e c o m p l e t e g r a p h
K
4
i n F i g u r e 2 . 1 .
V 1 V 2 F 1 F 2 P 1 P 2
e
1
v
2
v
1
f
4
f
1
e
6
e
3
e
2
v
1
v
3
f
4
f
2
e
1
e
5
e
3
v
1
v
4
f
2
f
1
e
2
e
4
e
4
v
4
v
2
f
3
f
1
e
5
e
1
e
5
v
3
v
4
f
3
f
2
e
6
e
3
e
6
v
2
v
3
f
3
f
4
e
4
e
2
N o t e t h a t t h e s p a c e u s e d b y a D C E L t o r e p r e s e n t a P S L G i s l i n e a r t o
t h e n u m b e r o f e d g e s o f t h e P S L G .
S u p p o s e t h a t t h e s e t o f v e r t i c e s o f a P S L G G i s f v
1
v
n
g , a n d t h e s e t
o f r e g i o n s o f G i s f f
1
f
m
g . W e h a v e a n o t h e r t w o a r r a y s H V 1 n ] a n d
H F 1 m ] , w h e r e H V i ] p o i n t s t o a n e d g e n o d e i n t h e D C E L s u c h t h a t o n e
e d g e e n d o f t h e c o r r e s p o n d i n g e d g e i s v
i
, f o r i = 1 n , a n d H F j ] p o i n t s
t o a n e d g e n o d e o n t h e D C E L s u c h t h a t t h e c o r r e s p o n d i n g e d g e i s o n t h e
b o u n d a r y o f t h e r e g i o n f
j
, f o r j = 1 m
U s i n g D C E L o f G w e c a n t r a v e l t h e b o u n d a r y o f e a c h r e g i o n o f G o r t h e
e d g e s i n c i d e n t o n a v e r t e x o f G . T h e f o l l o w i n g i s a n a l g o r i t h m f o r t r a v e l i n g
t h e b o u n d a r y o f a r e g i o n w h e n t h e D C E L o f G i s g i v e n . ( T h e a l g o r i t h m f o r
t r a v e l i n g t h e e d g e s i n c i d e n t o n a v e r t e x o f G i s g i v e n i n 2 3 ] . )
A l g o r i t h m T R A C E - R E G I O N ( i )
{ T r a c e t h e b o u n d a r y e d g e s o f t h e r e g i o n i . }
B E G I N
1 . a : = H F i ]
2 . a 0 : = a
3 . I F ( D C E L a ] F 1 ] = i ) T H E N
a : = D C E L a ] P 1 ]
E L S E a : = D C E L a ] P 2 ]
4 . W H I L E ( a < > a 0 ) D O
I F ( D C E L a ] F 1 ] = i ) T H E N
a : = D C E L a ] P 1 ]
E L S E a : = D C E L a ] P 2 ]
E N D .
-
8/23/2019 Computational Geometry Methods and Applications - Chen
20/227
G E O M E T R I C G R A P H S 1 9
F o r e x a m p l e , i f w e s t a r t w i t h H F 3 ] = 4 , a n d u s e t h e D C E L f o r t h e
p l a n a r i m b e d d i n g I o f t h e c o m p l e t e g r a p h K
4
, t h e n w e w i l l g e t t h e r e g i o n
f
3
a s e
4
, e
5
, a n d e
6
N o t e t h a t i f t h e r o t a t i o n o f e d g e s i n c i d e n t o n e a c h v e r t e x o f t h e P S L G G
i s g i v e n i n c o u n t e r c l o c k w i s e o r d e r i n a D C E L , t h e n t h e r e g i o n s a r e t r a v e l e d
c l o c k w i s e b y t h e a b o v e a l g o r i t h m . O n t h e o t h e r h a n d , i f t h e r o t a t i o n o f e d g e s
i n c i d e n t o n e a c h v e r t e x o f t h e P S L G G i s g i v e n i n c l o c k w i s e o r d e r i n a D C E L ,
t h e n t h e r e g i o n s a r e t r a v e l e d c o u n t e r c l o c k w i s e b y t h e a b o v e a l g o r i t h m . G i v e n
a P S L G G , i t i s e a s y t o s e e t h a t a D C E L f o r G i n w h i c h t h e r o t a t i o n o f
e d g e s i n c i d e n t o n e a c h v e r t e x o f G i s g i v e n i n c o u n t e r c l o c k w i s e o r d e r c a n b e
t r a n s f o r m e d i n l i n e a r t i m e i n t o a D C E L f o r G i n w h i c h t h e r o t a t i o n o f e d g e s
i n c i d e n t o n e a c h v e r t e x o f G i s g i v e n i n c l o c k w i s e o r d e r , a n d v i c e v e r s a . T h e
d e t a i l e d i m p l e m e n t a t i o n o f t h i s t r a n s f o r m a t i o n i s s t r a i g h t f o r w a r d a n d l e f t t o
t h e r e a d e r a s a n e x e r c i s e .
-
8/23/2019 Computational Geometry Methods and Applications - Chen
21/227
2 0 A L G O R I T H M I C F O U N D A T I O N S
-
8/23/2019 Computational Geometry Methods and Applications - Chen
22/227
C h a p t e r 3
G e o m e t r i c P r e l i m i n a r i e s
A c c o r d i n g t o t h e n a t u r e o f t h e g e o m e t r i c o b j e c t s i n v o l v e d , w e c a n i d e n t i f y
b a s i c a l l y v e c a t e g o r i e s i n t o w h i c h t h e e n t i r e c o l l e c t i o n o f g e o m e t r i c p r o b l e m s
c a n b e c o n v e n i e n t l y c l a s s i e d , i . e . , c o n v e x i t y , p r o x i m i t y , g e o m e t r i c s e a r c h i n g ,
i n t e r s e c t i o n , a n d o p t i m i z a t i o n .
I n t h i s c h a p t e r , w e w i l l g i v e t h e p r e c i s e d e n i t i o n s o f t h e s e p r o b l e m s
a n d g i v e a n \ i n t u i t i v e " d i s c u s s i o n o n t h e m a t h e m a t i c a l b a c k g r o u n d o f t h e m .
S o m e o f o u r s t a t e m e n t s a n d p r o o f s a r e i n f o r m a l . T h i s i s b e c a u s e o f t h e f a c t
t h a t s o m e g e o m e t r i c t h e o r e m s a r e \ i n t u i t i v e l y o b v i o u s " b u t n o e a s y p r o o f s
a r e k n o w n t h o u g h m a n y g r e a t m a t h e m a t i c i a n s h a v e t r i e d . A n e x a m p l e i s
t h e f o l l o w i n g f a m o u s \ J o r d a n C u r v e T h e o r e m " , w h i c h w i l l a c t u a l l y s e r v e a s
a f u n d a m e n t a l b a s i s f o r a l l o f o u r d i s c u s s i o n s .
J o r d a n C u r v e T h e o r e m L e t C b e a s i m p l e c l o s e d c u r v e i n t h e
p l a n e , t h e n t h e p l a n e i s s u b d i v i d e d i n t o a n i n t e r i o r r e g i o n a n d a n
e x t e r i o r r e g i o n s u c h t h a t e v e r y c u r v e c o n n e c t i n g a p o i n t i n t h e
i n t e r i o r r e g i o n a n d a p o i n t i n t h e e x t e r i o r r e g i o n m u s t i n t e r s e c t
t h e c u r v e C
T h e k - d i m e n s i o n a l E u c l i d e a n s p a c e E
k
i s t h e s p a c e o f a l l k - t u p l e s
( x
1
x
k
) o f r e a l n u m b e r s x
i
, 1 i k . T h e d i s t a n c e b e t w e e n t w o p o i n t s
p
1
= ( x
1
x
k
) a n d p
2
= ( y
1
y
k
) i n t h e k - d i m e n s i o n a l s p a c e i s d e n e d
b y
d ( p
1
p
2
) = (
k
X
i = 1
y
i
; x
i
2
)
1 = 2
2 1
-
8/23/2019 Computational Geometry Methods and Applications - Chen
23/227
2 2 G E O M E T R I C P R E L I M I N A R I E S
T h e l i n e p a s s i n g t h r o u g h t h e p o i n t s p
1
a n d p
2
c a n b e p a r a m e t e r i z e d b y
p
1
+ ( 1 ; ) p
2
w h e r e r a n g e s o v e r t h e r e a l s . I f w e r e s t r i c t t o t h e i n t e r v a l 0 , 1 ] , t h e n w e
h a v e a r e p r e s e n t a t i o n f o r a l i n e s e g m e n t , d e n o t e d p
1
p
2
, w i t h t h e p o i n t s p
1
a n d p
2
a s i t s e x t r e m e p o i n t s .
M o r e g e n e r a l l y , s u p p o s e k + 1 i n d e p e n d e n t p o i n t s p
0
, p
1
, , p
k
b e l o n g
t o a k - d i m e n s i o n a l h y p e r p l a n e . T h e n t h e h y p e r p l a n e i s p a r a m e t e r i z e d b y
0
p
0
+
1
p
1
+ +
k
p
k
w h e r e
P
k
i = 0
i
= 1 . I f w e f u r t h e r r e s t r i c t a l l
i
0 , t h e n w e h a v e t h e
r e p r e s e n t a t i o n f o r a s i m p l e x o n k + 1 p o i n t s .
G i v e n a t r i a n g l e w i t h e d g e s A , B a n d C , t h e a n g l e b e t w e e n t h e t w o
e d g e s B a n d C c a n b e o b t a i n e d b y t h e f o l l o w i n g f o r m u l a :
= a r c c o s
B
2
+ C
2
; A
2
2 B C
( 3 1 )
w h e r e A , B , a n d C d e n o t e t h e l e n g t h s o f t h e e d g e s A , B , a n d C , r e s p e c -
t i v e l y .
S u p p o s e t h a t i s a t r i a n g l e i n t h e p l a n e E
2
w i t h t h e v e r t i c e s p
1
=
( x
1
y
1
) , p
2
= ( x
2
y
2
) a n d p
3
= ( x
3
y
3
) . T h e n t h e s i g n e d a r e a o f i s h a l f o f
t h e d e t e r m i n a n t
D ( p
1
p
2
p
3
) =
x
1
y
1
1
x
2
y
2
1
x
3
y
3
1
( 3 2 )
w h e r e t h e s i g n i s p o s i t i v e i f ( p
1
p
2
p
3
) f o r m a c o u n t e r c l o c k w i s e c y c l e , a n d
n e g a t i v e i f ( p
1
p
2
p
3
) f o r m a c l o c k w i s e c y c l e . W e s a y t h a t t h e p a t h f r o m p o i n t
p
1
t h r o u g h t h e l i n e s e g m e n t p
1
p
2
t o p o i n t p
2
t h e n t h r o u g h t h e l i n e s e g m e n t
p
2
p
3
t o p o i n t p
3
i s a l e f t t u r n i f D ( p
1
p
2
p
3
) i s p o s i t i v e , o t h e r w i s e , w e s a y
t h e p a t h m a k e s a r i g h t t u r n
W i t h t h e f o r m u l a s ( 8 . 1 ) a n d ( 8 . 3 ) , g i v e n t h r e e p o i n t s p
1
, p
2
, a n d p
3
i n
t h e p l a n e E
2
, w e c a n d e t e r m i n e c o m p l e t e l y t h e v a l u e o f t h e a n g l e f r o m t h e
l i n e s e g m e n t p
1
p
2
t o t h e l i n e s e g m e n t p
1
p
3
( d e n o t e t h i s a n g l e b y
6
p
2
p
1
p
3
)
A l i n e L o n t h e p l a n e c a n b e r e p r e s e n t e d b y a l i n e a r e q u a t i o n :
A x + B y + C = 0
-
8/23/2019 Computational Geometry Methods and Applications - Chen
24/227
C O N V E X H U L L S 2 3
s u c h t h a t a p o i n t p = ( x y ) i s o n t h e l i n e i f a n d o n l y i f t h e c o o r d i n a t e s o f p
s a t i s f y t h e e q u a t i o n . A h a l f p l a n e d e n e d b y t h e l i n e L c a n b e r e p r e s e n t e d
b y e i t h e r
A x + B y + C 0
o r
A x + B y + C 0
3 . 1 C o n v e x h u l l s
A s u b s e t L E
k
i s a c o n v e x s e t i f f o r e v e r y p a i r p
1
, p
2
o f p o i n t s i n L , t h e
l i n e s e g m e n t p
1
p
2
i s e n t i r e l y i n L
T h e o r e m 3 . 1 . 1 T h e i n t e r s e c t i o n o f c o n v e x s e t s i s c o n v e x .
p r o o f . L e t S
i
, i = 1 2 b e c o n v e x s e t s . D e n o t e b y S t h e i n t e r s e c t i o n
o f a l l t h e s e S
i
' s . W e p r o v e t h a t S i s a g a i n c o n v e x .
L e t p
1
a n d p
2
b e t w o p o i n t s i n S . S i n c e S i s t h e i n t e r s e c t i o n o f a l l S
i
' s ,
p
1
a n d p
2
a r e a l s o p o i n t s i n e a c h s e t S
i
, i = 1 2 . S i n c e e a c h S
i
i s c o n v e x ,
b y d e n i t i o n , t h e e n t i r e l i n e s e g m e n t p
1
p
2
i s i n S
i
, f o r i = 1 2 , t h u s i n
t h e i n t e r s e c t i o n S o f a l l t h e s e S
i
' s
D e n i t i o n L e t L E
k
. T h e c o n v e x h u l l C H ( L ) o f L i s t h e s m a l l e s t
c o n v e x s e t c o n t a i n i n g L
G i v e n n p o i n t s i n t h e p l a n e , w e w a n t t o n d t h e i r c o n v e x h u l l . T h i s
p r o b l e m i s a s f u n d a m e n t a l t o c o m p u t a t i o n a l g e o m e t r y a s s o r t i n g t o g e n e r a l
a l g o r i t h m s . I t i s a l s o a v e h i c l e f o r t h e s o l u t i o n o f a n u m b e r o f a p p a r e n t l y
u n r e l a t e d q u e s t i o n s a r i s i n g i n c o m p u t a t i o n a l g e o m e t r y . T h e c o n s t r u c t i o n o f
t h e c o n v e x h u l l o f a n i t e s e t o f p o i n t s h a s a l s o f o u n d a p p l i c a t i o n s i n m a n y
a r e a s , s u c h a s i n p a t t e r n r e c o g n i t i o n , i n i m a g e p r o c e s s i n g , i n R o b o t i c s , a n d
i n s t o c k c u t t i n g a n d a l l o c a t i o n .
T h e o r e m 3 . 1 . 2 L e t L E
k
. T h e c o n v e x h u l l C H ( L ) o f L e q u a l s t h e i n t e r -
s e c t i o n o f a l l c o n v e x s e t s c o n t a i n i n g L i n E
k
p r o o f . L e t S b e t h e i n t e r s e c t i o n o f a l l c o n v e x s e t s c o n t a i n i n g L i n E
k
B y t h e o r e m 3 . 1 . 1 , S i s c o n v e x , a n d o b v i o u s l y c o n t a i n s L . N o w w e p r o v e t h a t
-
8/23/2019 Computational Geometry Methods and Applications - Chen
25/227
2 4 G E O M E T R I C P R E L I M I N A R I E S
S i s t h e s m a l l e s t s u c h s e t . L e t S
0
b e a n a r b i t r a r y c o n v e x s e t c o n t a i n i n g L
T h e n b y t h e d e n i t i o n o f S , S i s t h e i n t e r s e c t i o n o f S
0
a n d o t h e r c o n v e x s e t s
c o n t a i n i n g L , t h e r e f o r e , S i s a s u b s e t o f S
0
. T h a t i s , S i s c o n t a i n e d i n e v e r y
c o n v e x s e t c o n t a i n i n g L , s o S i s t h e s m a l l e s t s u c h s e t .
A p o l y g o n i n E
k
i s a n i t e s e t o f l i n e s e g m e n t s s a t i s f y i n g t h e f o l l o w i n g
t w o c o n d i t i o n s :
1 . e v e r y e n d p o i n t i s s h a r e d b y e x a c t l y 2 l i n e s e g m e n t s a n d
2 . n o p r o p e r s u b s e t h a s P r o p e r t y 1 .
N o w w e s t u d y o u r p r o b l e m s i n t h e p l a n e E
2
, i . e . , t h e 2 - d i m e n s i o n a l
E u c l i d e a n s p a c e .
G i v e n a p o l y g o n P i n t h e p l a n e E
2
, P i s a s i m p l e p o l y g o n i f t h e r e i s n o
p a i r o f n o n c o n s e c u t i v e e d g e s s h a r i n g a p o i n t . F o r a n y s i m p l e p o l y g o n i n t h e
p l a n e , w e c a n a p p l y t h e J o r d a n C u r v e T h e o r e m t o d i v i d e t h e p l a n e i n t o t h e
i n t e r i o r a n d t h e e x t e r i o r o f t h e s i m p l e p o l y g o n . F o r a s i m p l e p o l y g o n P ,
w e w i l l u s e P t o r e f e r t o e i t h e r t h e b o u n d a r y o f P , o r t h e b o u n d a r y p l u s
t h e i n t e r i o r o f P . T h e r e a d e r s h o u l d n o t b e c o n f u s e d f r o m t h e c o n t e n t s .
A p o l y g o n P i s c a l l e d a c o n v e x p o l y g o n i f P i s a s i m p l e p o l y g o n a n d t h e
b o u n d a r y p l u s t h e i n t e r i o r o f P i s a c o n v e x s e t i n E
2
T h e o r e m 3 . 1 . 3 T h e c o n v e x h u l l o f a n i t e s e t S o f p o i n t s i n E
2
i s a s i m p l e
p o l y g o n . M o r e o v e r , e a c h h u l l v e r t e x m u s t b e a p o i n t i n t h e s e t S
p r o o f . W e g i v e a n i n f o r m a l , b u t i n t u i t i v e p r o o f h e r e . A f o r m a l p r o o f c a n
b e f o u n d i n 1 7 ] .
1 . T h e c o n v e x h u l l C H ( S ) o f t h e n i t e s e t S m u s t b e c o n n e c t e d . O t h e r -
w i s e , l e t p
1
a n d p
2
b e t w o p o i n t s i n t w o d i s t i n c t c o n n e c t e d c o m p o n e n t s
o f C H ( S ) . T h e n t h e l i n e s e g m e n t p
1
p
2
w o u l d n o t b e e n t i r e l y i n C H ( S )
2 . T h e c o n v e x h u l l C H ( S ) m u s t b e a b o u n d e d a r e a . I n f a c t , s i n c e S
c o n s i s t s o f n i t e n u m b e r o f p o i n t s , w e m u s t b e a b l e t o d r a w a c i r c l e C
o f a n i t e r a d i u s i n t h e p l a n e s u c h t h a t a l l p o i n t s o f S a r e i n s i d e C
T h e c i r c l e C i s o b v i o u s l y c o n v e x . N o w b y d e n i t i o n , t h e c o n v e x h u l l
C H ( S ) i s c o n t a i n e d i n t h e c i r c l e C
3 . L e t p
1
a n d p
2
b e t w o p o i n t s i n S s u c h t h a t a l l p o i n t s o f S a r e o n
o n e s i d e o f t h e s t r a i g h t l i n e t h r o u g h p
1
a n d p
2
, t h e n t h e l i n e s e g m e n t
-
8/23/2019 Computational Geometry Methods and Applications - Chen
26/227
C O N V E X H U L L S 2 5
p
1
p
2
i s o n t h e b o u n d a r y o f t h e c o n v e x h u l l C H ( S ) . F i r s t o f a l l , t h e l i n e
s e g m e n t p
1
p
2
m u s t b e c o n t a i n e d i n C H ( S ) . M o r e o v e r , s i n c e t h e h a l f
p l a n e H
1
d e t e r m i n e d b y t h e s t r a i g h t l i n e t h r o u g h p o i n t s p
1
a n d p
2
a n d
c o n t a i n i n g a l l p o i n t s o f S i s a c o n v e x s e t c o n t a i n i n g t h e s e t S , s o t h e
c o n v e x h u l l C H ( S ) i s c o n t a i n e d i n H
1
. T h e r e f o r e , n o p o i n t o n t h e o t h e r
s i d e o f t h e l i n e s e g m e n t p
1
p
2
c a n b e i n C H ( S ) . T h a t i s , p
1
p
2
i s o n t h e
b o u n d a r y o f t h e c o n v e x h u l l C H ( S )
4 . A l l p o i n t s o n t h e b o u n d a r y o f C H ( S ) m u s t b e o n a l i n e s e g m e n t p
1
p
2
,
w h e r e p
1
a n d p
2
a r e p o i n t s i n t h e s e t S . S u p p o s e t h a t p i s n o t s u c h
a p o i n t a n d p i s o n t h e b o u n d a r y o f C H ( S ) . I f w e \ s l i g h t l y " m o v e t h e
p a r t o f t h e b o u n d a r y o f C H ( S ) n e a r t h e p o i n t p s o t h a t t h e r e s u l t i n g
a r e a i s p r o p e r l y c o n t a i n e d i n C H ( S ) , i s s t i l l c o n v e x , a n d c o n t a i n s a l l
p o i n t s i n t h e s e t S , t h e n w e g e t a c o n v e x s e t t h a t c o n t a i n s a l l p o i n t s
o f t h e s e t S , a n d i s \ s m a l l e r " t h a n C H ( S ) , c o n t r a d i c t i n g t h e d e n i t i o n
o f c o n v e x h u l l s .
T h e r e f o r e , t h e b o u n d a r y o f t h e c o n v e x h u l l C H ( S ) m u s t c o n s i s t o f a
n i t e s e t G o f l i n e s e g m e n t s o f w h i c h t h e e n d - p o i n t s a r e p o i n t s i n t h e s e t
S . S u p p o s e t h a t a l i n e s e g m e n t p
1
p
2
i s o n t h e b o u n d a r y o f C H ( S ) . W i t h o u t
l o s s o f g e n e r a l i t y , w e c a n s u p p o s e t h a t t h e p o i n t s o f t h e s e t S a r e o n o u r l e f t
w h e n w e t r a v e l a l o n g t h e s t r a i g h t l i n e L t h r o u g h p
1
a n d p
2
i n t h e d i r e c t i o n
f r o m p
1
t o p
2
. N o w i f w e r o t a t e t h e l i n e L c o u n t e r c l o c k w i s e a r o u n d t h e p o i n t
p
2
, t h e l i n e L w i l l e v e n t u a l l y h i t a r s t p o i n t p
3
o f t h e s e t S . I t i s o b v i o u s
t o s e e t h a t n o w t h e l i n e s e g m e n t p
2
p
3
i s a l s o o n t h e b o u n d a r y o f C H ( S )
M o r e o v e r , t h e r e i s n o o t h e r p o i n t p i n S t h a t c a n m a k e t h e l i n e s e g m e n t p
2
p
o n t h e b o u n d a r y o f C H ( S ) i f w e a s s u m e t h a t n o t h r e e p o i n t s i n t h e s e t S a r e
c o - l i n e a r ( t h e p r o o f c a n b e m o d i e d p r o p e r l y f o r t h e g e n e r a l c a s e ) , s i n c e t h e
p o i n t s p
1
a n d p
3
m u s t l i e o n d i e r e n t s i d e s o f t h e s t r a i g h t l i n e t h r o u g h p
2
p
N o w b a s e d o n t h e n e w l i n e a n d t h e h u l l v e r t e x p
3
, w e c a n n d t h e n e x t h u l l
v e r t e x , e t c . . T h i s p r o c e s s m u s t b e s t o p p e d e v e n t u a l l y s i n c e t h e r e a r e o n l y
n i t e n u m b e r o f p o i n t s i n t h e s e t S . T h e r e f o r e , w e w i l l e v e n t u a l l y h i t a p o i n t
p i n t h e s e t S t h a t h a s b e e n d e c i d e d e a r l i e r t o b e a h u l l v e r t e x . T h e p o i n t p
m u s t b e t h e p o i n t p
1
s i n c e a l l o t h e r h u l l v e r t i c e s f o u n d h a v e a l r e a d y h a d t h e
t w o l i n e s e g m e n t s i n c i d e n t o n t h e m , w h i c h a r e o n t h e b o u n d a r y o f C H ( S )
T h e r e f o r e , w e h a v e e n c l o s e d t h e p o i n t s o f t h e s e t S b y a c l o s e d s i m p l e c y c l e ,
w h i c h i s a s i m p l e p o l y g o n P = f p
1
p
2
p
k
g . N o p o i n t p i n t h e i n t e r i o r o f
P c a n b e o n t h e b o u n d a r y o f C H ( S ) s i n c e a n y s t r a i g h t l i n e t h r o u g h t h e p o i n t
p w i l l i n t e r s e c t w i t h a b o u n d a r y e d g e o f t h e p o l y g o n P , t h u s h a v e p o i n t s i n
-
8/23/2019 Computational Geometry Methods and Applications - Chen
27/227
2 6 G E O M E T R I C P R E L I M I N A R I E S
t h e s e t S o n b o t h o f i t s s i d e s . T h e r e f o r e , t h e s i m p l e p o l y g o n P i s t h e c o n v e x
h u l l C H ( S )
3 . 2 P r o x i m i t y p r o b l e m s
T h e e x a m p l e s o f p r o x i m i t y p r o b l e m s i n c l u d e C L O S E S T - P A I R , A L L -
N E A R E S T - N E I G H B O R S , E U C L I D E A N - M I N I M U M - S P A N N I N G - T R E E ,
T R I A N G U L A T I O N , a n d M A X I M U M - E M P T Y - C I R C L E .
P r o x i m i t y p r o b l e m s a r i s e i n m a n y a p p l i c a t i o n s w h e r e p h y s i c a l o r m a t h -
e m a t i c a l o b j e c t s a r e r e p r e s e n t e d a s p o i n t s i n s p a c e . E x a m p l e s i n c l u d e t h e
f o l l o w i n g :
c l u s t e r i n g : a n u m b e r o f e n t i t i e s a r e g r o u p e d t o g e t h e r i f t h e y a r e s u f -
c i e n t l y c l o s e t o o n e a n o t h e r
c l a s s i c a t i o n : a n e w p a t t e r n t o b e c l a s s i e d i s a s s i g n e d t o t h e c l a s s o f
i t s c l o s e s t ( c l a s s i e d ) n e i g h b o r a n d
a i r - t r a c c o n t r o l : t h e t w o a i r p l a n e s t h a t a r e c l o s e s t a r e t h e t w o m o s t
i n d a n g e r .
W e w i l l r e s t r i c t o u r s e l v e s t o 2 - d i m e n s i o n s . T h e i n p u t t o t h e s e p r o b l e m s
i s a s e t S o f n p o i n t s i n t h e p l a n e . T h e d i s t a n c e b e t w e e n p o i n t s i n S w i l l b e
t h e E u c l i d e a n d i s t a n c e b e t w e e n t h e p o i n t s .
C L O S E S T - P A I R
F i n d a p a i r o f p o i n t s i n t h e s e t S w h i c h a r e c l o s e s t .
A L L - N E A R E S T - N E I G H B O R S
F o r e v e r y p o i n t i n t h e s e t S , n d a p o i n t t h a t i s n e a r e s t t o i t .
E U C L I D E A N - M I N I M U M - S P A N N I N G - T R E E
F i n d a n i n t e r c o n n e c t i n g t r e e o f m i n i m u m t o t a l l e n g t h w h o s e v e r t i c e s
a r e t h e p o i n t s i n t h e s e t S
T R I A N G U L A T I O N
J o i n t h e p o i n t s i n t h e s e t S b y n o n - i n t e r s e c t i n g s t r a i g h t l i n e s e g m e n t s
s o t h a t e v e r y r e g i o n i n t e r i o r t o t h e c o n v e x h u l l o f S i s a t r i a n g l e .
-
8/23/2019 Computational Geometry Methods and Applications - Chen
28/227
P R O X I M I T Y P R O B L E M S 2 7
H ( p , p )i j p pi jF i g u r e 3 . 1 : T h e p o i n t s t h a t a r e c l o s e r t o p
i
t h a n t o p
j
M A X I M U M - E M P T Y - C I R C L E
F i n d a l a r g e s t c i r c l e c o n t a i n i n g n o p o i n t s o f t h e s e t S y e t w h o s e c e n t e r
i s i n t e r i o r t o t h e c o n v e x h u l l o f S
T h e p r o b l e m s p o s e d a b o v e a r e r e l a t e d i n t h e s e n s e t h a t t h e y a l l d e a l w i t h
t h e r e s p e c t i v e d i s t a n c e s a m o n g p o i n t s i n t h e p l a n e . I n t h e f o l l o w i n g , w e w i l l
i n t r o d u c e a s i n g l e g e o m e t r i c s t r u c t u r e , c a l l e d t h e V o r o n o i d i a g r a m , w h i c h
c o n t a i n s a l l o f t h e r e l e v a n t p r o x i m i t y i n f o r m a t i o n i n o n l y l i n e a r s p a c e .
L e t u s g e t s o m e m o t i v a t i o n f r o m t h e C L O S E S T - P A I R p r o b l e m . L e t S
b e a s e t o f n p o i n t s i n t h e p l a n e . F o r a n y t w o p o i n t s p
i
a n d p
j
i n S , t h e s e t o f
p o i n t s c l o s e r t o p
i
t h a n t o p
j
i s j u s t t h e h a l f - p l a n e c o n t a i n i n g p
i
t h a t i s d e n e d
b y t h e p e r p e n d i c u l a r b i s e c t o r o f t h e s e g m e n t p
i
p
j
. S e e F i g u r e 3 . 1 . D e n o t e
t h i s h a l f - p l a n e b y H ( p
i
p
j
) ( n o t e t h a t H ( p
i
p
j
) 6= H ( p
j
p
i
) ) . T h e r e f o r e , t h e
s e t V
i
o f p o i n t s i n t h e p l a n e t h a t a r e c l o s e r t o t h e p o i n t p
i
t h a n t o a n y o t h e r
p o i n t s i n t h e s e t S i s t h e i n t e r s e c t i o n o f t h e s e t s H ( p
i
p
j
) f o r a l l p
j
2 S ; f p
i
g
V
i
=
\
j 6= i
H ( p
i
p
j
)
E a c h H ( p
i
p
j
) i s a h a l f - p l a n e s o i t i s c o n v e x . B y T h e o r e m 3 . 1 . 1 , t h e s e t
V
i
, w h i c h i s t h e i n t e r s e c t i o n o f t h e s e c o n v e x s e t s H ( p
i
p
j
) , i s a l s o c o n v e x . I t
i s a l s o e a s y t o s e e t h a t t h e s e t V
i
i s i n f a c t a c o n v e x p o l y g o n a l r e g i o n . O b s e r v e
-
8/23/2019 Computational Geometry Methods and Applications - Chen
29/227
2 8 G E O M E T R I C P R E L I M I N A R I E S
t h a t e v e r y p o i n t i n t h e p l a n e m u s t b e l o n g t o s o m e r e g i o n V
i
. M o r e o v e r , n o
s e t V
i
c a n b e e m p t y s i n c e a l l p o i n t s i n a s m a l l e n o u g h d i s c c e n t e r e d a t t h e
p o i n t p
i
m u s t b e i n V
i
T h u s t h e s e n c o n v e x p o l y g o n a l r e g i o n s V
1
, V
2
, , V
n
p a r t i t i o n t h e p l a n e
i n t o a c o n v e x n e t . M o t i v a t e d b y t h i s d i s c u s s i o n , w e i n t r o d u c e t h e f o l l o w i n g
d e n i t i o n .
D e n i t i o n A V o r o n o i d i a g r a m o f a s e t S = f p
1
p
n
g o f n p l a n a r p o i n t s
i s a p a r t i t i o n o f t h e p l a n e i n t o n r e g i o n s V
1
, V
2
, , V
n
s u c h t h a t a n y p o i n t
i n t h e r e g i o n V
i
i s c l o s e r t o t h e p o i n t p
i
t h a n t o a n y o t h e r p o i n t i n t h e s e t
S
T h e c o n v e x p o l y g o n a l r e g i o n V
i
i s c a l l e d t h e V o r o n o i p o l y g o n o f t h e p o i n t
p
i
i n S . T h e v e r t i c e s o f t h e d i a g r a m a r e c a l l e d V o r o n o i v e r t i c e s a n d t h e l i n e
s e g m e n t s o f t h e d i a g r a m a r e c a l l e d V o r o n o i e d g e s . T h e V o r o n o i d i a g r a m o f
a s e t S i s d e n o t e d b y V o r ( S ) . N o t e t h a t V o r o n o i v e r t i c e s a r e i n g e n e r a l n o t
t h e p o i n t s i n t h e s e t S
3 . 3 I n t e r s e c t i o n s
I n t e r s e c t i o n p r o b l e m s a n d t h e i r v a r i a t i o n s a r i s e i n m a n y d i s c i p l i n e s , s u c h a s
a r c h i t e c t u r a l d e s i g n , c o m p u t e r g r a p h i c s , p a t t e r n r e c o g n i t i o n , e t c . A n a r c h i -
t e c t u r a l d e s i g n c a n n o t p l a c e t w o i n t e r p e n e t r a b l e o b j e c t s t o s h a r e a c o m m o n
r e g i o n . W h e n d i s p l a y i n g o b j e c t s o n a 2 - d i m e n s i o n a l d i s p l a y d e v i c e , o b s c u r e d
p o r t i o n s ( o r i n t e r s e c t i n g p o r t i o n s ) s h o u l d b e e l i m i n a t e d t o e n h a n c e r e a l i s m ,
a l o n g s t a n d i n g p r o b l e m k n o w n a s h i d d e n l i n e / s u r f a c e e l i m i n a t i o n p r o b l e m
1 9 ] . I n i n t e g r a t e d c i r c u i t d e s i g n t w o d i s t i n c t c o m p o n e n t s m u s t b e s e p a r a t e d
b y a c e r t a i n d i s t a n c e , a n d t h e d e t e c t i o n o f w h e t h e r o r n o t t h e s e p a r a t i o n
r u l e i s o b e y e d c a n b e c a s t a s a n i n s t a n c e o f i n t e r s e c t i o n p r o b l e m s s i n c e t h e
t a s k m a y i n v o l v e t h o u s a n d s o f o b j e c t s , f a s t a l g o r i t h m s f o r d e t e c t i n g o r r e -
p o r t i n g i n t e r s e c t i n g o r o v e r l a p p i n g o b j e c t s a r e n e e d e d . A n o t h e r m o t i v a t i o n
f o r s t u d y i n g t h e c o m p l e x i t y o f i n t e r s e c t i o n a l g o r i t h m s i s t h a t l i g h t m a y b e
s h e d o n t h e i n h e r e n t c o m p l e x i t y o f f u n d a m e n t a l g e o m e t r i c p r o b l e m s . F o r
e x a m p l e , h o w d i c u l t i s i t t o d e c i d e i f a g i v e n p o l y g o n w i t h n v e r t i c e s i s
s i m p l e o r h o w m u c h t i m e i s n e e d e d t o d e t e r m i n e i f a n y t w o o f n g i v e n o b j e c t s
i n t h e p l a n e , s u c h a s p o l y g o n s , l i n e s e g m e n t s , e t c . , i n t e r s e c t ?
W e l i s t a f e w t y p i c a l g e o m e t r i c i n t e r s e c t i o n p r o b l e m s .
S E G M E N T I N T E R S E C T I O N
-
8/23/2019 Computational Geometry Methods and Applications - Chen
30/227
S E A R C H I N G 2 9
G i v e n n l i n e s e g m e n t s i n t h e p l a n e , n d a l l i n t e r s e c t i o n s .
H A L F - P L A N E I N T E R S E C T I O N
G i v e n n h a l f - p l a n e s i n t h e p l a n e , c o m p u t e t h e i r c o m m o n i n t e r s e c t i o n .
P O L Y G O N I N T E R S E C T I O N
G i v e n t w o p o l y g o n s P a n d Q w i t h m a n d n v e r t i c e s , r e s p e c t i v e l y , c o m -
p u t e r t h e i r i n t e r s e c t i o n .
3 . 4 G e o m e t r i c s e a r c h i n g
T h i s g e o m e t r i c p r o b l e m i s w e l l m o t i v a t e d b y t h e f o l l o w i n g P o s t O c e P r o b -
l e m p r o p o s e d b y K n u t h 1 4 ] : G i v e n a x e d m a p o f n p o s t o c e s , f o r a n
a r b i t r a r y q u e r y p o i n t , w h i c h i s t h e n e a r e s t p o s t o c e ? T h e s o l u t i o n t o t h i s
p r o b l e m i s s i m p l e : c o m p a r e t h e d i s t a n c e b e t w e e n t h e q u e r y p o i n t a n d e a c h
p o s t o c e a n d n d t h e n e a r e s t o n e . T h e t i m e c o m p l e x i t y o f t h i s a l g o r i t h m
i s o b v i o u s l y O ( n ) . I t i s a l s o e a s y t o s e e t h a t t o n d t h e n e a r e s t p o s t o c e , a t
l e a s t n c o m p a r i s o n s a r e n e e d e d , s i n c e i f t h e a l g o r i t h m d o e s n o t c o m p u t e t h e
d i s t a n c e b e t w e e n t h e q u e r y p o i n t a n d s o m e p o s t o c e , t h e n w e a r e a l w a y s
a b l e t o c o n s t r u c t a n i n p u t i n s t a n c e s u c h t h a t t h e q u e r y p o i n t i s c l o s e s t t o t h e
u n c o m p a r e d p o s t o c e s o t h a t t h e a l g o r i t h m o u t p u t s a n i n c o r r e c t a n s w e r .
T h e r e f o r e , f o r a s i n g l e q u e r y p o i n t , t h e a b o v e s i m p l e a l g o r i t h m i s a c t u a l l y
o p t i m a l .
O n t h e o t h e r h a n d , s u p p o s e t h a t w e h a v e , s a y , n q u e r y p o i n t s a n d w e
a r e a s k i n g t h e n e a r e s t p o s t o c e f o r e a c h q u e r y p o i n t . I f w e a g a i n a p p l y
t h e a b o v e a l g o r i t h m , t h e n i t t a k e s t i m e O ( n ) t o n d t h e n e a r e s t p o s t o c e
f o r e a c h q u e r y p o i n t , s o t o t a l l y w e n e e d t i m e O ( n
2
) t o n d t h e n e a r e s t p o s t
o c e s f o r a l l q u e r y p o i n t s . N o w i t s e e m s t h a t t h e t i m e O ( n
2
) i s n o t n e c e s s a r y .
F o r e x a m p l e , a f t e r w e h a v e c o m p u t e d t h e d i s t a n c e b e t w e e n t h e r s t q u e r y
p o i n t a n d e a c h o f t h e p o s t o c e a n d f o u n d t h e n e a r e s t p o s t o c e f o r t h e
r s t q u e r y p o i n t , i t s e e m s t h a t w e c a n s a v e s o m e i n f o r m a t i o n a b o u t t h e p o s t
o c e s a n d u s e t h i s i n f o r m a t i o n t o s p e e d u p t h e c o m p u t a t i o n o f n e a r e s t p o s t
o c e f o r t h e l a t t e r q u e r y p o i n t s . E v e n m o r e c l e v e r l y , w e c a n r s t o r g a n i z e
t h e p o s t o c e s i n t o a n e a s y - s e a r c h s t r u c t u r e s u c h t h a t s e a r c h i n g t h e n e a r e s t
p o s t o c e f o r e a c h q u e r y p o i n t c a n b e d o n e v e r y e c i e n t l y o n t h e o r g a n i z e d
s t r u c t u r e .
O n e c a n d i d a t e o f t h e s e s m a r t s t r u c t u r e s i s t h e V o r o n o i d i a g r a m , i n t r o -
d u c e d i n S e c t i o n 2 . 2 . G i v e n n p o s t o c e s , r e g a r d i n g t h e m a s a s e t S o f n
-
8/23/2019 Computational Geometry Methods and Applications - Chen
31/227
3 0 G E O M E T R I C P R E L I M I N A R I E S
p o i n t s i n t h e p l a n e , w e r s t c o n s t r u c t t h e V o r o n o i d i a g r a m V o r ( S ) f o r t h e
s e t S . T h e n n d i n g t h e n e a r e s t p o s t o c e f o r a q u e r y p o i n t i s r e d u c e d t o
l o c a t i n g t h e q u e r y p o i n t i n a V o r o n o i p o l y g o n o f V o r ( S )
T h i s i s a t y p i c a l g e o m e t r i c s e a r c h i n g p r o b l e m , c a l l e d p o i n t l o c a t i o n p r o b -
l e m : S u p p o s e t h a t w e h a v e a s u b d i v i s i o n G o f t h e p l a n e a n d w e w a n t t o k n o w
i n w h i c h r e g i o n o f G a g i v e n q u e r y p o i n t i s l o c a t e d . I n t h e s i m p l e s t c a s e , w e
h a v e o n l y o n e q u e r y p o i n t . T h e n w e c a n s e a r c h t h e p o i n t i n e a c h r e g i o n o f
G d i r e c t l y t o n d t h e r e g i o n c o n t a i n i n g t h e p o i n t . A o n e - t i m e q u e r y o f t h i s
t y p e i s c a l l e d s i n g l e s h o t . H o w e v e r , w e m a y h a v e m a n y q u e r y p o i n t s a n d
w a n t t o n d t h e c o n t a i n i n g r e g i o n f o r e a c h q u e r y p o i n t . S u c h q u e r i e s a r e
c a l l e d r e p e t i t i v e - m o d e q u e r i e s
I n t h e c a s e o f r e p e t i t i v e - m o d e q u e r i e s , i t m a y b e w o r t h w h i l e t o a r r a n g e
t h e s u b d i v i s i o n G i n t o a m o r e o r g a n i z e d s t r u c t u r e t o f a c i l i t a t e s e a r c h i n g .
T h e r e f o r e , w h e n w e a r e c o n s i d e r i n g t h e p r o b l e m o f r e p e t i t i v e - m o d e q u e r i e s ,
w e a r e i n t e r e s t e d i n t h r e e c o m p u t a t i o n a l r e s o u r c e s : t h e p r e p r o c e s s i n g t i m e
t h a t i s u s e d t o c o n v e r t t h e g i v e n s u b d i v i s i o n G i n t o a n o r g a n i z e d s t r u c t u r e ,
t h e s t o r a g e t h a t i s u s e d t o s t o r e t h e o r g a n i z e d s t r u c t u r e , a n d t h e q u e r y t i m e
t h a t i s n e e d e d t o l o c a t e e a c h q u e r y p o i n t .
S u p p o s e t h a t t h e i n p u t s u b d i v i s i o n G h a s n v e r t i c e s . I n g e n e r a l , w e
c a n n o t e x p e c t t h a t t h e p r e p r o c e s s i n g t i m e i s l e s s t h a n O ( n ) s i n c e e v e n r e a d -
i n g t h e i n p u t s u b d i v i s i o n G t a k e s t i m e ( n ) . S i m i l a r l y , w e c a n n o t e x p e c t
t h a t t h e s t o r a g e u s e d f o r t h e o r g a n i z e d s t r u c t u r e i s l e s s t h a n O ( n ) s i n c e
e v e n s t o r i n g t h e u n o r g a n i z e d s t r u c t u r e , t h e s u b d i v i s i o n G i t s e l f n e e d s ( n )
s p a c e . F i n a l l y , a s p o i n t e d o u t b y K n u t h 1 4 ] , a n y a l g o r i t h m f o r s e a r c h i n g
a n o r d e r e d t a b l e o f l e n g t h n b y m e a n s o f c o m p a r i s o n s c a n b e r e p r e s e n t e d
a s a b i n a r y t r e e o f n l e a v e s , t h u s i n t h e w o r s t c a s e , t h e s e a r c h i n g t i m e i s a t
l e a s t ( l o g n ) . W h i l e t h e p o i n t l o c a t i o n p r o b l e m i s c l e a r l y a g e n e r a l i z a t i o n
o f s e a r c h i n g , w e c o n c l u d e t h a t t h e q u e r y t i m e o f t h e p o i n t l o c a t i o n p r o b l e m
i s a t l e a s t ( l o g n )
-
8/23/2019 Computational Geometry Methods and Applications - Chen
32/227
C h a p t e r 4
G e o m e t r i c S w e e p i n g
G e o m e t r i c s w e e p i n g t e c h n i q u e i s a g e n e r a l i z a t i o n o f a t e c h n i q u e c a l l e d p l a n e
s w e e p i n g , t h a t i s p r i m a r i l y u s e d f o r 2 - d i m e n s i o n a l p r o b l e m s . I n m o s t c a s e s ,
w e w i l l i l l u s t r a t e t h e t e c h n i q u e f o r 2 - d i m e n s i o n a l c a s e s . T h e g e n e r a l i z a t i o n
t o h i g h e r d i m e n s i o n s i s s t r a i g h t f o r w a r d . T h i s t e c h n i q u e i s a l s o k n o w n a s t h e
s c a n - l i n e m e t h o d i n c o m p u t e r g r a p h i c s , a n d i s u s e d f o r a v a r i e t y o f a p p l i c a -
t i o n s , s u c h a s s h a d i n g , p o l y g o n l l i n g , a m o n g o t h e r s .
T h e t e c h n i q u e i s i n t u i t i v e l y s i m p l e . S u p p o s e t h a t w e h a v e a l i n e i n t h e
p l a n e . T o c o l l e c t t h e g e o m e t r i c i n f o r m a t i o n w e a r e i n t e r e s t e d i n , w e s l i d e
t h e l i n e i n s o m e w a y s o t h a t t h e w h o l e p l a n e w i l l b e \ s c a n n e d " b y t h e l i n e .
W h i l e t h e l i n e i s s w e e p i n g t h e p l a n e , w e s t o p a t s o m e p o i n t s a n d u p d a t e o u r
r e c o r d i n g . W e c o n t i n u e t h i s p r o c e s s u n t i l a l l i n t e r e s t i n g o b j e c t s a r e c o l l e c t e d .
T h e r e a r e t w o b a s i c s t r u c t u r e s a s s o c i a t e d w i t h t h i s t e c h n i q u e . O n e i s f o r
t h e s w e e p i n g l i n e s t a t u s , w h i c h i s a n a p p r o p r i a t e d e s c r i p t i o n o f t h e r e l e v a n t
i n f o r m a t i o n o f t h e g e o m e t r i c o b j e c t s a t t h e s w e e p i n g l i n e , a n d t h e o t h e r i s
f o r t h e e v e n t p o i n t s , w h i c h a r e t h e p l a c e s w e s h o u l d s t o p a n d u p d a t e o u r
r e c o r d i n g . N o t e t h a t t h e s t r u c t u r e s m a y b e i m p l e m e n t e d i n d i e r e n t d a t a
s t r u c t u r e s u n d e r v a r i o u s s i t u a t i o n s . I n g e n e r a l , t h e d a t a s t r u c t u r e s s h o u l d
s u p p o r t e c i e n t o p e r a t i o n s t h a t a r e n e c e s s a r y f o