home *** CD-ROM | disk | FTP | other *** search
- \bigskip
- \bigskip
- {\magonebf 6.1.4 Polygons (polygon)}
-
- 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.
-
- \def\name{$polygon$}
- \def\type{$polygon$}
-
- {\bf 1. Creation of a polygon }
-
- a) \create P (list(point)\ pl)
-
- b) \create P {}
-
-
- 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. Variant b) creates the empty
- polygon and assings it to \var.
-
-
- \bigskip
- {\bf 2. Operations on a polygon P}
-
- \medskip
- \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
- \+\op list(point) vertices {}
- {returns the vertex sequence of \var.}
- \smallskip
- \+\op list(segment) segments {}
- {returns the sequence of bounding segments of}
- \+\nop {\var in clockwise order.}
- \smallskip
- \+\op list(point) intersection {line\ l}
- {returns $P \cap l$ as a list of points.}
- \smallskip
- \+\op list(point) intersection {segment\ s}
- {returns $P \cap s$ as a list of points.}
- \smallskip
- \+\op list(polygon) intersection {polygon\ Q}
- {returns $P \cap Q$ as a list of points.}
- \smallskip
- \+\op bool inside {point\ p}
- {returns true if $p$ lies inside of $P$,}
- \+\nop {false otherwise.}
- \smallskip
- \+\op bool outside {point\ p}
- {returns !\var.inside($p$).}
- \smallskip
- \+\op polygon translate {vector\ v} {}
- \+\nop {returns $P+v$, i.e., the polygon created by}
- \+\nop {translating $P$ by vector $v$. \precond $v$}
- \+\nop {has dimension 2.}
- \smallskip
- \+\op polygon translate {real\ \alpha,\ real\ d} {}
- \+\nop {returns the polygon created by a translation of }
- \+\nop {of \var\ in direction $\alpha$ by distance $d$}
- \smallskip
- \+\op polygon rotate {point\ q,\ real\ \alpha}
- {returns the polygon created by a rotation of $P$}
- \+\nop {about point $q$ by angle $\alpha$.}
- \smallskip
- \+\op real size {}
- {returns the size of \var.}
- \smallskip
- \+\op real empty {}
- {returns true if \var\ is empty, false otherwise.}
- \smallskip
-
- \vfill\eject
-
- \bigskip
- {\bf 3. Operators }
- \medskip
- \+&$polygon\&$ &$polygon$ =\ \ $polygon$ &assignment\cr
- \smallskip
- \+&$bool$ &$polygon$ == $polygon$ &test for equality\cr
- \smallskip
- \+&$bool$ &$polygon$\ !=\ $polygon$ &test for inequality\cr
-
-
-