45#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_2D_INL
46#define LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_2D_INL
61template <
typename T,
class NP,
class PP>
62Ray2D<T, NP, PP>::Ray2D():
66 LASS_ASSERT(support_.isZero());
67 LASS_ASSERT(direction_.isZero());
72template <
typename T,
class NP,
class PP>
73Ray2D<T, NP, PP>::Ray2D(
const TPoint& iSupport,
const TVector& iDirection):
75 direction_(iDirection)
77 NP::normalize(direction_);
82template <
typename T,
class NP,
class PP>
83Ray2D<T, NP, PP>::Ray2D(
const TPoint& iSupport,
const TPoint& iLookAt):
85 direction_(iLookAt - iSupport)
87 NP::normalize(direction_);
95template <
typename T,
class NP,
class PP>
96const typename Ray2D<T, NP, PP>::TPoint&
107template <
typename T,
class NP,
class PP>
108typename Ray2D<T, NP, PP>::TPoint&
118template <
typename T,
class NP,
class PP>
119const typename Ray2D<T, NP, PP>::TVector&
129template <
typename T,
class NP,
class PP>
132 direction_ = iDirection;
133 NP::normalize(direction_);
140template <
typename T,
class NP,
class PP>
143 direction_ = iLookAt - support_;
144 NP::normalize(direction_);
154template <
typename T,
class NP,
class PP>
155const typename Ray2D<T, NP, PP>::TPoint
158 TParameterPolicy::enforceRange(iT, TNumTraits::zero);
159 return support_ + iT * direction_;
167template <
typename T,
class NP,
class PP>
168const typename Ray2D<T, NP, PP>::TValue
171 return NP::divideBySquaredNorm(dot(iPoint - support_, direction_), direction_);
178template <
typename T,
class NP,
class PP>
179const typename Ray2D<T, NP, PP>::TVector
182 return direction_ * NP::divideBySquaredNorm(dot(iVector, direction_), direction_);
189template <
typename T,
class NP,
class PP>
190const typename Ray2D<T, NP, PP>::TVector
193 return iVector -
project(iVector);
200template <
typename T,
class NP,
class PP>
201const typename Ray2D<T, NP, PP>::TVector
204 return 2 *
project(iVector) - iVector;
212template <
typename T,
class NP,
class PP>
213const typename Ray2D<T, NP, PP>::TPoint
216 return support_ +
project(iPoint - support_);
223template <
typename T,
class NP,
class PP>
224const typename Ray2D<T, NP, PP>::TVector
227 return reject(iPoint - support_);
234template <
typename T,
class NP,
class PP>
235const typename Ray2D<T, NP, PP>::TPoint
238 return support_ +
reflect(iPoint - support_);
245template <
typename T,
class NP,
class PP>
248 const T surf = perpDot(iPoint - support_, direction_);
259template <
typename T,
class NP,
class PP>
262 return !direction_.isZero();
269template<
typename T,
class NP>
270std::ostream& operator<<(std::ostream& ioOStream,
const Ray2D<T, NP>& iRay)
272 LASS_ENFORCE(ioOStream) <<
"{S=" << iRay.
support() <<
", D=" << iRay.
direction() <<
"}";
280template<
typename T,
class NP>
283 LASS_ENFORCE_STREAM(ioOStream)
285 <<
"<support>" << iRay.support() <<
"</support>\n"
286 <<
"<direction>" << iRay.direction() <<
"</direction>\n"
Output stream for writing a selection of geometric primitives to XML files.
const TPoint point(TParam a_t) const
Return point on ray by it's parameter.
const TVector reflect(const TVector &iVector) const
Reflect vector against the axis of the ray.
bool isValid() const
Return true if ray is valid (direction isn't a zero vector).
const TVector project(const TVector &iVector) const
Project vector on the axis of the ray.
void lookAt(const TPoint &iLookAt)
Set direction from origin to look-at point.
void setDirection(const TVector &iDirection)
Set direction and normalize it if that's the policy.
const TVector & direction() const
Return direction of 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 & support() const
return origin of ray.
Side classify(const TPoint &iPoint) const
Return on what side a point is located.
const TVector reject(const TVector &iVector) const
Reject vector against the axis of the ray.
set of geometrical primitives
Side
Different sides of a surface.
@ sLeft
alias for sFront in 2D
@ sSurface
right on the surface
@ sRight
alias for sBack in 2D
Library for Assembled Shared Sources.