45#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_LINE_SEGMENT_3D_INL
46#define LASS_GUARDIAN_OF_INCLUSION_PRIM_LINE_SEGMENT_3D_INL
58template <
typename T,
class PP>
59LineSegment3D<T, PP>::LineSegment3D():
63 LASS_ASSERT(tail_.isZero());
64 LASS_ASSERT(head_.isZero());
69template <
typename T,
class PP>
70LineSegment3D<T, PP>::LineSegment3D(
const TPoint& iTail,
const TPoint& iHead):
78template <
typename T,
class PP>
79template <
typename PP2>
80LineSegment3D<T, PP>::LineSegment3D(
const LineSegment3D<T, PP2>& iOther):
88template <
typename T,
class PP>
inline
89const typename LineSegment3D<T, PP>::TPoint&
90LineSegment3D<T, PP>::tail()
const
97template <
typename T,
class PP>
inline
98typename LineSegment3D<T, PP>::TPoint&
99LineSegment3D<T, PP>::tail()
106template <
typename T,
class PP>
inline
107const typename LineSegment3D<T, PP>::TPoint&
108LineSegment3D<T, PP>::head()
const
115template <
typename T,
class PP>
inline
116typename LineSegment3D<T, PP>::TPoint&
117LineSegment3D<T, PP>::head()
127template <
typename T,
class PP>
128const typename LineSegment3D<T, PP>::TPoint
131 TParameterPolicy::enforceRange(iT, TNumTraits::zero, TNumTraits::one);
132 return tail_ + iT *
vector();
140template <
typename T,
class PP>
141const typename LineSegment3D<T, PP>::TValue
144 const TVector v =
vector();
145 const TValue t1 = dot(iPoint - tail_, v);
146 const TValue t2 = -dot(iPoint - head_, v);
147 const TValue
t = std::max(t1,t2) / (t1 + t2);
148 return t1 > t2 ?
t : TNumTraits::one -
t;
153template <
typename T,
class PP>
154const typename LineSegment3D<T, PP>::TVector
157 return head_ - tail_;
164template <
typename T,
class PP>
165const typename LineSegment3D<T, PP>::TValue
168 const TVector v =
vector();
173template <
typename T,
class PP>
174const typename LineSegment3D<T, PP>::TValue
177 oT = this->
t(iPoint);
181 return (iPoint - tail_).squaredNorm();
186 return (iPoint - head_).squaredNorm();
188 return (iPoint - this->
point(oT)).squaredNorm();
193template <
typename T,
class PP>
194const typename LineSegment3D<T, PP>::TValue
197 TParam
t = this->t(iPoint);
199 return (iPoint - tail_).squaredNorm();
201 return (iPoint - head_).squaredNorm();
202 return (iPoint - this->
point(
t)).squaredNorm();
207template <
typename T,
class PP>
208const typename LineSegment3D<T, PP>::TValue
219 return iA.tail()==iB.tail() && iA.head()==iB.head();
224template <
typename T,
class PPa,
class PPb>
bool operator!=(
const LineSegment3D<T, PPa>& iA,
const LineSegment3D<T, PPb>& iB)
232template<
typename T,
class PP>
233std::ostream& operator<<(std::ostream& ioOStream,
const LineSegment3D<T, PP>& iLineSegment)
235 LASS_ENFORCE_STREAM(ioOStream) <<
"{T=" << iLineSegment.tail() <<
", H=" << iLineSegment.head() <<
"}";
243template<
typename T,
class PP>
244io::XmlOStream& operator<<(io::XmlOStream& ioOStream,
const LineSegment3D<T, PP>& iLineSegment)
246 LASS_ENFORCE_STREAM(ioOStream)
247 <<
"<LineSegment3D>\n"
248 <<
"<tail>" << iLineSegment.tail() <<
"</tail>\n"
249 <<
"<head>" << iLineSegment.head() <<
"</head>\n"
250 <<
"</LineSegment3D>\n";
const TValue t(const TPoint &iPoint) const
Return parameter of projection of iPoint on line segment.
const TValue length() const
Return length of line segment.
const TVector vector() const
Return vector from tail to head.
const TValue distance(const TPoint &iPoint) const
Return distance of point to line segment.
const TPoint point(TParam iT) const
Return point on ray by it's parameter.
const TValue closestsPoint(const TPoint &iPoint, T &oT) const
t is parameter of closests point and return squared distance of a point to the line segment.
const TValue squaredDistance(const TPoint &iPoint) const
Return squared distance of a point to line segment.
set of geometrical primitives
Library for Assembled Shared Sources.
const TValue norm() const
Return norm of vector.