Review the Graham Scan algorithm for computing convex hull. Rewrite he algorithm so that it produces the spiral tracing all the points instead of its convex hull.
Answer:
Normal graham scan results closed polygon:
GRAHAM-SCAN(Q)[CLRS]
let p0 be the point in Q with the minimum y-coordinate, or the leftmost such point in case of a tie
let_p1, p2, . . . , pm_ be the remaining points in Q,
sorted by polar angle in counterclockwise order around p0 (if more than one point has the same angle, remove all but the one that is farthest from p0)
PUSH(p0, S)
PUSH(p1, S)
PUSH(p2, S)
for i ← 3 to m
do while the angle formed by points NEXT-TO-TOP(S), TOP(S), and pi makes a nonleft turn
do POP(S)
PUSH(pi , S)
return S
in order to get spiral points, we need to modify the algorithm, each time the GRAHAM-SCAN(Q) finishes finding the outer points, it may not stop, but It continue to find convex Hull for the remaining points, it continues until all points are covered. The last point of each GRAHAM-SCAN(Q) must be connected to the first point of the next inner GRAHAM-SCAN(Q). the red printed letters are the modifications. Read more »





