45#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_3D_INL
46#define LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_3D_INL
61template <
typename T,
class NP,
class PP>
62Ray3D<T, NP, PP>::Ray3D():
66 LASS_ASSERT(support_.isZero());
67 LASS_ASSERT(direction_.isZero());
72template <
typename T,
class NP,
class PP>
73Ray3D<T, NP, PP>::Ray3D(
const TPoint& iSupport,
const TVector& iDirection):
75 direction_(iDirection)
77 NP::normalize(direction_);
82template <
typename T,
class NP,
class PP>
83Ray3D<T, NP, PP>::Ray3D(
const TPoint& iSupport,
const TVector& iNormalizedDirection,
86 direction_(iNormalizedDirection)
92template <
typename T,
class NP,
class PP>
93Ray3D<T, NP, PP>::Ray3D(
const TPoint& iSupport,
const TPoint& iLookAt):
95 direction_(iLookAt - iSupport)
97 NP::normalize(direction_);
102template <
typename T,
class NP,
class PP>
103template <
class NP2,
class PP2>
104Ray3D<T, NP, PP>::Ray3D(
const Ray3D<T, NP2, PP2>& iOther):
105 support_(iOther.support()),
106 direction_(iOther.direction())
108 NP::normalize(direction_);
116template <
typename T,
class NP,
class PP>
117const typename Ray3D<T, NP, PP>::TPoint&
128template <
typename T,
class NP,
class PP>
129typename Ray3D<T, NP, PP>::TPoint&
139template <
typename T,
class NP,
class PP>
140const typename Ray3D<T, NP, PP>::TVector&
150template <
typename T,
class NP,
class PP>
153 direction_ = iDirection;
154 NP::normalize(direction_);
161template <
typename T,
class NP,
class PP>
164 direction_ = iLookAt - support_;
165 NP::normalize(direction_);
175template <
typename T,
class NP,
class PP>
inline
176const typename Ray3D<T, NP, PP>::TPoint
179 TParameterPolicy::enforceRange(
t, TNumTraits::zero);
180 return TPoint(support_.x +
t * direction_.x, support_.y +
t * direction_.y, support_.z +
t * direction_.z);
188template <
typename T,
class NP,
class PP>
inline
189const typename Ray3D<T, NP, PP>::TValue
193 return NP::divideBySquaredNorm(
194 (
point.x - support_.x) * direction_.x + (
point.y - support_.y) * direction_.y + (
point.z - support_.z) * direction_.z,
203template <
typename T,
class NP,
class PP>
204const typename Ray3D<T, NP, PP>::TVector
207 return direction_ * NP::divideBySquaredNorm(dot(iVector, direction_), direction_);
214template <
typename T,
class NP,
class PP>
215const typename Ray3D<T, NP, PP>::TVector
218 return iVector -
project(iVector);
225template <
typename T,
class NP,
class PP>
226const typename Ray3D<T, NP, PP>::TVector
229 return 2 *
project(iVector) - iVector;
237template <
typename T,
class NP,
class PP>
238const typename Ray3D<T, NP, PP>::TPoint
241 return support_ +
project(iPoint - support_);
248template <
typename T,
class NP,
class PP>
249const typename Ray3D<T, NP, PP>::TVector
252 return reject(iPoint - support_);
259template <
typename T,
class NP,
class PP>
260const typename Ray3D<T, NP, PP>::TPoint
263 return support_ +
reflect(iPoint - support_);
270template <
typename T,
class NP,
class PP>
273 return !direction_.isZero();
280template<
typename T,
class NP>
281std::ostream& operator<<(std::ostream& ioOStream,
const Ray3D<T, NP>& iRay)
283 LASS_ENFORCE(ioOStream) <<
"{S=" << iRay.
support() <<
", D=" << iRay.
direction() <<
"}";
291template<
typename T,
class NP>
294 LASS_ENFORCE_STREAM(ioOStream)
296 <<
"<support>" << iRay.support() <<
"</support>\n"
297 <<
"<direction>" << iRay.direction() <<
"</direction>\n"
Output stream for writing a selection of geometric primitives to XML files.
const TVector & direction() const
Return direction of ray.
void setDirection(const TVector &iDirection)
Set direction and normalize it if that's the policy.
const TPoint & support() const
return origin of ray.
void lookAt(const TPoint &iLookAt)
Set direction from origin to look-at point.
const TVector reject(const TVector &iVector) const
Reject vector against the axis of the ray.
bool isValid() const
Return true if ray is valid (direction isn't a zero vector).
const TVector reflect(const TVector &iVector) const
Reflect vector against the axis of the ray.
const TValue t(const TPoint &iPoint) const
Return parameter of point on the ray that is the projection of the given point.
const TPoint point(TParam a_t) const
Return point on ray by it's parameter.
const TVector project(const TVector &iVector) const
Project vector on the axis of the ray.
set of geometrical primitives
Library for Assembled Shared Sources.