OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
operations.hpp
Go to the documentation of this file.
1// OpenBEM - Copyright (C) 2026 Shashwat Sharma
2
3// This file is part of OpenBEM.
4
5// OpenBEM is free software: you can redistribute it and/or modify it under the terms of the
6// GNU General Public License as published by the Free Software Foundation, either version 3
7// of the License, or (at your option) any later version.
8
9// You should have received a copy of the GNU General Public License along with OpenBEM.
10// If not, see <https://www.gnu.org/licenses/>.
11
12
18#ifndef BEM_GEOM_OPS_H
19#define BEM_GEOM_OPS_H
20
21#include <cassert>
22
23#include "types.hpp"
24#include "constants.hpp"
25
26
27namespace bem
28{
29
30const Float GEOMETRY_DEFAULT_TOL = std::sqrt(float_eps);
31
32// Forward declarations
33template <uint8_t dim> class Edge;
34template <uint8_t dim> class Triangle;
35
45template <uint8_t dim>
47{
48
49 static_assert((dim == 1 || dim == 2 || dim == 3), "Dimension must be one, two, or three.");
50
51public:
52
60
61
72 );
73
74
87 );
88
89
99 );
100
101
112 );
113
114
125 const Float tol = GEOMETRY_DEFAULT_TOL
126 );
127
128
149 const Float tol = GEOMETRY_DEFAULT_TOL
150 );
151
152
161 const Triangle<3>& triangle1,
162 const Triangle<3>& triangle2,
163 const Float tol = GEOMETRY_DEFAULT_TOL
164 );
165
166
175 const Triangle<3>& triangle1,
176 const Triangle<3>& triangle2,
177 const Float tol = GEOMETRY_DEFAULT_TOL
178 );
179
180
188 static bool check_coplanar_triangles(
189 const Triangle<3>& triangle1,
190 const Triangle<3>& triangle2,
191 const Float tol = GEOMETRY_DEFAULT_TOL
192 );
193
194
203 const Edge<dim>& edge1,
204 const Edge<dim>& edge2,
205 const Float tol = GEOMETRY_DEFAULT_TOL
206 );
207
208
216 static bool check_perpendicular_edges(
217 const Edge<dim>& edge1,
218 const Edge<dim>& edge2,
219 const Float tol = GEOMETRY_DEFAULT_TOL
220 );
221
222
231 static bool point_in_polygon(
234 const Float tol = GEOMETRY_DEFAULT_TOL
235 );
236
237};
238
243}
244
245#ifndef BEM_LINKED
247#endif
248
249#endif
Geometry operations class.
static EigMatNX< Complex, dim > cartesian_to_polar_field(ConstEigRef< EigMatNX< Float, dim > > points, ConstEigRef< EigMatNX< Complex, dim > > field)
Transforms a vector field in Cartesian space to polar (2D) or spherical (3D) space.
static EigRowVec< Float > directed_angle_between_vectors(ConstEigRef< EigMatNX< Float, dim > > v1, ConstEigRef< EigMatNX< Float, dim > > v2)
Returns the directional angles between pairs of vectors in a right-hand system where counter-clockwis...
static bool point_in_polygon(ConstEigRef< EigColVecN< Float, dim > > &point, ConstEigRef< EigMatNX< Float, dim > > &polygon, const Float tol=GEOMETRY_DEFAULT_TOL)
Checks if a point is inside a polygon using ray casting.
static EigRowVec< Float > angle_between_vectors(ConstEigRef< EigMatNX< Float, dim > > v1, ConstEigRef< EigMatNX< Float, dim > > v2)
Returns the angles between pairs of vectors in radians.
static bool check_coplanar_triangles(const Triangle< 3 > &triangle1, const Triangle< 3 > &triangle2, const Float tol=GEOMETRY_DEFAULT_TOL)
Checks if two triangles are coplanar.
static uint8_t common_vertices(const Triangle< dim > &triangle1, const Triangle< dim > &triangle2, const Float tol=GEOMETRY_DEFAULT_TOL)
Returns the number of vertices common or coinciding between two Triangle objects.
static int8_t check_parallel_triangles(const Triangle< 3 > &triangle1, const Triangle< 3 > &triangle2, const Float tol=GEOMETRY_DEFAULT_TOL)
Checks if the normal vectors of two triangles are (anti-)parallel.
static EigMatNX< Float, dim > transform_coordinate_system(ConstEigRef< EigMatNX< Float, dim > > v_in, ConstEigRef< EigColVecN< Float, dim > > new_origin, ConstEigRef< EigMatMN< Float, dim, dim > > new_uvw)
Transforms the given coordinates to a new coordinate system defined by a new origin and orthogonal un...
static EigMatNX< Float, dim > polar_to_cartesian(ConstEigRef< EigMatNX< Float, dim > > points)
Transforms polar (2D) or spherical (3D) coordinates to Cartesian.
static bool check_perpendicular_triangles(const Triangle< 3 > &triangle1, const Triangle< 3 > &triangle2, const Float tol=GEOMETRY_DEFAULT_TOL)
Checks if the normal vectors of two triangles are perpendicular.
static bool check_perpendicular_edges(const Edge< dim > &edge1, const Edge< dim > &edge2, const Float tol=GEOMETRY_DEFAULT_TOL)
Checks if two edges are perpendicular.
static int8_t check_parallel_edges(const Edge< dim > &edge1, const Edge< dim > &edge2, const Float tol=GEOMETRY_DEFAULT_TOL)
Checks if two edges are (anti-)parallel.
const Float float_eps
Numerical infinitesimal.
Definition constants.hpp:70
Eigen::Ref< EigObj > EigRef
Writable reference to an Eigen object.
Definition types.hpp:102
const Eigen::Ref< const EigObj > ConstEigRef
Read-only reference to an Eigen object.
Definition types.hpp:98
double Float
Floating point number.
Definition types.hpp:47
Eigen::Matrix< T, N, 1 > EigColVecN
Fixed-size column vector of size N containing type T.
Definition types.hpp:86
Primary namespace for the OpenBEM library.
Definition constants.hpp:31