Whereas locally optimizing the placement of concave shapes involved a
more stringent corner joining scheme, we attacked convex shapes from a
simpler approach. Like the concave shapes algorithm, we employ matching
between edges. Our criteria for a good pair of edges is to pick a pair
of edges between two copies of a cookie that have similiar length with
a preference for longer edges.
Once a pair of edges have been matched, FFA almost follows the same
procedure specified for joining to concave cookies. Since the direction
of edges depends on the orientation of the cookie copy, which could be
different depending on the current configuration of the cookie copies,
simply finding the angle between the two edge vectors is insufficient.
After the initial rotation, the vectors for the updated edges must be
checked to ensure that they point away from each other. Otherwise, the
two cookie copies could be sitting upon each other. By ensuring they
point away from each other, the cookies are effectively reflected along
their now common edge.
Finally, the newly attached cookie should translate away from the other cookie until no overlaps have been detected. Instead of translating away along a bisector, the newer cookie copy translates away along a vector perpendicular to other cookie's edge. This perpendicular vector needs to be checked to ensure that it does not point towards the interior of the cookie. Otherwise, the newer copy will come to rest on the wrong side of the cookie.