home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / diverses / leda / man / line.tex < prev    next >
Encoding:
Text File  |  1991-11-15  |  3.6 KB  |  103 lines

  1. \bigskip
  2. \bigskip
  3. {\magonebf 6.1.3 Straight Lines (line)}
  4.  
  5. An instance $l$ of the data type $line$ is a directed straight line 
  6. in the two-dimensional plane. The angle between a right oriented horizontal 
  7. line and $l$ is called the direction of $l$. 
  8.  
  9. \def\name{$line$}
  10. \def\type{$line$}
  11.  
  12. {\bf 1. Creation of a line }
  13.  
  14. a) \create l (point\ p,\ point\ q)
  15.  
  16. b) \create l (segment\ s)
  17.  
  18. c) \create l (point\ p,\ real\ \alpha)
  19.  
  20. d) \create l {}
  21.  
  22.  
  23.  
  24. introduces a variable \var\ of type \name. \var\ is initialized to the line 
  25. passing through points $p$ and $q$ directed form $p$ to $q$ (variant a), to 
  26. the line supporting segment $s$ (variant b), to the line passing through point 
  27. $p$ with direction $\alpha$ (variant c), or a line through $(0,0)$ with 
  28. direction 0 (variant d).
  29.  
  30. \bigskip
  31. {\bf 2. Operations on a line \var}
  32.  
  33. \medskip
  34. \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
  35. \+\op real   direction {} 
  36.                         {returns the direction of \var.}
  37. \smallskip
  38. \+\op real   angle {line\ g} 
  39.                         {returns the angle between \var\ and $g$, i.e.,}
  40. \+\nop                  {$g$.direction() - \var.direction().}
  41. \smallskip
  42. \+\op real   angle {} 
  43.                         {returns \var.direction().}
  44. \smallskip
  45. \+\op bool   horizontal {} 
  46.                         {returns true iff \var\ is horizontal.}
  47. \smallskip
  48. \+\op bool   vertical {} 
  49.                         {returns true iff \var\ is vertical.}
  50. \smallskip
  51. \+\op real   slope {}
  52.                         {returns the slope of \var.}
  53. \+\nop                  {\precond  \var\  is not vertical.}
  54. \smallskip
  55. \+\op real   y\_proj {real\ x}        
  56.                        {returns $p$.ycoord(), where $p \in l$ with $p$.xcoord()}
  57. \+\nop                 {= $x$. \precond \var\ is not vertical.}
  58. \smallskip
  59. \+\op real   x\_proj {real\ y}        
  60.                        {returns $p$.xcoord(), where $p \in l$ with $p$.ycoord()}
  61. \+\nop                 {= $y$. \precond \var\ is not horizontal.}
  62. \smallskip
  63. \+\op real   y\_abs {}
  64.                         {returns the y-abscissa of \var\ (\var.y\_proj(0)).}
  65. \+\nop                  {\precond  \var\  is not vertical.}
  66. \smallskip
  67. \+\op bool   intersection {line\ g,\ point\&\ p} {}
  68. \+\nop                     {if $l$ and $g$ are not collinear and intersect the}
  69. \+\nop                     {intersection point is assigned to $p$ and true is}
  70. \+\nop                     {returned, otherwise false is returned.}
  71. \smallskip
  72. \+\op bool   intersection {segment\ s,\ point\&\ p} {}
  73. \+\nop                     {if $l$ and $s$ are not collinear and intersect the}
  74. \+\nop                     {intersection point is assigned to $p$ and true is}
  75. \+\nop                     {returned, otherwise false is returned.}
  76. \smallskip
  77. \+\op line   translate {vector\ v} {}
  78. \+\nop                     {returns $l+v$, i.e., the line created by}
  79. \+\nop                     {translating $l$ by vector $v$. \precond $v$}
  80. \+\nop                     {has dimension 2.}
  81. \smallskip
  82. \+\op line   translate {real\ alpha,\ real\ d} {}
  83. \+\nop                     {returns the line created by a translation of }
  84. \+\nop                     {\var\ in direction $\alpha$ by distance $d$.}
  85. \smallskip
  86. \+\op line  rotate {point\ q,\ real\ \alpha}
  87.                         {returns the line created by a rotation of $l$}
  88. \+\nop                  {about point $q$ by angle $\alpha$.}
  89. \smallskip
  90. \+\op segment perpendicular {point\ p}
  91.                         {returns the nromal of $p$ with respect to \var.}
  92.  
  93. {\bf 3. Operators }
  94. \medskip
  95. \+&$line\&$    &$line$  =\ \  $line$    &assignment\cr
  96. \smallskip
  97. \+&$bool$      &$line$  ==    $line$    &test for equality\cr
  98. \smallskip
  99. \+&$bool$      &$line$\ !=\   $line$    &test for inequality\cr
  100.  
  101. \vfill\eject
  102.  
  103.