160 likes | 249 Views
s 2. s 5. s 1. s 3. s 2 ’. s 3 ’. s 4. s 1 ’. s 4 ’. s 5 ’. Plane Sweep Algorithm for Line-Segment Intersection Problem. CP = E[ s 2 , s 5 , s 1 , s 3 , s 2 ’ , s 3 ’ , s 4 , s 1 ’ , s 4 ’ , s 5 ’ ] S[] I[]. CP=Current Point E=Event Queue S=Status Queue I=Intersection List.
E N D
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Plane Sweep Algorithm for Line-Segment Intersection Problem CP = E[ s2 , s5 , s1 , s3 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[] I[] CP=Current Point E=Event Queue S=Status Queue I=Intersection List
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = E[ s2 , s5 , s1 , s3 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ ] I[ ] New CP = s2 E[ s2 , s5 , s1 , s3 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 ] I[ ]
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ previous sweep line Previous CP = s2 E[ s5 , s1 , s3 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 ] I[ ] new sweep line New CP = s5 E[ s5 , s1 , s3 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 , s5 ] I[ ] Compare s2 with s5 => no intersection
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s5 E[ s1 , s3 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 , s5 ] I[ ] s21 New CP = s1 E[ s1 , s3 , s21, s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 , s1, s5 ] I[s21 ] Compare s`1 with s2 => s21 Compare s`1 with s5 => no intersection
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s1 E[ s3 , s21 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 , s1 , s5 ] I[s21 ] s21 s53 New CP = s3 E[ s3 , s53 , s21 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 , s1 , s5 , s3 ] I[s21 , s53 ] Compare s`3 with s5 => s53
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s3 E[ s53 , s21 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 , s1 , s5 , s3 ] I[s21 , s53 ] s21 s53 New CP = s53 E[ s53 , s21 , s13 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 , s1 , s3 , s5] I[s21 , s53 , s13 ] s13 Compare s`3 with s1 => s13
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s53 E[ s21 , s13 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s2 , s1 , s3 , s5 ] I[s21 , s53 , s13 ] s21 s53 New CP = s21 E[ s21 , s23 , s13 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s1 , s2, s3 , s5 ] I[s21 , s53 , s13 , s23 ] s23 s13 Compare s`2 with s3 => s23
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s21 E[ s23 , s13 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s1 , s2 , s3 , s5 ] I[s21 , s53 , s13 , s23 ] s21 s53 New CP = s23 E[ s23 , s13 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s1 , s3 , s2, s5 ] I[s21 , s53 , s13 , s23 ] s23 s13 Compare s`3 with s1 => s13 (already in the list) Compare s`2 with s5 => no intersection
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s23 E[ s13 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s1 , s3 , s2 , s5 ] I[s21 , s53 , s13 , s23 ] s21 s53 New CP = s13 E[ s13 , s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s3 , s1, s2 , s5 ] I[s21 , s53 , s13 , s23 ] s23 s13 Compare s`1 with s2 => s21 (already in the list)
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s13 E[ s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s3 , s1 , s2 , s5 ] I[s21 , s53 , s13 , s23 ] s21 s53 New CP = s2’ E[ s2’ , s3’ , s4 , s1’ , s4’ , s5’ ] S[ s3 , s1 , s2 , s5 ] I[s21 , s53 , s13 , s23 ] s23 s13 Compare s`1 with s5 => no intersection
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s2’ E[ s3’ , s4 , s1’ , s4’ , s5’ ] S[ s3 , s1 , s5 ] I[s21 , s53 , s13 , s23 ] s21 s53 New CP = s3’ E[ s3’ , s4 , s1’ , s4’ , s5’ ] S[ s3 , s1 , s5 ] I[s21 , s53 , s13 , s23 ] s23 s13
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s3’ E[ s4 , s1’ , s4’ , s5’ ] S[ s1 , s5 ] I[s21 , s53 , s13 , s23 ] s21 s53 New CP = s4 E[ s4 , s54 , s1’ , s4’ , s5’ ] S[ s1 , s5 , s4 ] I[s21 , s53 , s13 , s23 , s54 ] s23 s13 s54 Compare s`4 with s5 => s54
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s4 E[ s54 , s1’ , s4’ , s5’ ] S[ s1 , s5 , s4 ] I[s21 , s53 , s13 , s23 , s54 ] s21 s53 New CP = s54 E[ s54 , s1’ , s4’ , s5’ ] S[ s1 , s4 , s5] I[s21 , s53 , s13 , s23 , s54 ] s23 s13 s54 Compare s`4 with s1 => no intersection
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s54 E[ s1’ , s4’ , s5’ ] S[ s1 , s4 , s5 ] I[s21 , s53 , s13 , s23 , s54 ] s21 s53 New CP = s1’ E[ s1’ , s4’ , s5’ ] S[ s1 , s4 , s5 ] I[s21 , s53 , s13 , s23 , s54 ] s23 s13 s54
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s1’ E[ s4’ , s5’ ] S[ s4 , s5 ] I[s21 , s53 , s13 , s23 , s54 ] s21 s53 New CP = s4’ E[ s4’ , s5’ ] S[ s4 , s5 ] I[s21 , s53 , s13 , s23 , s54 ] s23 s13 s54
s2 s5 s1 s3 s2’ s3’ s4 s1’ s4’ s5’ Previous CP = s4’ E[ s5’ ] S[ s5 ] I[s21 , s53 , s13 , s23 , s54 ] s21 s53 New CP = s5’ E[ s5’ ] S[ s5 ] I[s21 , s53 , s13 , s23 , s54 ] s23 s13 s54 Event Queue Is Empty, therefore STOP