45#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_POINT_3D_INL
46#define LASS_GUARDIAN_OF_INCLUSION_PRIM_POINT_3D_INL
61template<
typename T>
inline
62Point3D<T>::Point3D() :
67 LASS_ASSERT(isZero());
72template<
typename T>
inline
73Point3D<T>::Point3D(TParam x, TParam y, TParam z) :
83template<
typename U>
inline
84Point3D<T>::Point3D(
const Point3D<U>& other):
85 x(static_cast<TValue>(other.x)),
86 y(static_cast<TValue>(other.y)),
87 z(static_cast<TValue>(other.z))
94template<
typename U>
inline
95Point3D<T>::Point3D(
const Vector3D<U>& position):
96 x(static_cast<TValue>(position.x)),
97 y(static_cast<TValue>(position.y)),
98 z(static_cast<TValue>(position.z))
105template<
typename U>
inline
106Point3D<T>::Point3D(
const U& x,
const U& y,
const U& z):
107 x(static_cast<TValue>(x)),
108 y(static_cast<TValue>(y)),
109 z(static_cast<TValue>(z))
115template <
typename T>
inline
116const typename Point3D<T>::TVector
117Point3D<T>::position()
const
119 return TVector(x, y, z);
124template<
typename T>
inline
125typename Point3D<T>::TConstReference
126Point3D<T>::operator[](
size_t index)
const
128 LASS_ASSERT(index < dimension);
129 return *(&x + index);
134template<
typename T>
inline
135typename Point3D<T>::TReference
136Point3D<T>::operator[](
size_t index)
138 LASS_ASSERT(index < dimension);
139 return *(&x + index);
146template<
typename T>
inline
147typename Point3D<T>::TConstReference
150 return *(&x + num::mod(index, dimension));
157template<
typename T>
inline
158typename Point3D<T>::TReference
161 return *(&x + num::mod(index, dimension));
167template<
typename T>
inline
168Point3D<T>& Point3D<T>::operator+=(
const TVector& offset)
178template<
typename T>
inline
179Point3D<T>& Point3D<T>::operator-=(
const TVector& offset)
189template<
typename T>
inline
190bool Point3D<T>::isZero()
const
192 return x == TNumTraits::zero && y == TNumTraits::zero && z == TNumTraits::zero;
199template<
typename T>
inline
202 return num::isNaN(x) || num::isNaN(y) || num::isNaN(z);
211template<
typename T>
inline
214 return a.x == b.x && a.y == b.y && a.z == b.z;
221template<
typename T>
inline
222bool operator!=(
const Point3D<T>& a,
const Point3D<T>& b)
231template<
typename T>
inline
232Point3D<T> operator+(
const Point3D<T>& a,
const Vector3D<T>& b)
234 Point3D<T> result(a);
243template<
typename T>
inline
255template<
typename T>
inline
267template<
typename T>
inline
270 return Vector3D<T>(a.x - b.x, a.y - b.y, a.z - b.z);
278template<
typename T>
inline
279typename Point3D<T>::TValue
distance(
const Point3D<T>& a,
const Point3D<T>& b)
281 return (a - b).norm();
286template<
typename T>
inline
289 return (a - b).squaredNorm();
300 return Point3D<T>(std::min(a.x, b.x), std::min(a.y, b.y), std::min(a.z, b.z));
308template<
typename T>
inline
309Point3D<T>
lerp(
const Point3D<T>& a,
const Point3D<T>& b,
typename Point3D<T>::TParam t)
311 return Point3D<T>(
lerp(a.position(), b.position(), t));
322 return Point3D<T>(std::max(a.x, b.x), std::max(a.y, b.y), std::max(a.z, b.z));
330std::ostream& operator<<(std::ostream& stream,
const Point3D<T>& b)
332 LASS_ENFORCE_STREAM(stream) << b.position();
343 LASS_ENFORCE_STREAM(stream)
344 <<
"<Point3D>" << b.x <<
" " << b.y <<
" " << b.z <<
"</Point3D>\n";
352std::istream& operator>>(std::istream& stream, Point3D<T>& b)
355 LASS_ENFORCE_STREAM(stream) >> temp;
356 b = Point3D<T>(temp);
Output stream for writing a selection of geometric primitives to XML files.
set of geometrical primitives
Library for Assembled Shared Sources.
bool isNaN() const
Return true if at least one of the components is NaN.
TConstReference at(signed index) const
Wrap index around range.
Point3D< T > pointwiseMax(const Point3D< T > &a, const Point3D< T > &b)
return a point with, for each coordinate, the maximum value of a and b
Point3D< T > lerp(const Point3D< T > &a, const Point3D< T > &b, typename Point3D< T >::TParam t)
interpolate linearly between two points: a + t * (b - a)
Point3D< T > pointwiseMin(const Point3D< T > &a, const Point3D< T > &b)
return a point with, for each coordinate, the minimum value of a and b
Point3D< T >::TValue distance(const Point3D< T > &a, const Point3D< T > &b)
return the distance between two points