90 likes | 247 Views
Graham Scan Triangulation. Reference. Summary. Time complexity: O(kn), k-1 is the number of concave vertices in the polygon Worst case: O(n 2 ), yet easy to implement Algorithm: Loop around polygon to cut ear Once an ear is cut, update the list of concave vertices An ear can be cut if:
E N D
Graham Scan Triangulation Reference
Summary • Time complexity: O(kn), k-1 is the number of concave vertices in the polygon • Worst case: O(n2), yet easy to implement • Algorithm: • Loop around polygon to cut ear • Once an ear is cut, update the list of concave vertices • An ear can be cut if: • Ear is at a convex vertex • Triangle does not contain any concave vertex
Algorithm Build diagonal; cut ear Check concavity of two sides of the ear; update R if necessary P: vertices in the polygon R: concave vertices in P
P={0,1,2,3,4,5} R={3,4} 2 i=2 IsAnEar(P,R,1) = F {3 in ∆012} i=3 1 3 4 5 0
P={0,1,2,3,4,5} R={3,4} 2 i=3 IsAnEar(P,R,2) = T Diagonal(1, 3) P -= {2} Check concavity of 3 and 1: R -= {3} 1 3 4 5 0
P={0,1,3,4,5} R={4} 2 i = 3 IsAnEar(P,R,1) = T {1 is convex 4 not in ∆013} Diagonal(0, 3) P -= {1} Check concavity of 3 and 0: {no-op} PRED(3) = 0 i=SUCC(3)=4 1 3 4 5 0 Never cut the ear at p0
P={0,3,4,5} R={4} 2 i = 4 IsAnEar(P,R,3) = T {3 is convex 4 not in ∆034} Diagonal(0, 4) P -= {3} Check concavity of 4 and 0: R -= {4} PRED(4) = 0 i=SUCC(4)=5 1 3 4 5 0
P={0,4,5} R={ } 2 i = 5 P is a triangle = T i=SUCC(5) = 0 1 3 4 5 0
P={0,4,5} R={ } 2 i = 0 END Triangulate 1 3 4 5 0