Class that represents a single triangle together with associated metadata on the vertices (one float per vertex)
More...
#include <CD_Triangle.H>
|
|
using | Vec3 = EBGeometry::Vec3T< Real > |
| | Alias for always-3D vector type.
|
| |
|
| | Triangle () noexcept |
| | Default constructor.
|
| |
| | Triangle (const std::array< Vec3, 3 > &a_vertexPositions) noexcept |
| | Full constructor.
|
| |
|
virtual | ~Triangle () noexcept |
| | Destructor.
|
| |
| void | computeArea () noexcept |
| | Compute and store the triangle area in m_area.
|
| |
| void | setVertexPositions (const std::array< Vec3, 3 > &a_vertexPositions) noexcept |
| | Set vertex positions and recompute the triangle area.
|
| |
| void | setVertexData (const std::array< Real, 3 > &a_vertexData) noexcept |
| | Set meta-data on the vertices.
|
| |
| Vec3 | projectToTrianglePlane (const Vec3 &a_point) const noexcept |
| | Project the input point to the triangle plane.
|
| |
| bool | isInside (const Vec3 &a_point) const noexcept |
| | Check if a point lies inside the triangle.
|
| |
| Real | interpolate (const Vec3 &a_point) const noexcept |
| | Interpolate vertex data at a point using barycentric coordinates or IDW fallback.
|
| |
Class that represents a single triangle together with associated metadata on the vertices (one float per vertex)
◆ Triangle() [1/2]
Default constructor.
Leaves vertex positions at their EBGeometry defaults and initializes vertex metadata to zero. The triangle area is zero-initialized. Vertex positions must be set before calling computeArea(), isInside(), or interpolate().
◆ Triangle() [2/2]
| Triangle::Triangle |
( |
const std::array< Vec3, 3 > & |
a_vertexPositions | ) |
|
|
noexcept |
Full constructor.
Sets vertex positions, computes the triangle normal and area, and zero-initializes vertex metadata.
- Parameters
-
| [in] | a_vertexPositions | Vertex positions, in CCW order when viewed from the normal direction. |
◆ computeArea()
| void Triangle::computeArea |
( |
| ) |
|
|
noexcept |
Compute and store the triangle area in m_area.
Uses the cross-product formula: area = 0.5 * ||(v1-v0) x (v2-v0)||. This is called automatically by setVertexPositions(), so manual invocation is only needed if vertex positions were changed through the base class API directly.
◆ computeTriangleArea()
| Real Triangle::computeTriangleArea |
( |
const Vec3 & |
a_x1, |
|
|
const Vec3 & |
a_x2, |
|
|
const Vec3 & |
a_x3 |
|
) |
| |
|
inlinestaticprotectednoexcept |
Compute the area of a triangle defined by three vertices.
- Parameters
-
| [in] | a_x1 | First vertex. |
| [in] | a_x2 | Second vertex. |
| [in] | a_x3 | Third vertex. |
- Returns
- Triangle area: 0.5 * ||(a_x2 - a_x1) x (a_x3 - a_x1)||. Returns zero for degenerate (collinear or coincident) vertices.
◆ interpolate()
| Real Triangle::interpolate |
( |
const Vec3 & |
a_point | ) |
const |
|
noexcept |
Interpolate vertex data at a point using barycentric coordinates or IDW fallback.
For points inside the triangle, barycentric weights are computed from area ratios and the weighted sum of the three vertex data values is returned. For points outside the triangle, inverse-distance weighting (IDW, Shepard power = 1) over the two nearest vertices is used instead: weights are w_i = d_j/(d_i+d_j) and w_j = d_i/(d_i+d_j), ensuring the interpolated value stays within the data range and is bounded. If both nearest distances are zero, equal weights of 0.5 are used. Returns zero for degenerate triangles (m_area == 0).
- Parameters
-
| [in] | a_point | Query point in 3D space. |
- Returns
- Interpolated vertex data value at a_point.
◆ isInside()
| bool Triangle::isInside |
( |
const Vec3 & |
a_point | ) |
const |
|
noexcept |
Check if a point lies inside the triangle.
Tests whether the projection of a_point onto the triangle plane falls within the triangle boundary. The test is based on the sign of the triple products of each edge direction with the triangle normal, so it is valid for arbitrary 3D points (not just coplanar ones). Points exactly on an edge are considered inside.
- Parameters
-
| [in] | a_point | Query point in 3D space. |
- Returns
- True if the projection of a_point onto the triangle plane is inside the triangle, false otherwise.
- Note
- The user must first project the point to the triangle plane by using projectToTrianglePlane
◆ projectToTrianglePlane()
| EBGeometry::Vec3T< Real > Triangle::projectToTrianglePlane |
( |
const Vec3 & |
a_point | ) |
const |
|
noexcept |
Project the input point to the triangle plane.
- Parameters
-
- Returns
- Returns a_point - dot(a_point, m_triangleNormal) * m_triangleNormal
◆ setVertexData()
| void Triangle::setVertexData |
( |
const std::array< Real, 3 > & |
a_vertexData | ) |
|
|
noexcept |
Set meta-data on the vertices.
- Parameters
-
| [in] | a_vertexData | Data on the vertices. Must be in the same order as the vertex positions. |
◆ setVertexPositions()
| void Triangle::setVertexPositions |
( |
const std::array< Vec3, 3 > & |
a_vertexPositions | ) |
|
|
noexcept |
Set vertex positions and recompute the triangle area.
This shadows EBGeometry::Triangle::setVertexPositions to ensure that m_area is kept in sync whenever vertex positions change.
- Parameters
-
| [in] | a_vertexPositions | Vertex positions. |
The documentation for this class was generated from the following files: