|
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 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 Array< Vec3, 3 > &a_vertexPositions) noexcept |
| Set the triangle vertex positions. | |
| void | setVertexNormals (const Array< Vec3, 3 > &a_vertexNormals) noexcept |
| Set the triangle vertex normals. | |
| void | setEdgeNormals (const Array< Vec3, 3 > &a_edgeNormals) noexcept |
| Set the triangle edge normals. | |
| void | setFaceId (const uint32_t a_faceId) noexcept |
| Set the face id. | |
| void | computeNormal () noexcept |
| Compute the triangle normal vector. | |
| const Vec3 & | getNormal () const noexcept |
| Get the triangle normal vector. | |
| const Array< Vec3, 3 > & | getVertexPositions () const noexcept |
| Get the vertex positions. | |
| const Array< Vec3, 3 > & | getVertexNormals () const noexcept |
| Get the vertex normals. | |
| const Array< Vec3, 3 > & | getEdgeNormals () const noexcept |
| Get the edge normals. | |
| uint32_t | getFaceId () const noexcept |
| Get the face id. | |
| 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. | |
| Array< Vec3, 3 > | m_vertexPositions {Vec3::max(), Vec3::max(), Vec3::max()} |
| Triangle vertex positions. | |
| Array< Vec3, 3 > | m_vertexNormals {Vec3::max(), Vec3::max(), Vec3::max()} |
| Triangle vertex normals. | |
| Array< Vec3, 3 > | m_edgeNormals {Vec3::max(), Vec3::max(), Vec3::max()} |
| Triangle edge normals. | |
| uint32_t | m_faceId = UINT32_MAX |
| Id of the face this triangle belongs to, UINT32_MAX if unset. | |
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 0 points from vertex 0 to vertex 1 Edge 1 points from vertex 1 to vertex 2 Edge 2 points from vertex 2 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.
A triangle also carries a face id: the index of the mesh face it was cut from (see Parser::readIntoTriangles and TriMeshSDF), or any id the caller assigns. It plays no part in the distance computation; TriMeshSDF::getClosestFace() reports it.
| T | Floating-point precision. |
|
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. |
|
noexcept |
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. A zero-area triangle (collinear or coincident vertices) gets a zero normal.
|
noexcept |
Get the edge normals.
Const-only; use setEdgeNormals to update.
|
noexcept |
Get the face id.
|
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, or zero for an edge on a fold (a mesh loaded with Parser::OnDefect::Warn can have one). |
|
noexcept |
Set the face id.
| [in] | a_faceId | Id of the face this triangle belongs to. |
|
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, or zero for a vertex on a fold (a mesh loaded with Parser::OnDefect::Warn can have one). |
|
noexcept |
Set the triangle vertex positions.
Also recomputes the triangle face normal from the new vertex positions (see computeNormal). If the three vertices are collinear or coincident the normal is set to zero: such a triangle has no interior, and its signed distance is not meaningful.
| [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. |