added Normalized flag
This commit is contained in:
parent
9215ea92e7
commit
017afe95d0
|
@ -24,11 +24,6 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
Revision 1.3 2004/03/09 16:47:32 tarini
|
|
||||||
Added "Normalize" flag
|
|
||||||
|
|
||||||
Revision 1.2 2004/03/08 19:46:47 tarini
|
|
||||||
First Version (tarini)
|
|
||||||
|
|
||||||
Revision 1.1 2004/03/08 16:15:48 tarini
|
Revision 1.1 2004/03/08 16:15:48 tarini
|
||||||
first version (tarini)
|
first version (tarini)
|
||||||
|
@ -71,26 +66,26 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// Origin
|
/// Origingin
|
||||||
PointType _ori;
|
PointType _ori;
|
||||||
|
|
||||||
/// Direction (not necessarily normalized)
|
/// Directionection (not necessarily normalized)
|
||||||
PointType _dir;
|
PointType _dir;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Members to access the origin, direction
|
/// Members to access the origin, direction
|
||||||
inline const PointType &Ori() const { return _ori; }
|
inline const PointType &Origin() const { return _ori; }
|
||||||
inline const PointType &Dir() const { return _dir; }
|
inline const PointType &Direction() const { return _dir; }
|
||||||
inline PointType &Ori() { return _ori; }
|
inline PointType &Origin() { return _ori; }
|
||||||
inline PointType &Dir() {
|
inline PointType &Direction() {
|
||||||
assert(NORM); // Direction can't be set for NORMALIZED Rays! Use SetDir instead!
|
assert(!IsNormalized()); // Directionection can't be set for NORMALIZED Lines! Use SetDirection instead!
|
||||||
return _dir;
|
return _dir;
|
||||||
}
|
}
|
||||||
/// The empty constructor
|
/// The empty constructor
|
||||||
Line3() {};
|
Line3() {};
|
||||||
/// The (origin, direction) constructor
|
/// The (origin, direction) constructor
|
||||||
LineType(const PointType &ori, const PointType &dir) {SetOri(ori); SetDir(dir);};
|
LineType(const PointType &ori, const PointType &dir) {SetOrigin(ori); SetDirection(dir);};
|
||||||
/// Operator to compare two lines
|
/// Operator to compare two lines
|
||||||
inline bool operator == ( LineType const & p ) const
|
inline bool operator == ( LineType const & p ) const
|
||||||
{ return _ori==p._ori && _dir==p._dir; }
|
{ return _ori==p._ori && _dir==p._dir; }
|
||||||
|
@ -102,16 +97,16 @@ public:
|
||||||
{ if (NORM) return ScalarType((p-_ori)*_dir);
|
{ if (NORM) return ScalarType((p-_ori)*_dir);
|
||||||
else return ScalarType((p-_ori)*_dir/_dir.SquaredNorm());
|
else return ScalarType((p-_ori)*_dir/_dir.SquaredNorm());
|
||||||
}
|
}
|
||||||
inline bool IsNorm() const {return NORM;};
|
inline bool IsNormalized() const {return NORM;};
|
||||||
///set the origin
|
///set the origin
|
||||||
inline void SetOri( const PointType & ori )
|
inline void SetOrigin( const PointType & ori )
|
||||||
{ _ori=ori; }
|
{ _ori=ori; }
|
||||||
///set the direction
|
///set the direction
|
||||||
inline void SetDir( const PointType & dir)
|
inline void SetDirection( const PointType & dir)
|
||||||
{ _dir=dir; if (NORM) _dir.Normalize(); }
|
{ _dir=dir; if (NORM) _dir.Normalize(); }
|
||||||
///set both the origina and direction.
|
///set both the origina and direction.
|
||||||
inline void Set( const PointType & ori, const PointType & dir )
|
inline void Set( const PointType & ori, const PointType & dir )
|
||||||
{ SetOri(ori); SetDir(dir); }
|
{ SetOrigin(ori); SetDirection(dir); }
|
||||||
/// calculates the point of parameter t on the line.
|
/// calculates the point of parameter t on the line.
|
||||||
inline PointType P( const ScalarType t ) const
|
inline PointType P( const ScalarType t ) const
|
||||||
{ return _ori + _dir * t; }
|
{ return _ori + _dir * t; }
|
||||||
|
@ -124,7 +119,7 @@ public:
|
||||||
/// importer for different line types
|
/// importer for different line types
|
||||||
template <class Q, bool K>
|
template <class Q, bool K>
|
||||||
inline void Import( const Line3<Q,K> & b )
|
inline void Import( const Line3<Q,K> & b )
|
||||||
{ _ori.Import( b.Ori()); _dir.Import( b.Dir());
|
{ _ori.Import( b.Origin()); _dir.Import( b.Direction());
|
||||||
if ((NORM) && (!K)) _dir.Normalize();
|
if ((NORM) && (!K)) _dir.Normalize();
|
||||||
}
|
}
|
||||||
PointType ClosestPoint(const PointType & p) const{
|
PointType ClosestPoint(const PointType & p) const{
|
||||||
|
|
Loading…
Reference in New Issue