8#ifndef META_OCEAN_MATH_TRIANGLE_3_H
9#define META_OCEAN_MATH_TRIANGLE_3_H
341 if (result.
x() < 0 || result.
y() < 0 || result.
x() + result.
y() > 1)
346 distance = result.
z();
366 if (result.
x() < 0 || result.
y() < 0 || result.
x() + result.
y() > 1)
371 distance = result.
z();
373 barycentric =
VectorT3<T>(1 - result.
x() - result.
y(), result.
x(), result.
y());
392 if (result.
x() < 0 || result.
y() < 0 || result.
x() + result.
y() > 1)
397 distance = result.
z();
400 ocean_assert(normal.
isUnit());
405 ocean_assert(reflection.
isValid());
424 if (result.
x() < 0 || result.
y() < 0 || result.
x() + result.
y() > 1)
429 distance = result.
z();
432 ocean_assert(normal.
isUnit());
437 ocean_assert(reflection.
isValid());
451 ocean_assert(normal.
isUnit());
462 if (result.
x() < 0 || result.
y() < 0 || result.
x() + result.
y() > 1)
467 distance = result.
z();
472 ocean_assert(reflection.
isValid());
495 if (result.
x() < 0 || result.
y() < 0 || result.
x() + result.
y() > 1)
500 distance = result.
z();
503 ocean_assert(normal.
isUnit());
513 ocean_assert(reflection.
isValid());
536 if (result.
x() < 0 || result.
y() < 0 || result.
x() + result.
y() > 1)
541 distance = result.
z();
543 normal = (normal0 * (1 - result.
x() - result.
y()) + normal1 * result.
x() + normal2 * result.
y()).
normalizedOrZero();
544 ocean_assert(normal.
isUnit());
554 ocean_assert(reflection.
isValid());
573 barycentric =
VectorT3<T>(1 - result.
x() - result.
y(), result.
x(), result.
y());
587 ocean_assert(index <= 2u);
This class implements an infinite line in 3D space.
Definition Line3.h:69
bool isValid() const
Returns whether this line has valid parameters.
Definition Line3.h:312
const VectorT3< T > & direction() const
Returns the direction of the line.
Definition Line3.h:293
const VectorT3< T > & point() const
Returns a point on the line.
Definition Line3.h:280
static constexpr T weakEps()
Returns a weak epsilon.
static constexpr T eps()
Returns a small epsilon.
static constexpr bool isNotEqualEps(const T value)
Returns whether a value is not smaller than or equal to a small epsilon.
Definition Numeric.h:2246
This class implements a 3x3 square matrix.
Definition SquareMatrix3.h:89
bool invert()
Inverts this matrix in place.
Definition SquareMatrix3.h:1191
This class implements a 3D triangle.
Definition Triangle3.h:80
TriangleT3< T > & operator-=(const VectorT3< T > &offset)
Shifts the triangle by a given 3D vector (by subtracting the vector from all three corners of the tri...
Definition Triangle3.h:614
TriangleT3< T > & operator+=(const VectorT3< T > &offset)
Shifts the triangle by a given 3D vector (by adding the vector to all three corners of the triangle).
Definition Triangle3.h:598
const VectorT3< Scalar > & point0() const
const VectorT3< T > & operator[](const unsigned int index) const
Returns individual triangle corners.
Definition Triangle3.h:585
bool intersection(const LineT3< T > &ray, LineT3< T > &reflection, T &distance) const
Returns whether a given ray has an intersection with this triangle and determines the reflective ray ...
Definition Triangle3.h:379
bool frontIntersection(const LineT3< T > &ray, const VectorT3< T > &normal, LineT3< T > &reflection, T &distance) const
Returns whether a given ray has a front intersection with this triangle and determines the reflective...
Definition Triangle3.h:443
bool planeIntersection(const LineT3< T > &ray, VectorT3< T > &barycentric) const
Returns the intersection point with a given ray and a plane that is spanned by this triangle.
Definition Triangle3.h:560
bool frontIntersection(const LineT3< T > &ray, const VectorT3< T > &normal0, const VectorT3< T > &normal1, const VectorT3< T > &normal2, LineT3< T > &reflection, T &distance) const
Returns whether a given ray has a front intersection with this triangle and determines the reflective...
Definition Triangle3.h:478
VectorT3< T > barycentric2cartesian(const VectorT3< T > &barycentric) const
Returns the 3D cartesian coordinate of a given barycentric coordinate defined in relation to this tri...
Definition Triangle3.h:296
bool isValid() const
Returns whether this triangle is valid.
Definition Triangle3.h:579
bool hasIntersection(const LineT3< T > &ray) const
Returns whether a given ray has an intersection with this triangle.
Definition Triangle3.h:306
bool intersection(const LineT3< T > &ray, LineT3< T > &reflection, T &distance, VectorT3< T > &normal) const
Returns whether a given ray has an intersection with this triangle and determines the reflective ray ...
Definition Triangle3.h:411
TriangleT3< T > operator+(const VectorT3< T > &offset) const
Shifts the triangle by a given 3D vector (by adding the vector to all three corners of the triangle).
Definition Triangle3.h:592
const VectorT3< Scalar > & point2() const
TriangleT3< T > operator-(const VectorT3< T > &offset) const
Shifts the triangle by a given 3D vector (by subtracting the vector from all three corners of the tri...
Definition Triangle3.h:608
bool frontIntersection(const LineT3< T > &ray, const VectorT3< T > &normal0, const VectorT3< T > &normal1, const VectorT3< T > &normal2, LineT3< T > &reflection, T &distance, VectorT3< T > &normal) const
Returns whether a given ray has a front intersection with this triangle and determines the reflective...
Definition Triangle3.h:519
const VectorT3< Scalar > & point1() const
bool intersection(const LineT3< T > &ray, VectorT3< T > &point, T &distance) const
Returns whether a given ray has an intersection with this triangle and determines the intersection po...
Definition Triangle3.h:323
TriangleT3()
Creates a new triangle object with default parameters.
Definition Triangle3.h:262
bool intersection(const LineT3< T > &ray, VectorT3< T > &point, VectorT3< T > &barycentric, T &distance) const
Returns whether a given ray has an intersection with this triangle and determines the intersection po...
Definition Triangle3.h:353
VectorT3< Scalar > trianglePoints[3]
Definition Triangle3.h:258
TriangleT3(const VectorT3< T > &point0, const VectorT3< T > &point1, const VectorT3< T > &point2)
Creates a new triangle object by three given corners.
Definition Triangle3.h:270
This class implements a base class for all triangle classes.
Definition Triangle.h:49
static bool isValidBarycentric(const VectorT3< T > &barycentric, const T &epsilon=NumericT< T >::eps())
Returns whether the a barycentric coordinate is valid.
Definition Triangle.h:77
This class implements a vector with three elements.
Definition Vector3.h:97
bool isUnit(const T eps=NumericT< T >::eps()) const
Returns whether this vector is a unit vector (whether the vector has the length 1).
Definition Vector3.h:865
const T & y() const noexcept
Returns the y value.
Definition Vector3.h:816
const T & x() const noexcept
Returns the x value.
Definition Vector3.h:804
VectorT3< T > normalizedOrZero() const
Returns the normalized vector.
Definition Vector3.h:623
const T & z() const noexcept
Returns the z value.
Definition Vector3.h:828
T length() const
Returns the length of the vector.
Definition Vector3.h:668
TriangleT3< double > TriangleD3
Instantiation of the TriangleT3 template class using a double precision float data type.
Definition Triangle3.h:35
TriangleT3< Scalar > Triangle3
Definition of the Triangle3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sing...
Definition Triangle3.h:28
std::vector< TriangleF3 > TrianglesF3
Definition of a vector holding 3D triangles with single precision float data type.
Definition Triangle3.h:64
std::vector< TriangleT3< T > > TrianglesT3
Definition of a typename alias for vectors with TriangleT3 objects.
Definition Triangle3.h:50
std::vector< Triangle3 > Triangles3
Definition of a vector holding 3D triangles.
Definition Triangle3.h:57
TriangleT3< float > TriangleF3
Instantiation of the TriangleT3 template class using a single precision float data type.
Definition Triangle3.h:42
std::vector< TriangleD3 > TrianglesD3
Definition of a vector holding 3D triangles with double precision float data type.
Definition Triangle3.h:71
The namespace covering the entire Ocean framework.
Definition Accessor.h:15