Next: Analysis
Up: CS4444: Project 2 -
Previous: Global Optimization
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
- This class was taken from Grace (http://www.doclsf.de/grace/).
- Grace is an Open Source Software Project.
- Grace deals with generating of direct manipulation editors.
- This is the base class for our Cookie Class and adds the following functionality.
- contains() - determines if a point/polygon is inside this polygon.
- getBounds() - gets the integer bounds of this polygon.
- intersects() - determines if the polygon is intersected by a rectangle.
- lineTo() - adds vertices to the end of a polygon.
- transform() - transforms the polygon with the given transform.(which could be rotation,translation or translation )
class Cookie extends Polygon2D
- This is a child class extended from the Polygon2D class and represents Cookie copies.
- It stores the Corners for the polygon. Methods in this class perform :
- recenter() - recenters the cookie around the origin.
- updateCorners() - labels corners within the cookie as concave or convex.
- getBestCornerComplement() - determines the best pair of corners at which cookies must be joined.
- getBestEdgeComplement() - determines the best pair of edges at which 2 convex cookies must be joined.
- overlapswith() - determines if cookies overlap after they are joined.
class AmoebaCookie extends Cookie
- This class respresents cookie aggregations. It keeps keeps references to the Cookies it absorbs.
- Methods in this class :
- transformCookie() - performs transformations(rotation/translation) so that two cookies are joined together.
- assimilate() - performs the actual assimilation of all the vertices to generate one larger Cookie.
- globallyOptimize() - performs final rotation to minimze area used
class Corner extends Point2D.Double
implements CookiePart
- This class represents a corner within a polygon. A corner is a collection of 3 consecutive vertices.
- This class provides the following methods:
- angleBisector() - determines anglebisector (Vector that bisects the angle) for the corner
- idealMeasure() - determines the wasted space that is generated when cookies are joined.
- complement() - returns the complementary corner for this corner. Actual implementation is in child class.
class ConcaveCorner extends Corner
class ConvexCorner extends Corner
- This class represents a Concave Corner within the polygon.
- This class provides the following methods:
- penetrationDepth() - determines the depth to which a concave corner can fit into a convex corner.
- complement() - returns the complementary Convex corner for this corner.
- outerangle() - returns the actual concave/convex angle.
- innerangle() - returns the inner angle.
Next: Analysis
Up: CS4444: Project 2 -
Previous: Global Optimization
Stephen Lee
2003-10-14