8 #ifndef META_OCEAN_MATH_FINITE_LINE_3_H
9 #define META_OCEAN_MATH_FINITE_LINE_3_H
21 template <
typename T>
class FiniteLineT3;
200 explicit inline operator bool()
const;
214 template <
typename T>
216 linePoint0(T(0), T(0), T(0)),
217 linePoint1(T(0), T(0), T(0)),
218 lineDirection(T(0), T(0), T(0))
223 template <
typename T>
227 lineDirection((point1 - point0).normalizedOrZero())
232 template <
typename T>
233 template <
typename U>
241 template <
typename T>
247 template <
typename T>
253 template <
typename T>
256 ocean_assert(index <= 1u);
268 template <
typename T>
271 return (linePoint0 + linePoint1) * T(0.5);
274 template <
typename T>
277 return lineDirection;
280 template <
typename T>
283 ocean_assert(isValid());
288 template <
typename T>
291 ocean_assert(isValid());
296 template <
typename T>
299 ocean_assert(isValid());
301 return nearestPoint(point).sqrDistance(point);
304 template <
typename T>
307 ocean_assert(isValid());
309 const VectorT3<T> lineOffset(linePoint1 - linePoint0);
312 const Scalar dotProduct = lineOffset * pointOffset;
321 if (dotProduct >= lineOffset.
sqr())
327 return linePoint0 + lineDirection * (pointOffset * lineDirection);
330 template <
typename T>
336 template <
typename T>
339 ocean_assert(isValid() && right.
isValid());
344 template <
typename T>
347 return !lineDirection.isNull();
350 template <
typename T>
357 template <
typename T>
360 return !(*
this == right);
363 template <
typename T>
This class implements an finite line in 3D space.
Definition: FiniteLine3.h:68
bool operator!=(const FiniteLineT3< T > &right) const
Returns whether two line are identical up to a small epsilon.
Definition: FiniteLine3.h:358
VectorT3< T > midpoint() const
Returns the midpoint of the line.
Definition: FiniteLine3.h:269
VectorT3< T > linePoint0
First end point of the line.
Definition: FiniteLine3.h:205
const VectorT3< T > & point1() const
Returns the second end point of the line.
Definition: FiniteLine3.h:248
bool intersection(const FiniteLineT3< T > &right, VectorT3< T > &point) const
Returns the intersection pointer of two finite lines.
Definition: FiniteLine3.h:331
bool isParallel(const FiniteLineT3< T > &right) const
Returns whether two lines are parallel up to a small epsilon.
Definition: FiniteLine3.h:337
bool operator==(const FiniteLineT3< T > &right) const
Returns whether two line are identical up to a small epsilon.
Definition: FiniteLine3.h:351
bool isValid() const
Returns whether this line has valid parameters.
Definition: FiniteLine3.h:345
VectorT3< T > nearestPoint(const VectorT3< T > &point) const
Returns the point on this line nearest to an arbitrary given point.
Definition: FiniteLine3.h:305
T sqrDistance(const VectorT3< T > &point) const
Returns the square distance between the line and a given point.
Definition: FiniteLine3.h:297
bool isOnLine(const VectorT3< T > &point) const
Returns whether a given point is part of the finite line.
Definition: FiniteLine3.h:281
const VectorT3< T > & point(const unsigned int index) const
Returns the first or second end point of the line.
Definition: FiniteLine3.h:254
const VectorT3< T > & direction() const
Returns the direction of the line: normalize(point1() - point0())
Definition: FiniteLine3.h:275
FiniteLineT3()
Creates a finite line with default parameters.
Definition: FiniteLine3.h:215
VectorT3< T > linePoint1
Second end point of the line.
Definition: FiniteLine3.h:208
const VectorT3< T > & point0() const
Returns the first end point of the line.
Definition: FiniteLine3.h:242
VectorT3< T > lineDirection
Direction of the line with unit length, if the object holds valid parameters.
Definition: FiniteLine3.h:211
T Type
Definition of the used data type.
Definition: FiniteLine3.h:74
T distance(const VectorT3< T > &point) const
Returns the distance between the line and a given point.
Definition: FiniteLine3.h:289
This class implements an infinite line in 3D space.
Definition: Line3.h:70
static T sqrt(const T value)
Returns the square root of a given value.
Definition: Numeric.h:1533
static constexpr bool isEqualEps(const T value)
Returns whether a value is smaller than or equal to a small epsilon.
Definition: Numeric.h:2087
This class implements a vector with three elements.
Definition: Vector3.h:97
T sqr() const
Returns the square of the vector length.
Definition: Vector3.h:670
unsigned int sqrDistance(const char first, const char second)
Returns the square distance between two values.
Definition: base/Utilities.h:1089
FiniteLineT3< Scalar > FiniteLine3
Definition of the FiniteLine3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with si...
Definition: FiniteLine3.h:21
std::vector< FiniteLineT3< T > > FiniteLinesT3
Definition of a typename alias for vectors with FiniteLineT3 objects.
Definition: FiniteLine3.h:50
float Scalar
Definition of a scalar type.
Definition: Math.h:128
FiniteLineT3< float > FiniteLineF3
Instantiation of the LineT3 template class using a single precision float data type.
Definition: FiniteLine3.h:42
FiniteLineT3< double > FiniteLineD3
Instantiation of the LineT3 template class using a double precision float data type.
Definition: FiniteLine3.h:35
std::vector< FiniteLine3 > FiniteLines3
Definition of a vector holding FiniteLine3 objects.
Definition: FiniteLine3.h:57
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15