45#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_LINE_3D_INL
46#define LASS_GUARDIAN_OF_INCLUSION_PRIM_LINE_3D_INL
61template <
typename T,
class NP>
62Line3D<T, NP>::Line3D():
66 LASS_ASSERT(support_.isZero());
67 LASS_ASSERT(direction_.isZero());
72template <
typename T,
class NP>
73Line3D<T, NP>::Line3D(
const TPoint& iSupport,
const TVector& iDirection):
75 direction_(iDirection)
77 NP::normalize(direction_);
82template <
typename T,
class NP>
83Line3D<T, NP>::Line3D(
const TPoint& iSupport,
const TPoint& iLookAt):
85 direction_(iLookAt - iSupport)
87 NP::normalize(direction_);
92template <
typename T,
class NP>
inline
93const typename Line3D<T, NP>::TPoint&
94Line3D<T, NP>::support()
const
101template <
typename T,
class NP>
inline
102typename Line3D<T, NP>::TPoint&
103Line3D<T, NP>::support()
112template <
typename T,
class NP>
inline
113const typename Line3D<T, NP>::TVector&
123template <
typename T,
class NP>
inline
126 direction_ = iDirection;
127 NP::normalize(direction_);
134template <
typename T,
class NP>
137 direction_ = iLookAt - support_;
138 NP::normalize(direction_);
146template<
typename T,
class NP>
147const typename Line3D<T, NP>::TVector
150 return reject(iPoint - support_);
159template<
typename T,
class NP>
160const typename Line3D<T, NP>::TVector
164 return iVector -
project(iVector);
171template<
typename T,
class NP>
172const typename Line3D<T, NP>::TPoint
175 return support_ +
project(iPoint - support_);
182template<
typename T,
class NP>
183const typename Line3D<T, NP>::TVector
186 return direction_ * NP::divideBySquaredNorm(dot(iVector, direction_), direction_);
193template<
typename T,
class NP>
194const typename Line3D<T, NP>::TPoint
197 return support_ +
reflect(iPoint - support_);
204template<
typename T,
class NP>
205const typename Line3D<T, NP>::TVector
208 return T(2) *
project(iVector) - iVector;
216template <
typename T,
class NP>
217const typename Line3D<T, NP>::TPoint
220 return support_ + iT * direction_;
227template <
typename T,
class NP>
228const typename Line3D<T, NP>::TValue
231 return NP::divideBySquaredNorm(dot(iPoint - support_, direction_), direction_);
238template <
typename T,
class NP>
241 return !direction_.isZero();
248template<
typename T,
class NP>
249std::ostream& operator<<(std::ostream& ioOStream,
const Line3D<T, NP>& iLine)
251 LASS_ENFORCE(ioOStream) <<
"{S=" << iLine.support() <<
", U=" << iLine.
direction() <<
"}";
259template<
typename T,
class NP>
262 LASS_ENFORCE_STREAM(ioOStream)
264 <<
"<support>" << iLine.support() <<
"</support>\n"
265 <<
"<direction>" << iLine.direction() <<
"</direction>\n"
Output stream for writing a selection of geometric primitives to XML files.
const TPoint reflect(const TPoint &iPoint) const
reflect a point orthogonally into the line.
const TPoint point(TParam iT) const
Return point on line by it's parameter.
const TVector & direction() const
Return direction of line.
const TValue t(const TPoint &iPoint) const
Return parameter of point on the line that is the projection of the given point.
void lookAt(const TPoint &iLookAt)
Set direction from support to look-at point.
void setDirection(const TVector &iDirection)
Set direction and normalize it if that's the policy.
const TPoint project(const TPoint &iPoint) const
project a point orthogonally onto the line
const TVector reject(const TPoint &iPoint) const
return the vector that, if added to the projection of iPoint, you get iPoint again.
bool isValid() const
Return true if line is valid (direction isn't a zero vector).
set of geometrical primitives
Library for Assembled Shared Sources.