home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / freedraft.tar.gz / freedraft.tar / FREEdraft-050298 / GEOMLIB2D / line.h < prev    next >
C/C++ Source or Header  |  1998-04-29  |  2KB  |  57 lines

  1. // line.h
  2.  
  3. // Copyright (C) 1997  Cliff Johnson                                       //
  4. //                                                                         //
  5. // This program is free software; you can redistribute it and/or           //
  6. // modify it under the terms of the GNU  General Public                    //
  7. // License as published by the Free Software Foundation; either            //
  8. // version 2 of the License, or (at your option) any later version.        //
  9. //                                                                         //
  10. // This software is distributed in the hope that it will be useful,        //
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of          //
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       //
  13. // General Public License for more details.                                //
  14. //                                                                         //
  15. // You should have received a copy of the GNU General Public License       //
  16. // along with this software (see COPYING); if not, write to the        //
  17. // Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. //
  18.  
  19. #ifndef LINE_H
  20. #define LINE_H
  21.  
  22. #include "geom.h"  // ISA
  23. #include "point.h" // HASA
  24.  
  25. // a line is an unlimited entity.
  26. // defined in double precision, by a point, and a 3D vector.
  27.  
  28. // in the 2d application, the z values must be zero.
  29. //
  30. class GeomException;
  31.  
  32. class Line : public Geom
  33. {
  34. public:
  35.     static double NullDist;
  36.  
  37. protected:    //data
  38.     Point origin;        // one point
  39.     Point direction;    // and a direction - always normalized
  40. public:
  41. // constructors
  42.     Line();        // default creates a horizontal line through the 
  43.     Line(const Point& o, const Point& d) throw (GeomException); // by origin and direction
  44.  
  45.     virtual ~Line() {}
  46.  
  47. // utilities
  48.     Point Origin() const { return origin; }
  49.     Point Direction() const { return direction; }
  50.     friend ostream& operator<<(ostream& os, const Line& l);
  51.  
  52.     virtual Point Project(const Point& p) const;
  53.     virtual double Distance(const Point& p) const;
  54. };
  55.  
  56. #endif
  57.