OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
bem::Triangle< dim > Class Template Reference

Triangle primitive class. More...

#include <triangle.hpp>

Detailed Description

template<uint8_t dim>
class bem::Triangle< dim >

Triangle primitive class.

Template Parameters
dim- The dimension of the triangle (2 or 3).

Definition at line 44 of file triangle.hpp.

Constructor & Destructor Documentation

◆ Triangle() [1/3]

template<uint8_t dim>
bem::Triangle< dim >::Triangle ( )
inline

Constructs a default reference Triangle object.

Definition at line 51 of file triangle.hpp.

◆ Triangle() [2/3]

template<uint8_t dim>
bem::Triangle< dim >::Triangle ( ConstEigRef< EigMatMN< Float, dim, 3 > >  v,
EigRowVecN< Float, 3 >  edge_polarities = EigRowVecN<Float, 3>::Constant(1, 3, 1) 
)
inline

Constructs a Triangle with given vertices.

Parameters
[in]v- Vertices of the triangle.
[in]edge_polarities- Polarity of each edge of the triangle (optional).

Definition at line 63 of file triangle.hpp.

◆ Triangle() [3/3]

template<uint8_t dim>
bem::Triangle< dim >::Triangle ( std::array< EigColVecN< Float, dim >, 3 >  v_array,
EigRowVecN< Float, 3 >  edge_polarities = EigRowVecN<Float, 3>::Constant(1, 3, 1) 
)
inline

Constructs a Triangle with given vertices.

Parameters
[in]v_array- Array of vertices of the triangle.
[in]edge_polarities- Polarity of each edge of the triangle (optional).

Definition at line 78 of file triangle.hpp.

Member Function Documentation

◆ set_v()

template<uint8_t dim>
void bem::Triangle< dim >::set_v ( ConstEigRef< EigMatMN< Float, dim, 3 > >  v,
EigRowVecN< Float, 3 >  edge_polarities = EigRowVecN<Float, 3>::Constant(1, 3, 1) 
)

Sets the vertices of this Triangle.

Parameters
[in]v- Vertices of the triangle.
[in]edge_polarities- Polarity of each edge of the triangle (optional).

Definition at line 33 of file triangle.cpp.

◆ v() [1/2]

template<uint8_t dim>
const EigMatMN< Float, dim, 3 > & bem::Triangle< dim >::v ( ) const
inline

Returns the vertices of this Triangle.

Returns
Vertices of the triangle.

Definition at line 106 of file triangle.hpp.

◆ v() [2/2]

template<uint8_t dim>
EigColVecN< Float, dim > bem::Triangle< dim >::v ( const uint8_t  idx) const
inline

Returns the vertex of this Triangle at a given index.

Parameters
[in]idx- Index of the desired vertex (0, 1, or 2).
Returns
Vertex of the triangle at the given index.

Definition at line 117 of file triangle.hpp.

◆ edge_polarities() [1/2]

template<uint8_t dim>
const EigRowVecN< Float, 3 > & bem::Triangle< dim >::edge_polarities ( ) const
inline

Returns the edge polarities of this Triangle.

Returns
Edge polarities of the triangle.

Definition at line 129 of file triangle.hpp.

◆ edge_polarities() [2/2]

template<uint8_t dim>
Float bem::Triangle< dim >::edge_polarities ( const uint8_t  idx) const
inline

Returns the edge polarity of this Triangle at a given index.

Parameters
[in]idx- Index of the desired edge (0, 1, or 2).
Returns
Edge polarity of the triangle at the given index.

Definition at line 140 of file triangle.hpp.

◆ reverse()

template<uint8_t dim>
void bem::Triangle< dim >::reverse ( )
inline

Reverses the orientation of this Triangle.

Definition at line 151 of file triangle.hpp.

◆ area() [1/2]

template<uint8_t dim>
Float bem::Triangle< dim >::area ( ) const
inline

Returns the area of this Triangle.

Returns
Area of the triangle.

Definition at line 162 of file triangle.hpp.

◆ normal() [1/2]

template<uint8_t dim>
EigColVecN< Float, 3 > bem::Triangle< dim >::normal ( ) const
inline

Returns the unit normal vector for this Triangle.

Returns
Unit normal vector of the triangle.

Definition at line 170 of file triangle.hpp.

◆ centroid() [1/2]

template<uint8_t dim>
EigColVecN< Float, dim > bem::Triangle< dim >::centroid ( ) const
inline

Returns the centroid of this Triangle.

Returns
Centroid of the triangle.

Definition at line 178 of file triangle.hpp.

◆ mean_edge_length()

template<uint8_t dim>
Float bem::Triangle< dim >::mean_edge_length ( ) const
inline

Returns the mean edge length of this Triangle.

Returns
Mean edge length of the triangle.

Definition at line 186 of file triangle.hpp.

◆ to_2d()

template<uint8_t dim>
Triangle< 2 > bem::Triangle< dim >::to_2d ( ) const

Returns an equivalent triangle with coordinates in a local 2D system, with the local origin at this triangle's first vertex, and with its edge connecting the first two vertices lying along the local x axis.

Returns
2D Triangle with coordinates in a local 2D system.

Definition at line 48 of file triangle.cpp.

◆ to_3d()

template<uint8_t dim>
Triangle< 3 > bem::Triangle< dim >::to_3d ( const Float  z = 0.0) const

Adds a 0-valued third dimension if this Triangle is in 2D, otherwise just returns a copy of this Triangle.

Returns
3D Triangle.

Definition at line 74 of file triangle.cpp.

◆ local_origin()

template<uint8_t dim>
EigColVecN< Float, dim > bem::Triangle< dim >::local_origin ( ) const
inline

Returns the local origin of this Triangle in the global coordinate system. The local origin is just the first vertex of the triangle.

Returns
Local origin of the triangle in the global coordinate system (i.e., its first vertex).

Definition at line 217 of file triangle.hpp.

◆ local_coordinate_basis()

template<uint8_t dim>
EigMatMN< Float, dim, dim > bem::Triangle< dim >::local_coordinate_basis ( ) const

Returns the unit vectors of a local coordinate system, defined in the global system, such that the edge connecting the first two vertices lie along the local x axis, and the Triangle lies in the local xy plane.

Returns
Local coordinate basis of the triangle in the global coordinate system.

Definition at line 83 of file triangle.cpp.

◆ get_plane_projection()

template<uint8_t dim>
void bem::Triangle< dim >::get_plane_projection ( EigMatNX< Float, dim > &  r_proj,
EigRowVec< Float > &  d,
ConstEigRef< EigMatNX< Float, 3 > >  r,
uint8_t  ref_idx = 0 
) const

Returns the projection of given points on to the triangle's plane, along with the normal distance to the plane. For a 2D Triangle, its third (z) dimension is assumed to be 0.

Parameters
[out]r_proj- Projected points.
[out]d- Perpendicular distances of the original points to the triangle's plane.
[in]r- Points to be projected onto the triangle's plane.
[in]ref_idx- Index of the reference vertex to be used for the projection (optional).

Definition at line 111 of file triangle.cpp.

◆ reference_triangle()

template<uint8_t dim>
Triangle< dim > bem::Triangle< dim >::reference_triangle ( )
static

Returns a reference triangle in the specified dimension.

Returns
Reference edge with vertices (0, 0, ...), (1, 0, ...), (0, 1, ...).

Definition at line 129 of file triangle.cpp.

◆ edge_lengths()

template<uint8_t dim>
EigColVecN< Float, 3 > bem::Triangle< dim >::edge_lengths ( ) const
inline

Returns the lengths of each edge of this Triangle.

Returns
Lengths of the triangle's edges.

Definition at line 259 of file triangle.hpp.

◆ longest_edge_index()

template<uint8_t dim>
uint8_t bem::Triangle< dim >::longest_edge_index ( ) const
inline

Returns the index associated with the longest edge of this Triangle.

Returns
Index of the triangle's longest edge.

Definition at line 272 of file triangle.hpp.

◆ shortest_edge_index()

template<uint8_t dim>
uint8_t bem::Triangle< dim >::shortest_edge_index ( ) const
inline

Returns the index associated with the shortest edge of this Triangle.

Returns
Index of the triangle's shortest edge.

Definition at line 285 of file triangle.hpp.

◆ longest_edge_length()

template<uint8_t dim>
Float bem::Triangle< dim >::longest_edge_length ( ) const
inline

Length of the longest edge of this Triangle.

Returns
Length of the triangle's longest edge.

Definition at line 298 of file triangle.hpp.

◆ shortest_edge_length()

template<uint8_t dim>
Float bem::Triangle< dim >::shortest_edge_length ( ) const
inline

Length of the shortest edge of this Triangle.

Returns
Length of the triangle's shortest edge.

Definition at line 308 of file triangle.hpp.

◆ barycentric_coords()

template<uint8_t dim>
EigMatNX< Float, 3 > bem::Triangle< dim >::barycentric_coords ( ConstEigRef< EigMatNX< Float, dim > >  p) const

Returns barycentric coordinates of given points lying in the Triangle's plane.

Parameters
[in]p- Points in the triangle's plane for which to compute barycentric coordinates.
Returns
Barycentric coordinates of the points.

Definition at line 141 of file triangle.cpp.

◆ projection_loc()

template<uint8_t dim>
EigRowVec< uint8_t > bem::Triangle< dim >::projection_loc ( ConstEigRef< EigMatNX< Float, 3 > >  r) const

Returns flags that indicate whether the given points project inside or outside the triangle, or onto a vertex or edge.

Parameters
[in]r- Points to be projected.
Returns
0 if strictly inside, 1 if on a vertex, 2 if on an edge, 3 if strictly outside.

Definition at line 172 of file triangle.cpp.

◆ point_in_triangle()

template<uint8_t dim>
bool bem::Triangle< dim >::point_in_triangle ( ConstEigRef< EigColVecN< Float, dim > >  r,
const Float  tol = TRIANGLE_DEFAULT_TOL 
) const

Checks whether a given point is inside the triangle, inclusive of edges and vertices.

Parameters
[in]r- Point to be tested.
[in]tol- Comparison tolerance (optional).
Returns
True if the point is inside the triangle, inclusive of edges and vertices, false otherwise.

Definition at line 241 of file triangle.cpp.

◆ map_points()

template<uint8_t dim>
template<uint8_t dim_out>
EigColVecN< Float, dim_out > bem::Triangle< dim >::map_points ( ConstEigRef< EigColVecN< Float, dim > >  points,
const Triangle< dim_out > &  tri_out 
) const
inline

Performs an affine transform to map points lying in this triangle's plane to the output triangle's plane.

Template Parameters
dim_out- Output triangle's dimension (2 or 3).
Parameters
[in]points- Coordinates in this triangle's plane.
[in]tri_out- Target Triangle into whose plane points will be mapped.
Returns
Output coordinates in tri_out's plane.

Definition at line 349 of file triangle.hpp.

◆ area() [2/2]

template<uint8_t dim>
Float bem::Triangle< dim >::area ( ConstEigRef< EigMatMN< Float, dim, 3 > >  v)
static

Computes the area of the triangle formed by the given vertices.

Parameters
[in]v- Vertices.
Returns
Area of the triangle.

Definition at line 287 of file triangle.cpp.

◆ normal() [2/2]

template<uint8_t dim>
EigColVecN< Float, 3 > bem::Triangle< dim >::normal ( ConstEigRef< EigMatMN< Float, dim, 3 > >  v)
static

Computes the unit normal vector for the triangle formed by the given vertices.

Parameters
[in]v- Vertices.
Returns
Unit normal vector of the triangle.

Definition at line 307 of file triangle.cpp.

◆ centroid() [2/2]

template<uint8_t dim>
static EigColVecN< Float, dim > bem::Triangle< dim >::centroid ( ConstEigRef< EigMatMN< Float, dim, 3 > >  v)
inlinestatic

Computes the centroid of the triangle formed by the given vertices.

Parameters
[in]v- Vertices.
Returns
Centroid of the triangle.

Definition at line 383 of file triangle.hpp.

Member Data Documentation

◆ v_

template<uint8_t dim>
EigMatMN<Float, dim, 3> bem::Triangle< dim >::v_
protected

Definition at line 389 of file triangle.hpp.

◆ area_

template<uint8_t dim>
Float bem::Triangle< dim >::area_
protected

Definition at line 390 of file triangle.hpp.

◆ normal_

template<uint8_t dim>
EigColVecN<Float, 3> bem::Triangle< dim >::normal_
protected

Definition at line 391 of file triangle.hpp.

◆ centroid_

template<uint8_t dim>
EigColVecN<Float, dim> bem::Triangle< dim >::centroid_
protected

Definition at line 392 of file triangle.hpp.

◆ edge_polarities_

template<uint8_t dim>
EigRowVecN<Float, 3> bem::Triangle< dim >::edge_polarities_ = EigRowVecN<Float, 3>::Constant(1, 3, 1)
protected

Definition at line 393 of file triangle.hpp.


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