Restriction #2: A polygon must be convex

Being "convex" means that if you pick any 2 points within the polygon and connect them with a straight line, the line never goes outside the polygon. Triangles, squares, and circles are all convex. The letter "E" (as a polygon) is not convex.

This is legal:

POLYSTART
REPEAT 4 [FORWARD 150 RIGHT 90] ; a square is convex
POLYEND

This is NOT legal:

POLYSTART
REPEAT 3 [
  FORWARD 150
  RIGHT   90
]
FORWARD 50
RIGHT   90  ; error: these instruction
FORWARD 50  ;        add a cavity to the
LEFT    90  ;        polygon
FORWARD 50  ;
LEFT    90  ;
FORWARD 50  ;
RIGHT   90  ;
FORWARD 50
RIGHT   90
POLYEND

You can always break a convex polygon up into simpler concave polygons.


SourceForge.net Logo