The Primal Algorithm

You are presented with a set of points, Q. The task is to find the lower convex hull of Q

1. Pick a point P with minimum x coordinate from the set Q.
2. Compute lines from P to all other points in the set Q.
3. Pick the point A, such that, the line from P to A has minimal slope.
4. Point A is on the convex hull.
5. Let A(n-1) = P
   Let A(n) = A
6. Compute lined from A(n) to all points in the set Q.
7. Pick the point A(n+1), such that, the angle A(n-1)A(n)A(n+1) is minimized.
8. A(n+1) is on the lower convex hull.
9. Let A(n-1)  = A(n)
   Let A(n) = A(n+1)
10. Loop to step 6 until the y coordinate of A(n) > y coordinate of P

The Dual Algorithm

You are presented with an arrangement of lines Q. The task is to determine the upper envelope of the arrangement.

1. Pick a line P such that the slope of P is minimized in the set Q.
2. Compute the intersections of P with all other lines in Q.
3. Pick the line L, such that, the intersection with P has minimum x coordinate
4. The segment of P upto that intersection point is on the upper envelope.
5. Let L(n-1) = P
   Let L(n) = L
6. Rotate and translate the coordinate system such that L(n-1) is the y-axis.
7. Compute the intersections of L(n) with all other lines in Q.
8. Pick L(n+1) such that the intersection has minimum positive x coordinate.
9. If there is no such intersection then jump to 13
10. The segment of L(n) from the previous intersection P(n-1) to P(n) is in U.E
11. Let L(n-1) = L(n)
    Let L(n) = L(n+1)
12. Loop to 6
13. DONE

The description above is a direct dualization from the primal algorithm. In more intuitive terms the process of gift wrapping dualizes to the concept of the location of an extreme segment of the upper envelope and then "walking" along succesive segments of the envelope which are defined by the points of intersection of the lines in the given arrangement.