00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00035
00036
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
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
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
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