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

  1. // segment.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 SEGMENT_H
  20. #define SEGMENT_H
  21.  
  22. #include "geom.h"  // ISA
  23.  
  24. #include "point.h" // HASA
  25.  
  26. class Line;
  27. class GeomException;
  28.  
  29. // in the 2d application, the z values must be zero.
  30.  
  31. class Segment : public Geom
  32. {
  33. public:
  34.     Point origin;           // one point
  35.     Point endpoint;
  36. public:
  37. // constructors
  38.     Segment();        
  39.     Segment(const Point&, const Point&) throw (GeomException);
  40.  
  41.     virtual ~Segment() {}
  42.  
  43. // utilities
  44.     Point Origin() const { return origin; }
  45.     Point Endpoint() const { return endpoint; }
  46.     Point U(double u) const; 
  47.     Line Support() const;
  48.     double Length() const;
  49.  
  50.     friend ostream& operator<<(ostream& os, const Segment& s);
  51.  
  52.     virtual double Distance(const Point&) const;
  53.     virtual Point Project(const Point&) const;
  54. };
  55.  
  56. #endif
  57.