next up previous
Next: Concave Shapes Up: Method Previous: Method

Local Optimization

Before our algorithm branches, given a cookie shape, we determine whether the corners of a shape are convex or concave. We first classify each corner of the shape as either convex or concave. In order to do this, our player traverses the vertices of the shape. During the traversal, the interior of the polygon should remain on either the left or right side. Likewise, if we form a triangle whose vertices are those of a corner, upon a traversal of the triangle, we can determine if the interior of the triangle stays on the left or right side. If the interiors of the both the polygon and the triangle lie on different sides, then, the angle is concave. Otherwise, the corner is convex.

Numerically, we can determine which the interior side by intergrating at each vertex [Rusin1995]. The integral for a vertex, $V_i$, and polygon follow.


\begin{displaymath}
A_i = P_i^y P_{i-1}^y - P_i^x P_{i-1}^x
\end{displaymath} (1)


\begin{displaymath}
A_{polygon} = \sum_{i=0}^{N-1} A_i
\end{displaymath} (2)

If the signs of $A_{polygon}$ differs from the $A_{corner}$, then the corner is concave. Otherwise, it is convex.

Furthermore, if all the corners of a shape are convex, we run our Convex Shape Local Optimization algorithm. Otherwise, we apply the Concave Shape routine on the given shape.



Subsections
next up previous
Next: Concave Shapes Up: Method Previous: Method
Stephen Lee 2003-10-14