Changed the interface of the interpolating function of a segment (2D and 3D) from the ambiguous P(float) to Lerp(float). Note that with the previous interface it could happen that seg.P(1) != seg.P0() just becouse seg.P(1) was the result of a lerp.
This commit is contained in:
parent
c8ef412821
commit
3bdf666e86
|
|
@ -42,7 +42,7 @@ namespace vcg {
|
|||
/**
|
||||
Templated class for 3D segment.
|
||||
This is the class for a segment in 3D space. A Segment is stored just as its two extrema (Point3).
|
||||
@param SegmentScalarType (template parameter) Specifies the type of scalar used to represent coords.
|
||||
@param SegmentScalarType (template parameter) Specifies the type of scalar used to represent coords.
|
||||
*/
|
||||
template <class SegmentScalarType >
|
||||
class Segment2
|
||||
|
|
@ -65,42 +65,42 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
/// Members to access either extrema
|
||||
/// Members to access either extrema
|
||||
inline const PointType &P0() const { return _p0; }
|
||||
inline const PointType &P1() const { return _p1; }
|
||||
inline PointType &P0() { return _p0; }
|
||||
inline PointType &P1() { return _p1; }
|
||||
/// The empty constructor
|
||||
Segment2() {};
|
||||
/// The (a,b) constructor
|
||||
Segment2(const PointType &a, const PointType &b) { _p0=a; _p1=b; };
|
||||
/// Operator to compare segments
|
||||
inline bool operator == ( SegmentType const & p ) const
|
||||
{ return _p0==p._p0 && _p1==p._p1; }
|
||||
/// Operator to dispare segments
|
||||
inline bool operator != ( SegmentType const & p ) const
|
||||
{ return _p0!=p._p0 || _p1!=p._p1; }
|
||||
/// initializes the segment with its extrema
|
||||
void Set( const PointType &a, const PointType &b)
|
||||
{ _p0=a; _p1=b;}
|
||||
/// calculates the point of parameter t on the segment.
|
||||
/// if t is in [0..1] returned point is inside the segment
|
||||
inline PointType P( const ScalarType t ) const
|
||||
{ return _p0 + (_p1 - _p0) * t; }
|
||||
/// return the middle point
|
||||
inline PointType MidPoint( ) const
|
||||
{ return ( _p0 + _p1) / ScalarType(2.0) ; }
|
||||
/// return the bounding box
|
||||
inline Box2<ScalarType> BBox( ) const
|
||||
{
|
||||
Box2<ScalarType> t;
|
||||
t.Add(_p0);
|
||||
t.Add(_p1);
|
||||
return t;
|
||||
}
|
||||
/// returns segment length
|
||||
ScalarType Length()
|
||||
{ return (_p0 - _p1).Norm(); }
|
||||
/// The empty constructor
|
||||
Segment2() {};
|
||||
/// The (a,b) constructor
|
||||
Segment2(const PointType &a, const PointType &b) { _p0=a; _p1=b; };
|
||||
/// Operator to compare segments
|
||||
inline bool operator == ( SegmentType const & p ) const
|
||||
{ return _p0==p._p0 && _p1==p._p1; }
|
||||
/// Operator to dispare segments
|
||||
inline bool operator != ( SegmentType const & p ) const
|
||||
{ return _p0!=p._p0 || _p1!=p._p1; }
|
||||
/// initializes the segment with its extrema
|
||||
void Set( const PointType &a, const PointType &b)
|
||||
{ _p0=a; _p1=b;}
|
||||
/// calculates the point of parameter t on the segment.
|
||||
/// if t is in [0..1] returned point is inside the segment
|
||||
inline PointType Lerp( const ScalarType t ) const
|
||||
{ return _p0 + (_p1 - _p0) * t; }
|
||||
/// return the middle point
|
||||
inline PointType MidPoint( ) const
|
||||
{ return ( _p0 + _p1) / ScalarType(2.0) ; }
|
||||
/// return the bounding box
|
||||
inline Box2<ScalarType> BBox( ) const
|
||||
{
|
||||
Box2<ScalarType> t;
|
||||
t.Add(_p0);
|
||||
t.Add(_p1);
|
||||
return t;
|
||||
}
|
||||
/// returns segment length
|
||||
ScalarType Length()
|
||||
{ return (_p0 - _p1).Norm(); }
|
||||
|
||||
/// returns segment length
|
||||
ScalarType Length() const
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ namespace vcg {
|
|||
/**
|
||||
Templated class for 3D segment.
|
||||
This is the class for a segment in 3D space. A Segment is stored just as its two extrema (Point3).
|
||||
@param SegmentScalarType (template parameter) Specifies the type of scalar used to represent coords.
|
||||
@param SegmentScalarType (template parameter) Specifies the type of scalar used to represent coords.
|
||||
*/
|
||||
template <class SegmentScalarType >
|
||||
class Segment3
|
||||
|
|
@ -84,7 +84,7 @@ private:
|
|||
|
||||
public:
|
||||
|
||||
/// Members to access either extrema
|
||||
/// Members to access either extrema
|
||||
inline const PointType &P0() const { return _p0; }
|
||||
inline const PointType &P1() const { return _p1; }
|
||||
inline PointType &P0() { return _p0; }
|
||||
|
|
@ -108,7 +108,7 @@ public:
|
|||
{ _p0=a; _p1=b;}
|
||||
/// calculates the point of parameter t on the segment.
|
||||
/// if t is in [0..1] returned point is inside the segment
|
||||
inline PointType P( const ScalarType t ) const
|
||||
inline PointType Lerp( const ScalarType t ) const
|
||||
{ return _p0 + (_p1 - _p0) * t; }
|
||||
/// return the middle point
|
||||
inline PointType MidPoint( ) const
|
||||
|
|
|
|||
Loading…
Reference in New Issue