Adjust vertices of optimal polygon: calculate the intersection of the two “optimal” line segments, then move it into the unit square if it lies outside. Return 1 with errno set on error; 0 on success. calculate “optimal” point-slope representation for each line segment.
Find the optimal polygon. Fill in the m and po components. Return 1 on failure with errno set, else 0. Non-cyclic version: assumes i=0 is in the polygon. Fixme: ### implement cyclic version.