home *** CD-ROM | disk | FTP | other *** search
- \bigskip
- \bigskip
- {\magonebf 6.1.5 Circles (circle)}
-
- An instance $C$ of the data type $circle$ is a circle in the two-dimensional
- plane, i.e., the set of points having a certain distance $r$ from a given
- point $p$. $r$ is called the radius and $p$ is called the center of $C$.
- The circle with center $(0,0)$ and radius $0$ is called the empty circle.
-
- \def\name{$circle$}
- \def\type{$circle$}
-
- {\bf 1. Creation of a circle }
-
- a) \create C (point\ p,\ real\ r)
-
- b) \create C {}
-
-
- introduces a variable $C$ of type $circle$. $C$ is initialized to the circle
- with center $p$ and radius $r$. Variant b) creates the empty circle and
- assigns it to $C$.
-
-
- \bigskip
- {\bf 2. Operations on a circle C}
-
- \medskip
- \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
- \+\op real radius {}
- {returns the radius of \var.}
- \smallskip
- \+\op point center {}
- {returns the center of \var.}
- \smallskip
- \+\op list(point) intersection {line\ l}
- {returns $C \cap l$ as a list of points.}
- \smallskip
- \+\op list(point) intersection {segment\ s}
- {returns $C \cap s$ as a list of points.}
- \smallskip
- \+\op list(point) intersection {circle\ D}
- {returns $C \cap D$ as a list of points.}
- \smallskip
- \+\op segment left\_tangent {point\ p}
- {returns the line segment starting in $p$ tangent}
- \+\nop {to \var\ and left of segment $[p,C.center()]$.}
- \smallskip
- \+\op segment right\_tangent {point\ p}
- {returns the line segment starting in $p$ tangent}
- \+\nop {to \var\ and right of segment $[p,C.center()]$.}
- \smallskip
- \+\op real distance {point\ p}
- {returns the distance between \var\ and $p$}
- \+\nop {(negative if $p$ inside \var).}
- \smallskip
- \+\op real distance {line\ l}
- {returns the distance between \var\ and $l$ }
- \+\nop {(negative if $l$ intersects \var).}
- \smallskip
- \+\op real distance {circle\ D}
- {returns the distance between \var\ and $D$}
- \+\nop {(negative if $D$ intersects \var).}
- \smallskip
- \+\op bool inside {point\ p}
- {returns true if $P$ lies inside of \var,}
- \+\nop {false otherwise.}
- \smallskip
- \+\op bool outside {point\ p}
- {returns !\var.inside($p$).}
- \smallskip
- \+\op circle translate {vector\ v}
- {returns $C+v$, i.e., the circle created by}
- \+\nop {translating $C$ by vector $v$. \precond }
- \+\nop {$v$.dim = 2.}
- \smallskip
- \+\op circle translate {real\ \alpha,\ real\ d} {}
- \+\nop {returns the circle created by a translation of $C$}
- \+\nop {in direction $\alpha$ by distance $d$.}
- \smallskip
- \+\op circle rotate {point\ q,\ real\ \alpha}
- {returns the circle created by a rotation of $C$}
- \+\nop {about point $q$ by angle $\alpha$.}
- \smallskip
-
- \bigskip
- {\bf 3. Operators }
- \medskip
- \+&$circle\&$ &$circle$ =\ \ $circle$ &assignment\cr
- \smallskip
- \+&$bool$ &$circle$ == $circle$ &test for equality\cr
- \smallskip
- \+&$bool$ &$circle$\ !=\ $circle$ &test for inequality\cr
-
-