\manpage {polygon} {} {Polygons} 
 
\definition
An instance $P$ of the data type $polygon$ is a simple polygon
in the two-dimensional plane defined by the sequence of its vertices
in clockwise order. The number of vertices is called the size
of $P$. A polygon with empty vertex sequence is called empty.
 
\creation P 
 
\create {(list\<point\>\ pl)}
   {
introduces a variable \var\ of type \name. \var\ is initialized to the
polygon with vertex sequence $pl$. \precond The vertices in $pl$ are given
in clockwise order and define a simple polygon. }
 
 
\create { }
   {
introduces a variable \var\ of type \name. \var\ is initialized to the
empty polygon. }
 
 
\operations 2.5 4.6
 
\op  list\<point\> vertices {()}
           {  returns the vertex sequence of \var. }
 
 
\op  list\<segment\> segments {()}
           {  returns the sequence of bounding segments
	    of \var\ in clockwise order. }
 
 
\op  list\<point\> intersection {( segment\ s)}
           {  returns $P \cap s$ as a list of points. }
 
 
\op  list\<point\> intersection {( line\ l)}
           {  returns $P \cap l$ as a list of points. }
 
 
\op  list\<polygon\> intersection {( polygon\ Q)}
           {  returns $P \cap Q$ as a list of points. }
 
 
\op  bool inside {( point\ p)}
           {  returns true if $p$ lies inside of $P$,
	    false otherwise. }
 
 
\op  bool outside {( point\ p)}
           {  returns !\var.inside($p$). }
 
 
\opl polygon translate {(double\ a, \ double\ d)}
           {  returns the polygon created by a translation
	    of \var\ in direction $a$ by distance $d$. }
 
 
\op  polygon translate {( vector\ v)}
           {  returns $P+v$, i.e., the polygon created by
	    translating $P$ by vector $v$.\\
	    \precond $v.dim() = 2$. } 
 
 
\op  polygon rotate {( point\ q, \ double\ a)}
           {  returns the polygon created by a rotation of
	    $P$ about point $q$ by angle $a$. }
 
 
\op  int         size {()}
           {  returns the size of \var. }
 
 
\op  bool        empty {()}
           {  returns true if \var\ is empty, false otherwise. }
 
 
