line.h

Go to the documentation of this file.
00001 //
00002 // line structures
00003 //
00004 // stuart meikle
00005 //Thu Mar  2 10:42:32 2000
00006 //
00007 
00008 // future improvement (?) we could make line a subclass of vector 
00009 // as a vector is a line which starts at 0,0 ! maybe vector should be a subclass of
00010 // line , etc ,etc
00011 
00012 #ifndef LINE_H
00013 #define LINE_H
00014 
00015 #include <boost/numeric/ublas/vector.hpp>
00016 #include <boost/smart_ptr.hpp>
00017 #include <list>
00018 #include "object.h"
00019 #include "angle.h"
00020 
00021 namespace mimas {
00029 class line
00030 {
00031     public:
00032   typedef boost::numeric::ublas::vector< double > Vector;
00033     private:
00034   // i don't think we'll need a co-ordinate system description for a line?
00035   // or maybe we do . i don't know. perhaps the co-ordinate system description
00036   // goes into object base class ?
00037 
00038   Vector start,end;
00039 
00040     public:
00041    line(void): start(2), end(2)
00042   {
00043   }
00044 
00045    line( double sx, double sy, double ex, double ey ): start( 2 ), end( 2 )
00046   {
00047      start(0) = sx; start(1) = sy;
00048      end  (0) = ex; end  (1) = ey;
00049   }
00050 
00051    line( const Vector &_start, const Vector &_end ):
00052      start( _start ), end( _end ) {}
00053 
00054   //WARNING ! use getVector().unit() to do a tina-like line->v command
00055    Vector getVector( void ) const
00056   {
00057      return end - start;
00058   }
00059 
00060    Vector findMidPoint(void) const
00061   {
00062      return 0.5 * ( start + end );
00063   }
00064 
00065   // vector rotate( angle a );
00066   Vector getIntersection( const line &l2, bool *on_this_line, bool *on_that_line ) const;
00067    Vector getIntersectionAngle( const line &l2, angle *retval) const;
00068   const Vector &getStart(void) const { return start; }
00069   const Vector &getEnd(void) const { return end; }
00070   Vector &getStart(void) { return start; }
00071   Vector &getEnd(void) { return end; }
00072   double length(void) const { return norm_2( end - start ); }
00073   angle getAngle( const line &l ) const;
00074   //line& operator=( const line& a );
00075 
00076 };
00077 
00079 typedef boost::shared_ptr< line > line_ptr;
00080 
00082 typedef std::list< line_ptr > line_ptr_list;
00083 
00085 typedef boost::shared_ptr< line_ptr_list > line_ptr_list_ptr;
00086 
00087 };
00088 #endif
00089 

[GNU/Linux] [Qt] [Mesa] [STL] [Lapack] [Boost] [Magick++] [Xalan-C and Xerces-C] [doxygen] [graphviz] [FFTW] [popt] [xine] [Gnuplot] [gnu-arch] [gcc] [gstreamer] [autoconf/automake/make] [freshmeat.net] [opensource.org] [sourceforge.net] [MMVL]
mimas 2.1 - Copyright Mon Oct 30 11:31:17 2006, Bala Amavasai, Stuart Meikle, Arul Selvan, Fabio Caparrelli, Jan Wedekind, Manuel Boissenin, ...