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

  1. \bigskip
  2. \bigskip
  3. {\magonebf 6.1.1 Points (point)}
  4.  
  5. An instance of the data type $point$ is a point in the two-dimensional 
  6. plane $\real^2$. We use $(a,b)$ to denote a point with first (or x-) 
  7. coordinate $a$ and second (or y-) coordinate $b$.
  8.  
  9. \def\name{$point$}
  10. \def\type{$point$}
  11.  
  12. {\bf 1. Creation of a point }
  13.  
  14. a) \create p (real\ x,\ real\ y)
  15.  
  16. b) \create p {}
  17.  
  18.  
  19. introduces a variable \var\ of type \name\ initialized to the point
  20. $(x,y)$. Variant b) initializes \var\ to the point $(0,0)$. 
  21.  
  22.  
  23. \bigskip
  24. {\bf 2. Operations on a point p}
  25.  
  26. \medskip
  27. \+\cleartabs & \hskip 2.5truecm & \hskip 5truecm &\cr
  28. \+\op real    xcoord {}
  29.                            {returns the first coordinate of point $p$}
  30. \smallskip
  31. \+\op real    ycoord {}
  32.                            {returns the second coordinate of point $p$}
  33. \smallskip
  34. \+\op real    distance {point\ q}
  35.                            {returns the euclidean distance between $p$} 
  36. \+\nop                     { and $q$.}
  37. \smallskip
  38. \+\op real    distance {}
  39.                            {returns the euclidean distance between $p$}
  40. \+\nop                     { and $(0,0)$.}
  41. \smallskip
  42. \+\op point   translate {vector\ v} 
  43.                            {returns $p+v$, i.e., $p$ translated by vector}
  44. \+\nop                     {$v$. \precond $v$.dim() = 2.}
  45.  
  46. \vfill\eject
  47.  
  48. \+\op point   translate {real\ \alpha,\ real\ d} {}
  49. \+\nop                     {returns the point created by translating}
  50. \+\nop                     {$p$ in direction $\alpha$ by distance $d$. The} 
  51. \+\nop                     {direction is given by its angle with a}
  52. \+\nop                     {right oriented horizontal ray.}
  53. \smallskip
  54. \+\op point  rotate {point\ q,\ real\ \alpha}
  55.                         {returns the point created by a rotation of $p$}
  56. \+\nop                  {about point $q$ by angle $\alpha$.}
  57.  
  58. \bigskip
  59. {\bf 3. Operators }
  60. \medskip
  61. \+&$point\&$  &$point$ =\  $point$     &assignment\cr
  62. \smallskip
  63. \+&$bool$     &$point$ ==  $point$     &test for equality\cr
  64. \smallskip
  65. \+&$bool$     &$point$ !=  $point$     &test for inequality\cr
  66. \smallskip
  67. \+&$point$    &$point$ +\  $vector$    &translation by vector\cr
  68.  
  69. \medskip
  70. Input and output operators:
  71. \medskip
  72. \+&$ostream\&$ &$ostream << point$ &writes a point to an output stream\cr
  73. \smallskip
  74. \+&$istream\&$ &$istream >> point$ &reads the coordinates of a point (two reals)\cr
  75. \+&            &                   &from an input stream\cr
  76.  
  77.