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
vcg/space

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
@ -108,8 +112,10 @@ public:
{ return _p0 + (_p1 - _p0) * t; } { return _p0 + (_p1 - _p0) * t; }
/// 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) ; }
/// return the bounding box inline PointType Direction( ) const
{ return ( _p1 - _p0) ; }
/// return the bounding box
inline Box3<ScalarType> BBox( ) const inline Box3<ScalarType> BBox( ) const
{ Box3<ScalarType> t; { Box3<ScalarType> t;
if (_p0[0]<_p1[0]) { t.min[0]=_p0[0];t.max[0]=_p1[0];} else { t.min[0]=_p1[0];t.max[0]=_p0[0];} if (_p0[0]<_p1[0]) { t.min[0]=_p0[0];t.max[0]=_p1[0];} else { t.min[0]=_p1[0];t.max[0]=_p0[0];}