next up previous
Next: Analysis Up: CS4444: Project 2 - Previous: Global Optimization

Implementation

Given the vertices of a cookie shape, we created a Cookie object for each copy of each cookie shape. Each Cookie consisted of a Vector of Edge objects and a Vector of Corners. An empty AmoebaCookie object absorbs each Cookie copy by first deciding whether the Cookie's convex or concave.

If the Cookie is concave, the AmoebaCookie tries to find a pair of corners (concave and convex)that complement each other. Two corners complement each other when there is minimal wasted area when the cookie copies are joined together.If the Cookie is convex, then the AmoebaCookie tries to find a pair of convex edges that complement each other. Two edges complement each other when they are almost of the same length.

A process of transformation then follows and the AmoebaCookie absorbs the cookie copy after performing the necessary translations or rotations. The process continues until the AmoebaCookie has absorbed all the copies.

Figure 4 is a chart which shows the relationship between the classes used in this implementation.

Figure 4: Famous Frugal Amos Class Diagram

class Polygon2D implements Shape

class Cookie extends Polygon2D

class AmoebaCookie extends Cookie

class Corner extends Point2D.Double implements CookiePart

class ConcaveCorner extends Corner
class ConvexCorner extends Corner


next up previous
Next: Analysis Up: CS4444: Project 2 - Previous: Global Optimization
Stephen Lee 2003-10-14