PolyFEM
Loading...
Searching...
No Matches
GeometryUtils.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <Eigen/Core>
6
7namespace polyfem::utils
8{
14 double triangle_area_2D(
15 const Eigen::Vector2d &a,
16 const Eigen::Vector2d &b,
17 const Eigen::Vector2d &c);
18
24 double triangle_area_3D(
25 const Eigen::Vector3d &a,
26 const Eigen::Vector3d &b,
27 const Eigen::Vector3d &c);
28
32 double triangle_area(const Eigen::MatrixXd V);
33
40 double tetrahedron_volume(
41 const Eigen::Vector3d &a,
42 const Eigen::Vector3d &b,
43 const Eigen::Vector3d &c,
44 const Eigen::Vector3d &d);
45
49 double tetrahedron_volume(const Eigen::MatrixXd V);
50
59 void triangle_area_2D_gradient(double ax, double ay, double bx, double by, double cx, double cy, double g[6]);
60
69 void triangle_area_2D_hessian(double ax, double ay, double bx, double by, double cx, double cy, double H[36]);
70
85 void tetrahedron_volume_gradient(double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz, double dx, double dy, double dz, double g[12]);
86
101 void tetrahedron_volume_hessian(double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz, double dx, double dy, double dz, double H[144]);
102
106 Eigen::MatrixXd triangle_to_clockwise_order(const Eigen::MatrixXd &triangle);
107
111 std::vector<Eigen::MatrixXd> triangle_fan(const Eigen::MatrixXd &convex_polygon);
112
117 Eigen::VectorXd barycentric_coordinates(
118 const Eigen::VectorXd &p,
119 const Eigen::MatrixXd &V);
120
129 const Eigen::Vector2d &t0,
130 const Eigen::Vector2d &t1,
131 const Eigen::Vector2d &t2,
132 const Eigen::Vector2d &center,
133 const double radius);
134
144 const Eigen::Vector3d &t0,
145 const Eigen::Vector3d &t1,
146 const Eigen::Vector3d &t2,
147 const Eigen::Vector3d &t3,
148 const Eigen::Vector3d &center,
149 const double radius);
150
159 const VectorNd &ea0,
160 const VectorNd &ea1,
161 const VectorNd &eb0,
162 const VectorNd &eb1,
163 const double tol = 1e-10);
164
175 const Eigen::Vector3d &t00,
176 const Eigen::Vector3d &t01,
177 const Eigen::Vector3d &t02,
178 const Eigen::Vector3d &t10,
179 const Eigen::Vector3d &t11,
180 const Eigen::Vector3d &t12,
181 const double tol = 1e-10);
182
190 const VectorNd &aabb0_min,
191 const VectorNd &aabb0_max,
192 const VectorNd &aabb1_min,
193 const VectorNd &aabb1_max);
194} // namespace polyfem::utils
int V
bool tetrahedron_intersects_ball(const Eigen::Vector3d &t0, const Eigen::Vector3d &t1, const Eigen::Vector3d &t2, const Eigen::Vector3d &t3, const Eigen::Vector3d &center, const double radius)
Determine if a 3D tetrahedron intersects a 3D ball.
bool are_aabbs_intersecting(const VectorNd &aabb0_min, const VectorNd &aabb0_max, const VectorNd &aabb1_min, const VectorNd &aabb1_max)
Determine if two axis-aligned bounding boxes intersect.
void triangle_area_2D_hessian(double ax, double ay, double bx, double by, double cx, double cy, double H[36])
Compute the Hessian of the signed area of a 2D triangle defined by three points.
void tetrahedron_volume_gradient(double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz, double dx, double dy, double dz, double g[12])
Compute the gradient of the signed volume of a tetrahedron defined by four points.
void tetrahedron_volume_hessian(double ax, double ay, double az, double bx, double by, double bz, double cx, double cy, double cz, double dx, double dy, double dz, double H[144])
Compute the gradient of the signed area of a 2D triangle defined by three points.
double tetrahedron_volume(const Eigen::Vector3d &a, const Eigen::Vector3d &b, const Eigen::Vector3d &c, const Eigen::Vector3d &d)
Compute the signed volume of a tetrahedron defined by four points.
void triangle_area_2D_gradient(double ax, double ay, double bx, double by, double cx, double cy, double g[6])
Compute the gradient of the signed area of a 2D triangle defined by three points.
bool are_edges_collinear(const VectorNd &ea0, const VectorNd &ea1, const VectorNd &eb0, const VectorNd &eb1, const double tol)
Determine if two edges are collinear.
double triangle_area_3D(const Eigen::Vector3d &a, const Eigen::Vector3d &b, const Eigen::Vector3d &c)
Compute the area of a 3D triangle defined by three points.
Eigen::MatrixXd triangle_to_clockwise_order(const Eigen::MatrixXd &triangle)
Reorder the vertices of a triangle so they are in clockwise order.
std::vector< Eigen::MatrixXd > triangle_fan(const Eigen::MatrixXd &convex_polygon)
Convert a convex polygon to a list of triangles fanned around the first vertex.
bool are_triangles_coplanar(const Eigen::Vector3d &t00, const Eigen::Vector3d &t01, const Eigen::Vector3d &t02, const Eigen::Vector3d &t10, const Eigen::Vector3d &t11, const Eigen::Vector3d &t12, const double tol)
Determine if two triangles are coplanar.
Eigen::VectorXd barycentric_coordinates(const Eigen::VectorXd &p, const Eigen::MatrixXd &V)
Compute barycentric coordinates for point p with respect to a simplex.
double triangle_area(const Eigen::MatrixXd V)
Compute the signed area of a triangle defined by three points.
double triangle_area_2D(const Eigen::Vector2d &a, const Eigen::Vector2d &b, const Eigen::Vector2d &c)
Compute the signed area of a 2D triangle defined by three points.
bool triangle_intersects_disk(const Eigen::Vector2d &t0, const Eigen::Vector2d &t1, const Eigen::Vector2d &t2, const Eigen::Vector2d &center, const double radius)
Determine if a 2D triangle intersects a 2D disk.
Eigen::Matrix< double, Eigen::Dynamic, 1, 0, 3, 1 > VectorNd
Definition Types.hpp:11