EBGeometry 1.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EBGeometry::Triangle< T, Meta > Class Template Reference

Triangle class with signed distance functionality. More...

#include <EBGeometry_Triangle.hpp>

Public Types

using Vec2 = Vec2T< T >
 Alias for 2D vector type.
 
using Vec3 = Vec3T< T >
 Alias for 3D vector type.
 

Public Member Functions

 Triangle () noexcept=default
 Default constructor. Does not put the triangle in a usable state.
 
 Triangle (const Triangle &a_otherTriangle) noexcept=default
 Copy constructor.
 
 Triangle (const std::array< Vec3, 3 > &a_vertexPositions) noexcept
 Full constructor.
 
 ~Triangle () noexcept=default
 Destructor (does nothing).
 
Triangleoperator= (const Triangle &a_otherTriangle) noexcept=default
 Copy assignment.
 
Triangleoperator= (Triangle &&a_otherTriangle) noexcept=default
 Move assignment.
 
void setNormal (const Vec3 &a_normal) noexcept
 Set the triangle normal vector.
 
void setVertexPositions (const std::array< Vec3, 3 > &a_vertexPositions) noexcept
 Set the triangle vertex positions.
 
void setVertexNormals (const std::array< Vec3, 3 > &a_vertexNormals) noexcept
 Set the triangle vertex normals.
 
void setEdgeNormals (const std::array< Vec3, 3 > &a_edgeNormals) noexcept
 Set the triangle edge normals.
 
void setMetaData (const Meta &a_metaData) noexcept
 Set the triangle meta-data.
 
void computeNormal () noexcept
 Compute the triangle normal vector.
 
Vec3getNormal () noexcept
 Get the triangle normal vector.
 
const Vec3getNormal () const noexcept
 Get the triangle normal vector.
 
std::array< Vec3, 3 > & getVertexPositions () noexcept
 Get the vertex positions.
 
const std::array< Vec3, 3 > & getVertexPositions () const noexcept
 Get the vertex positions.
 
std::array< Vec3, 3 > & getVertexNormals () noexcept
 Get the vertex normals.
 
const std::array< Vec3, 3 > & getVertexNormals () const noexcept
 Get the vertex normals.
 
std::array< Vec3, 3 > & getEdgeNormals () noexcept
 Get the edge normals.
 
const std::array< Vec3, 3 > & getEdgeNormals () const noexcept
 Get the edge normals.
 
MetagetMetaData () noexcept
 Get the triangle meta-data.
 
const MetagetMetaData () const noexcept
 Get the triangle meta-data.
 
T signedDistance (const Vec3 &a_point) const noexcept
 Compute the signed distance from the input point x to the triangle.
 

Protected Member Functions

T projectPointToEdge (const Vec3 &a_point, const Vec3 &a_x0, const Vec3 &a_x1) const noexcept
 Returns the "projection" of a point to an edge.
 

Protected Attributes

Vec3 m_triangleNormal = Vec3::max()
 Triangle face normal.
 
std::array< Vec3, 3 > m_vertexPositions {Vec3::max(), Vec3::max(), Vec3::max()}
 Triangle vertex positions.
 
std::array< Vec3, 3 > m_vertexNormals {Vec3::max(), Vec3::max(), Vec3::max()}
 Triangle vertex normals.
 
std::array< Vec3, 3 > m_edgeNormals {Vec3::max(), Vec3::max(), Vec3::max()}
 Triangle edge normals.
 
Triangle2D< Tm_triangle2D
 2D projection of the triangle to one of the Cartesian coordinate directions
 
Meta m_metaData
 Triangle meta-data normals.
 

Detailed Description

template<class T, class Meta>
class EBGeometry::Triangle< T, Meta >

Triangle class with signed distance functionality.

This class represents a planar triangle and has a signed distance functionality. It is self-contained such that it can be directly copied to GPUs. The class contains a triangle face normal vector; three vertex positions, and normal vectors for the three vertices and three edges.

This class assumes that the vertices are organized with the right-hand rule. I.e., edges are enumerated as follows:

Edge 1 points from vertex 1 to vertex 2 Edge 2 points from vertex 2 to vertex 3 Edge 3 points from vertex 3 to vertex 0

This class can compute its own normal vector from the vertex positions, and the triangle orientation is then implicitly given by the vertex order.

To compute the distance from a point to the triangle, one must determine if the point projects to the "inside" or "outside" of the triangle. This class contains a 2D embedding of the triangle that can perform this project. If the query point projects to the inside of the triangle, the distance is simply the projected distance onto the triangle plane. If it projects to the outside of the triangle, we check the distance against the triangle edges and vertices. the ed

Constructor & Destructor Documentation

◆ Triangle() [1/2]

template<class T , class Meta >
EBGeometry::Triangle< T, Meta >::Triangle ( const Triangle< T, Meta > &  a_otherTriangle)
defaultnoexcept

Copy constructor.

Parameters
[in]a_otherTriangleOther triangle.

◆ Triangle() [2/2]

template<class T , class Meta >
EBGeometry::Triangle< T, Meta >::Triangle ( const std::array< Vec3, 3 > &  a_vertexPositions)
noexcept

Full constructor.

Parameters
[in]a_vertexPositionsTriangle vertex positions

Member Function Documentation

◆ computeNormal()

template<class T , class Meta >
void EBGeometry::Triangle< T, Meta >::computeNormal ( )
noexcept

Compute the triangle normal vector.

This computes the normal vector from two of the triangle edges.

◆ getEdgeNormals() [1/2]

template<class T , class Meta >
const std::array< Vec3, 3 > & EBGeometry::Triangle< T, Meta >::getEdgeNormals ( ) const
noexcept

Get the edge normals.

Returns
m_edgeNormals

◆ getEdgeNormals() [2/2]

template<class T , class Meta >
std::array< Vec3, 3 > & EBGeometry::Triangle< T, Meta >::getEdgeNormals ( )
noexcept

Get the edge normals.

Returns
m_edgeNormals

◆ getMetaData() [1/2]

template<class T , class Meta >
const Meta & EBGeometry::Triangle< T, Meta >::getMetaData ( ) const
noexcept

Get the triangle meta-data.

Returns
m_metaData

◆ getMetaData() [2/2]

template<class T , class Meta >
Meta & EBGeometry::Triangle< T, Meta >::getMetaData ( )
noexcept

Get the triangle meta-data.

Returns
m_metaData

◆ getNormal() [1/2]

template<class T , class Meta >
const Vec3 & EBGeometry::Triangle< T, Meta >::getNormal ( ) const
noexcept

Get the triangle normal vector.

Returns
m_triangleNormal

◆ getNormal() [2/2]

template<class T , class Meta >
Vec3 & EBGeometry::Triangle< T, Meta >::getNormal ( )
noexcept

Get the triangle normal vector.

Returns
m_triangleNormal

◆ getVertexNormals() [1/2]

template<class T , class Meta >
const std::array< Vec3, 3 > & EBGeometry::Triangle< T, Meta >::getVertexNormals ( ) const
noexcept

Get the vertex normals.

Returns
m_vertexNormals

◆ getVertexNormals() [2/2]

template<class T , class Meta >
std::array< Vec3, 3 > & EBGeometry::Triangle< T, Meta >::getVertexNormals ( )
noexcept

Get the vertex normals.

Returns
m_vertexNormals

◆ getVertexPositions() [1/2]

template<class T , class Meta >
const std::array< Vec3, 3 > & EBGeometry::Triangle< T, Meta >::getVertexPositions ( ) const
noexcept

Get the vertex positions.

Returns
m_vertexPositions

◆ getVertexPositions() [2/2]

template<class T , class Meta >
std::array< Vec3, 3 > & EBGeometry::Triangle< T, Meta >::getVertexPositions ( )
noexcept

Get the vertex positions.

Returns
m_vertexPositions

◆ operator=() [1/2]

template<class T , class Meta >
Triangle & EBGeometry::Triangle< T, Meta >::operator= ( const Triangle< T, Meta > &  a_otherTriangle)
defaultnoexcept

Copy assignment.

Parameters
[in]a_otherTriangleOther triangle.

◆ operator=() [2/2]

template<class T , class Meta >
Triangle & EBGeometry::Triangle< T, Meta >::operator= ( Triangle< T, Meta > &&  a_otherTriangle)
defaultnoexcept

Move assignment.

Parameters
[in,out]a_otherTriangleOther triangle.

◆ projectPointToEdge()

template<class T , class Meta >
T EBGeometry::Triangle< T, Meta >::projectPointToEdge ( const Vec3 a_point,
const Vec3 a_x0,
const Vec3 a_x1 
) const
protectednoexcept

Returns the "projection" of a point to an edge.

This function parametrizes the edge as x(t) = x0 + (x1-x0)*t and returns where on the this edge the point a_x0 projects. If projects onto the edge if t = [0,1] and to one of the start/end vertices otherwise.

Parameters
[in]a_pointQuery point
[in]a_x0Starting edge coordinate
[in]a_x1Final edge coordinate

◆ setEdgeNormals()

template<class T , class Meta >
void EBGeometry::Triangle< T, Meta >::setEdgeNormals ( const std::array< Vec3, 3 > &  a_edgeNormals)
noexcept

Set the triangle edge normals.

Parameters
[in]a_edgeNormalsEdge normals

◆ setMetaData()

template<class T , class Meta >
void EBGeometry::Triangle< T, Meta >::setMetaData ( const Meta a_metaData)
noexcept

Set the triangle meta-data.

Parameters
[in]a_metaDataTriangle metadata.

◆ setNormal()

template<class T , class Meta >
void EBGeometry::Triangle< T, Meta >::setNormal ( const Vec3 a_normal)
noexcept

Set the triangle normal vector.

Parameters
[in]a_normalNormal vector (should be consistent with the vertex ordering!).

◆ setVertexNormals()

template<class T , class Meta >
void EBGeometry::Triangle< T, Meta >::setVertexNormals ( const std::array< Vec3, 3 > &  a_vertexNormals)
noexcept

Set the triangle vertex normals.

Parameters
[in]a_vertexNormalsVertex normals

◆ setVertexPositions()

template<class T , class Meta >
void EBGeometry::Triangle< T, Meta >::setVertexPositions ( const std::array< Vec3, 3 > &  a_vertexPositions)
noexcept

Set the triangle vertex positions.

Parameters
[in]a_vertexPositionsVertex positions

◆ signedDistance()

template<class T , class Meta >
T EBGeometry::Triangle< T, Meta >::signedDistance ( const Vec3 a_point) const
noexcept

Compute the signed distance from the input point x to the triangle.

Parameters
[in]a_pointPoint

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