|
EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
|
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 (Triangle &&a_otherTriangle) noexcept=default | |
| Move constructor. | |
| Triangle (const std::array< Vec3, 3 > &a_vertexPositions) noexcept | |
| Full constructor. | |
| ~Triangle () noexcept=default | |
| Destructor (does nothing). | |
| Triangle & | operator= (const Triangle &a_otherTriangle) noexcept=default |
| Copy assignment. | |
| Triangle & | operator= (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. | |
| const Vec3 & | getNormal () const noexcept |
| Get the triangle normal vector. | |
| const std::array< Vec3, 3 > & | getVertexPositions () const noexcept |
| Get the vertex positions. | |
| const std::array< Vec3, 3 > & | getVertexNormals () const noexcept |
| Get the vertex normals. | |
| const std::array< Vec3, 3 > & | getEdgeNormals () const noexcept |
| Get the edge normals. | |
| const Meta & | getMetaData () 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 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. | |
| Meta | m_metaData |
| Triangle meta-data normals. | |
Triangle class with signed distance functionality.
This class represents a planar triangle and has a signed distance functionality. It is self-contained: it stores all of its own data and holds no external references. 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. 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.
| T | Floating-point precision. |
| Meta | User-defined metadata type stored with the triangle. |
|
defaultnoexcept |
Copy constructor.
| [in] | a_otherTriangle | Other triangle. |
|
defaultnoexcept |
Move constructor.
| [in,out] | a_otherTriangle | Other triangle. |
|
noexcept |
Full constructor.
| [in] | a_vertexPositions | Triangle vertex positions. |
Compute the triangle normal vector.
This computes the normal vector from two of the triangle edges, using the right-hand rule and vertex ordering to infer the normal vector. The three vertices must not be collinear (or coincident): a zero-area triangle has an undefined face normal.
|
noexcept |
Get the edge normals.
Const-only; use setEdgeNormals to update.
|
noexcept |
Get the triangle meta-data.
Const-only; use setMetaData to update.
|
noexcept |
Get the triangle normal vector.
Const-only: mutating this in place would desynchronize it from the vertex positions it was derived from. Use setNormal or setVertexPositions instead.
|
noexcept |
Get the vertex normals.
Const-only; use setVertexNormals to update.
|
noexcept |
Get the vertex positions.
Const-only: mutating positions in place would leave m_triangleNormal stale. Use setVertexPositions instead.
|
defaultnoexcept |
Copy assignment.
| [in] | a_otherTriangle | Other triangle. |
|
defaultnoexcept |
Move assignment.
| [in,out] | a_otherTriangle | Other triangle. |
|
noexcept |
Set the triangle edge normals.
| [in] | a_edgeNormals | Edge normals. Each must be finite and unit length. |
|
noexcept |
Set the triangle meta-data.
| [in] | a_metaData | Triangle metadata. |
|
noexcept |
Set the triangle normal vector.
| [in] | a_normal | Normal vector. Must be finite and unit length. |
|
noexcept |
Set the triangle vertex normals.
| [in] | a_vertexNormals | Vertex normals. Each must be finite and unit length. |
|
noexcept |
Set the triangle vertex positions.
Also recomputes the triangle face normal from the new vertex positions (see computeNormal). The three vertices must not be collinear (or coincident), or the face normal is undefined.
| [in] | a_vertexPositions | Vertex positions. Each component must be finite. |
|
noexcept |
Compute the signed distance from the input point x to the triangle.
Requires the triangle to be fully initialized with a non-degenerate (non-collinear) set of vertex positions; see setVertexPositions.
| [in] | a_point | Query point. Must be finite. |