00001 // GMTL is (C) Copyright 2001-2010 by Allen Bierbaum 00002 // Distributed under the GNU Lesser General Public License 2.1 with an 00003 // addendum covering inlined code. (See accompanying files LICENSE and 00004 // LICENSE.addendum or http://www.gnu.org/copyleft/lesser.txt) 00005 00006 #ifndef _GMTL_LINESEG_H_ 00007 #define _GMTL_LINESEG_H_ 00008 00009 #include <gmtl/Point.h> 00010 #include <gmtl/Vec.h> 00011 #include <gmtl/VecOps.h> 00012 #include <gmtl/Ray.h> 00013 00014 namespace gmtl { 00015 00027 template <typename DATA_TYPE> 00028 class LineSeg : public Ray<DATA_TYPE> 00029 { 00030 public: 00034 LineSeg() 00035 {} 00036 00044 LineSeg( const Point<DATA_TYPE, 3>& origin, const Vec<DATA_TYPE, 3>& dir ) 00045 : Ray<DATA_TYPE>( origin, dir ) 00046 {} 00047 00053 LineSeg( const LineSeg& ray ) : Ray<DATA_TYPE>( ray ) 00054 { 00055 } 00056 00063 LineSeg( const Point<DATA_TYPE, 3>& beg, const Point<DATA_TYPE, 3>& end ) 00064 : Ray<DATA_TYPE>() 00065 { 00066 this->mOrigin = beg; 00067 this->mDir = end - beg; 00068 } 00069 00074 DATA_TYPE getLength() const 00075 { 00076 return length(this->mDir); 00077 } 00078 }; 00079 00080 00081 // --- helper types --- // 00082 typedef LineSeg<float> LineSegf; 00083 typedef LineSeg<double> LineSegd; 00084 } 00085 00086 #endif