Ocean
Ocean::TriangleT3< T > Class Template Reference

This class implements a 3D triangle. More...

Inheritance diagram for Ocean::TriangleT3< T >:

Public Member Functions

 TriangleT3 ()
 Creates a new triangle object with default parameters. More...
 
 TriangleT3 (const VectorT3< T > &point0, const VectorT3< T > &point1, const VectorT3< T > &point2)
 Creates a new triangle object by three given corners. More...
 
const VectorT3< T > & point0 () const
 Returns the first point of this triangle. More...
 
const VectorT3< T > & point1 () const
 Returns the second point of this triangle. More...
 
const VectorT3< T > & point2 () const
 Returns the third point of this triangle. More...
 
VectorT3< T > barycentric2cartesian (const VectorT3< T > &barycentric) const
 Returns the 3D cartesian coordinate of a given barycentric coordinate defined in relation to this triangle. More...
 
bool hasIntersection (const LineT3< T > &ray) const
 Returns whether a given ray has an intersection with this triangle. More...
 
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 point. More...
 
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 point. More...
 
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 starting at the intersection point. More...
 
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 starting at the intersection point. More...
 
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 ray starting at the intersection point. More...
 
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 ray starting at the intersection point. More...
 
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 ray starting at the intersection point. More...
 
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. More...
 
bool isValid () const
 Returns whether this triangle is valid. More...
 
const VectorT3< T > & operator[] (const unsigned int index) const
 Returns individual triangle corners. More...
 
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). More...
 
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). More...
 
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 triangle). More...
 
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 triangle). More...
 

Private Attributes

VectorT3< T > trianglePoints [3]
 Three triangle points. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Ocean::TriangleT< T >
static bool isBarycentricInside (const VectorT3< T > &barycentricPoint)
 Returns whether a given point, specified as barycentric coordinate, lies inside a triangle. More...
 
static bool isValidBarycentric (const VectorT3< T > &barycentric, const T &epsilon=NumericT< T >::eps())
 Returns whether the a barycentric coordinate is valid. More...
 

Detailed Description

template<typename T>
class Ocean::TriangleT3< T >

This class implements a 3D triangle.

See also
Triangle2.

Constructor & Destructor Documentation

◆ TriangleT3() [1/2]

template<typename T >
Ocean::TriangleT3< T >::TriangleT3
inline

Creates a new triangle object with default parameters.

◆ TriangleT3() [2/2]

template<typename T >
Ocean::TriangleT3< T >::TriangleT3 ( const VectorT3< T > &  point0,
const VectorT3< T > &  point1,
const VectorT3< T > &  point2 
)
inline

Creates a new triangle object by three given corners.

Parameters
point0First triangle point
point1Second triangle point
point2Third triangle point

Member Function Documentation

◆ barycentric2cartesian()

template<typename T >
VectorT3< T > Ocean::TriangleT3< T >::barycentric2cartesian ( const VectorT3< T > &  barycentric) const
inline

Returns the 3D cartesian coordinate of a given barycentric coordinate defined in relation to this triangle.

Parameters
barycentricBarycentric coordinate to convert to a cartesian coordinate
Returns
Cartesian coordinate

◆ frontIntersection() [1/3]

template<typename T >
bool Ocean::TriangleT3< T >::frontIntersection ( const LineT3< T > &  ray,
const VectorT3< T > &  normal,
LineT3< T > &  reflection,
T &  distance 
) const
inline

Returns whether a given ray has a front intersection with this triangle and determines the reflective ray starting at the intersection point.

An explicit reflection normal is used.

Parameters
rayRay to determine whether an intersection occurs
normalReflection normal
reflectionResulting reflection ray, if an intersection occurs
distanceResulting intersection distance
Returns
True, if so

◆ frontIntersection() [2/3]

template<typename T >
bool Ocean::TriangleT3< T >::frontIntersection ( const LineT3< T > &  ray,
const VectorT3< T > &  normal0,
const VectorT3< T > &  normal1,
const VectorT3< T > &  normal2,
LineT3< T > &  reflection,
T &  distance 
) const
inline

Returns whether a given ray has a front intersection with this triangle and determines the reflective ray starting at the intersection point.

The reflection normal is determined by interpolation of the given three point normals.

Parameters
rayRay to determine whether an intersection occurs
normal0Normal of the first triangle point
normal1Normal of the second triangle point
normal2Normal of the third triangle point
reflectionResulting reflection ray, if an intersection occurs
distanceResulting intersection distance
Returns
True, if so

◆ frontIntersection() [3/3]

template<typename T >
bool Ocean::TriangleT3< T >::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
inline

Returns whether a given ray has a front intersection with this triangle and determines the reflective ray starting at the intersection point.

The reflection normal is determined by interpolation of the given three point normals.

Parameters
rayRay to determine whether an intersection occurs
normal0Normal of the first triangle point
normal1Normal of the second triangle point
normal2Normal of the third triangle point
reflectionResulting reflection ray, if an intersection occurs
distanceResulting intersection distance
normalResulting normal
Returns
True, if so

◆ hasIntersection()

template<typename T >
bool Ocean::TriangleT3< T >::hasIntersection ( const LineT3< T > &  ray) const
inline

Returns whether a given ray has an intersection with this triangle.

Parameters
rayRay to determine whether an intersection occurs
Returns
True, if so

◆ intersection() [1/4]

template<typename T >
bool Ocean::TriangleT3< T >::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 starting at the intersection point.

The reflection normal is determined by the triangle.

Parameters
rayRay to determine whether an intersection occurs
reflectionResulting reflection ray, if an intersection occurs
distanceResulting intersection distance
Returns
True, if so

◆ intersection() [2/4]

template<typename T >
bool Ocean::TriangleT3< T >::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 starting at the intersection point.

The reflection normal is determined by the triangle.

Parameters
rayRay to determine whether an intersection occurs
reflectionResulting reflection ray, if an intersection occurs
distanceResulting intersection distance
normalResulting normal
Returns
True, if so

◆ intersection() [3/4]

template<typename T >
bool Ocean::TriangleT3< T >::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 point.

Parameters
rayRay to determine whether an intersection occurs
pointResulting intersection point, if an intersection occurs
distanceResulting intersection distance
Returns
True, if so

◆ intersection() [4/4]

template<typename T >
bool Ocean::TriangleT3< T >::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 point.

Parameters
rayRay to determine whether an intersection occurs
pointResulting intersection point, if an intersection occurs
barycentricResulting Barycentric intersection point
distanceResulting intersection distance
Returns
True, if so

◆ isValid()

template<typename T >
bool Ocean::TriangleT3< T >::isValid
inline

Returns whether this triangle is valid.

Returns
True, if so

◆ operator+()

template<typename T >
TriangleT3< T > Ocean::TriangleT3< T >::operator+ ( const VectorT3< T > &  offset) const
inline

Shifts the triangle by a given 3D vector (by adding the vector to all three corners of the triangle).

Parameters
offsetThe offset vector to shift the triangle
Returns
The new shifted triangle

◆ operator+=()

template<typename T >
TriangleT3< T > & Ocean::TriangleT3< T >::operator+= ( const VectorT3< T > &  offset)
inline

Shifts the triangle by a given 3D vector (by adding the vector to all three corners of the triangle).

Parameters
offsetThe offset vector to shift the triangle
Returns
The reference to this triangle

◆ operator-()

template<typename T >
TriangleT3< T > Ocean::TriangleT3< T >::operator- ( const VectorT3< T > &  offset) const
inline

Shifts the triangle by a given 3D vector (by subtracting the vector from all three corners of the triangle).

Parameters
offsetThe offset vector to shift the triangle
Returns
The new shifted triangle

◆ operator-=()

template<typename T >
TriangleT3< T > & Ocean::TriangleT3< T >::operator-= ( const VectorT3< T > &  offset)
inline

Shifts the triangle by a given 3D vector (by subtracting the vector from all three corners of the triangle).

Parameters
offsetThe offset vector to shift the triangle
Returns
The reference to this triangle

◆ operator[]()

template<typename T >
const VectorT3< T > & Ocean::TriangleT3< T >::operator[] ( const unsigned int  index) const
inline

Returns individual triangle corners.

Parameters
indexIndex of the corner that is requested, with range [0, 2]
Returns
Resulting triangle corner

◆ planeIntersection()

template<typename T >
bool Ocean::TriangleT3< T >::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.

Parameters
rayRay to determine whether an intersection occurs
barycentricResulting Barycentric intersection point
Returns
True, if the ray intersects the plane that is spanned by the triangle (the return value does not indicate whether the triangle itself has been intersected)

◆ point0()

template<typename T >
const VectorT3< T > & Ocean::TriangleT3< T >::point0
inline

Returns the first point of this triangle.

Returns
Triangle point

◆ point1()

template<typename T >
const VectorT3< T > & Ocean::TriangleT3< T >::point1
inline

Returns the second point of this triangle.

Returns
Triangle point

◆ point2()

template<typename T >
const VectorT3< T > & Ocean::TriangleT3< T >::point2
inline

Returns the third point of this triangle.

Returns
Triangle point

Field Documentation

◆ trianglePoints

template<typename T >
VectorT3<T> Ocean::TriangleT3< T >::trianglePoints[3]
private

Three triangle points.


The documentation for this class was generated from the following file: