\manpage {line} {} {Straight Lines}
 
\definition
An instance $l$ of the data type $line$ is a directed straight line
in the two-dimensional plane. The angle between a right oriented horizontal
line and $l$ is called the direction of $l$.
 
\creation l 
 
\create {(point\ p,\ point\ q)}
   {
introduces a variable \var\ of type \name. \var\ is initialized to the line
passing through points $p$ and $q$ directed form $p$ to $q$. }
 
 
\create {(segment\ s)}
   {
introduces a variable \var\ of type \name. \var\ is initialized to the line
supporting segment $s$. }
 
 
\create {(point\ p,\ double\ a)}
   {
introduces a variable \var\ of type \name. \var\ is initialized to the line
passing through point $p$ with direction $a$. }
 
 
\create { }
   {
introduces a variable \var\ of type \name. \var\ is initialized to the line
passing through the origin with direction 0. }
 
 
\operations 2 4.5 
 
\op  double direction {()}
           {  returns the direction of \var. }
 
 
\op  double angle {( line\ g)}
           {  returns the angle between \var\ and $g$, i.e.,
	    $g$.direction() - \var.direction(). }
 
 
\op  double angle {()}
           {  returns \var.direction(). }
 
 
\op  bool vertical {()}
           {  returns true iff \var\ is vertical. }
 
 
\op  bool horizontal {()}
           {  returns true iff \var\ is horizontal. }
 
 
\op  double slope {()}
           {  returns the slope of \var.\\
	    \precond  \var\  is not vertical. }
 
 
\op  double y\_proj {(double\ x)}
           {  returns $p$.ycoord(), where $p \in l$ with $p$.xcoord()
	    = $x$. \precond \var\ is not vertical. }
 
 
\op  double x\_proj {(double\ y)}
           {  returns $p$.xcoord(), where $p \in l$ with $p$.ycoord()
	    = $y$. \precond \var\ is not horizontal. }
 
 
\op  double y\_abs {()}
           {  returns the y-abscissa of \var\ (\var.y\_proj(0)).\\
	    \precond  \var\  is not vertical. }
 
 
\opl bool intersection {( line\ g, \ point\&\ inter)}
           {  if $l$ and $g$ are not collinear and intersect the
            intersection point is assigned to $inter$ and true is 
            returned, otherwise false is returned. }
 
 
\opl bool intersection {( segment\ s, \ point\&\ inter)}
           {  if $l$ and $s$ are not collinear and intersect the
	    intersection point is assigned to $inter$ and true is 
	    returned, otherwise false is returned. }
 
 
\opl line translate {(double\ a, \ double\ d)}
           {  returns the line created by a translation of
	    \var\ in direction $a$ by distance $d$. }
 
 
\op  line translate {( vector\ v)}
           {  returns $l+v$, i.e., the line created by
            translating $l$ by vector $v$.\\
	    \precond $v$.dim() = 2. } 
 
 
\opl line rotate {( point\ q, \ double\ a)}
           {  returns the line created by a rotation of $l$
	    about point $q$ by angle $a$. }
 
 
\op  line rotate {(double\ a)}
           {  returns $l$.rotate($point(0,0),\ \alpha$).  }
 
 
\op  segment perpendicular {( point\ q)}
           {  returns the normal of $p$ with respect to \var. }
 
 
\binop bool == {g}
         {  Test for equality. }
 
 
\binop bool != {g}
         {  Test for inequality. }
 
 
