added Normalized flag

This commit is contained in:
mtarini 2004-03-10 15:27:48 +00:00
parent 9215ea92e7
commit 017afe95d0
1 changed files with 13 additions and 18 deletions

View File

@ -24,11 +24,6 @@
History
$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
first version (tarini)
@ -71,26 +66,26 @@ public:
private:
/// Origin
/// Origingin
PointType _ori;
/// Direction (not necessarily normalized)
/// Directionection (not necessarily normalized)
PointType _dir;
public:
/// Members to access the origin, direction
inline const PointType &Ori() const { return _ori; }
inline const PointType &Dir() const { return _dir; }
inline PointType &Ori() { return _ori; }
inline PointType &Dir() {
assert(NORM); // Direction can't be set for NORMALIZED Rays! Use SetDir instead!
inline const PointType &Origin() const { return _ori; }
inline const PointType &Direction() const { return _dir; }
inline PointType &Origin() { return _ori; }
inline PointType &Direction() {
assert(!IsNormalized()); // Directionection can't be set for NORMALIZED Lines! Use SetDirection instead!
return _dir;
}
/// The empty constructor
Line3() {};
/// 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
inline bool operator == ( LineType const & p ) const
{ return _ori==p._ori && _dir==p._dir; }
@ -102,16 +97,16 @@ public:
{ if (NORM) return ScalarType((p-_ori)*_dir);
else return ScalarType((p-_ori)*_dir/_dir.SquaredNorm());
}
inline bool IsNorm() const {return NORM;};
inline bool IsNormalized() const {return NORM;};
///set the origin
inline void SetOri( const PointType & ori )
inline void SetOrigin( const PointType & ori )
{ _ori=ori; }
///set the direction
inline void SetDir( const PointType & dir)
inline void SetDirection( const PointType & dir)
{ _dir=dir; if (NORM) _dir.Normalize(); }
///set both the origina and direction.
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.
inline PointType P( const ScalarType t ) const
{ return _ori + _dir * t; }
@ -124,7 +119,7 @@ public:
/// importer for different line types
template <class Q, bool K>
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();
}
PointType ClosestPoint(const PointType & p) const{