added operator [] and function Direction()

This commit is contained in:
Paolo Cignoni 2012-01-18 16:45:50 +00:00
parent a61f6db8ac
commit a53887e893
1 changed files with 8 additions and 2 deletions

View File

@ -89,6 +89,10 @@ public:
inline const PointType &P1() const { return _p1; } inline const PointType &P1() const { return _p1; }
inline PointType &P0() { return _p0; } inline PointType &P0() { return _p0; }
inline PointType &P1() { return _p1; } inline PointType &P1() { return _p1; }
inline PointType &operator[] (const int i) {return i==0?_p0:_p1;}
inline const PointType &operator[] (const int i) const {return i==0?_p0:_p1;}
/// The empty constructor /// The empty constructor
Segment3() {}; Segment3() {};
/// The (a,b) constructor /// The (a,b) constructor
@ -109,6 +113,8 @@ public:
/// return the middle point /// return the middle point
inline PointType MidPoint( ) const inline PointType MidPoint( ) const
{ return ( _p0 + _p1) / ScalarType(2.0) ; } { return ( _p0 + _p1) / ScalarType(2.0) ; }
inline PointType Direction( ) const
{ return ( _p1 - _p0) ; }
/// return the bounding box /// return the bounding box
inline Box3<ScalarType> BBox( ) const inline Box3<ScalarType> BBox( ) const
{ Box3<ScalarType> t; { Box3<ScalarType> t;