Easy3D 2.6.1
Loading...
Searching...
No Matches
easy3d::geom Namespace Reference

Functions for basic geometric computations. More...

Classes

struct  VertexCurvature
 Discrete curvature information for a vertex. More...
 

Functions

float triangle_area (const SurfaceMesh *mesh, SurfaceMesh::Face f)
 Compute the area of a triangle face in a mesh.
 
float surface_area (const SurfaceMesh *mesh)
 Compute the surface area of the mesh.
 
float volume (const SurfaceMesh *mesh)
 Compute the volume of a mesh.
 
vec3 centroid (const SurfaceMesh *mesh, SurfaceMesh::Face f)
 Compute the barycenter/centroid of a face.
 
vec3 centroid (const SurfaceMesh *mesh)
 Compute the barycenter/centroid of the mesh.
 
void dual (SurfaceMesh *mesh)
 Compute the dual of a mesh.
 
double cotan_weight (const SurfaceMesh *mesh, SurfaceMesh::Edge e)
 Compute the cotangent weight for an edge.
 
double voronoi_area (const SurfaceMesh *mesh, SurfaceMesh::Vertex v)
 Compute the (mixed) Voronoi area of a vertex.
 
double voronoi_area_barycentric (const SurfaceMesh *mesh, SurfaceMesh::Vertex v)
 Compute the barycentric Voronoi area of a vertex.
 
vec3 laplace (const SurfaceMesh *mesh, SurfaceMesh::Vertex v)
 Compute the Laplace vector for a vertex.
 
double angle_sum (const SurfaceMesh *mesh, SurfaceMesh::Vertex v)
 Compute the sum of angles around a vertex.
 
VertexCurvature vertex_curvature (const SurfaceMesh *mesh, SurfaceMesh::Vertex v)
 Compute min, max, mean, and Gaussian curvature for a vertex.
 
template<int DIM, typename FT>
GenericBox< DIM, FT > box_union (GenericBox< DIM, FT > const &a, GenericBox< DIM, FT > const &b)
 Compute the union of two boxes.
 
template<int DIM, typename FT>
GenericBox< DIM, FT > box_intersection (GenericBox< DIM, FT > const &a, GenericBox< DIM, FT > const &b)
 Compute the intersection of two boxes.
 
template<typename FT>
bool intersect (const GenericPlane< FT > &plane1, const GenericPlane< FT > &plane2, const GenericPlane< FT > &plane3, typename GenericPlane< FT >::Point3 &point)
 
vec3 orthogonal (const vec3 &v)
 Returns a vector orthogonal to v. Its norm() depends on v, but is zero only for a null v.
 
template<typename Box, typename Container>
Box bounding_box (const Container &points)
 Computes the bounding box of a set of points.
 
template<typename Vec, typename Container>
Vec centroid (const Container &points)
 Computes the centroid of a set of points.
 
template<typename Vec>
Vec barycenter (const Vec &p1, const Vec &p2)
 Computes the barycenter of two points.
 
template<typename Vec>
Vec barycenter (const Vec &p1, const Vec &p2, const Vec &p3)
 Computes the barycenter of three points.
 
template<typename Vec>
Vec barycenter (const Vec &p1, const Vec &p2, const Vec &p3, const Vec &p4)
 Computes the barycenter of four points.
 
template<typename FT>
Vec< 3, FT > barycentric_coordinates (const Vec< 3, FT > &p, const Vec< 3, FT > &u, const Vec< 3, FT > &v, const Vec< 3, FT > &w)
 Computes the barycentric coordinates of a point p with respect to three points u, v, and w.
 
bool point_in_polygon (const vec2 &p, const std::vector< vec2 > &polygon)
 Tests if a point p lies inside or outside of a polygon. This function is robust to handle general polygons (no matter convex or concave).
 
double clamp_cot (const double v)
 Clamps cotangent values as if angles are in [1, 179].
 
double clamp_cos (const double v)
 Clamps cosine values as if angles are in [1, 179].
 
template<typename Vec>
double cos_angle (const Vec &a, const Vec &b)
 Computes cosine of angle between two (un-normalized) vectors.
 
template<typename Vec>
double sin_angle (const Vec &a, const Vec &b)
 Computes sine of angle between two (un-normalized) vectors.
 
template<typename Vec>
Vec::FT cotan_angle (const Vec &a, const Vec &b)
 Computes cotangent of angle between two (un-normalized) vectors.
 
template<typename Vec>
double angle (const Vec &a, const Vec &b)
 Computes angle between two (un-normalized) vectors.
 
template<typename FT>
FT to_radians (FT degrees)
 Converts an angle from degrees to radians.
 
template<typename FT>
FT to_degrees (FT radians)
 Converts an angle from radians to degrees.
 
float triangle_area (const vec3 &p1, const vec3 &p2, const vec3 &p3)
 Computes area of a triangle given by three points.
 
float triangle_signed_area (const vec2 &p1, const vec2 &p2, const vec2 &p3)
 Computes signed area of a triangle given by three points.
 
vec3 triangle_normal (const vec3 &p1, const vec3 &p2, const vec3 &p3)
 Computes the normal vector of a triangle given by three points.
 
float dist_point_line_segment (const vec3 &p, const vec3 &v0, const vec3 &v1, vec3 &nearest_point)
 Computes the distance of a point p to a line segment given by vec3s (v0,v1).
 
float dist_point_triangle (const vec3 &p, const vec3 &v0, const vec3 &v1, const vec3 &v2, vec3 &nearest_point)
 Computes the distance of a point p to the triangle given by vec3s (v0, v1, v2).
 
vec3 tetra_circum_center (const vec3 &p, const vec3 &q, const vec3 &r, const vec3 &s)
 Computes the circum center of a tetrahedron.
 

Detailed Description

Functions for basic geometric computations.

Function Documentation

◆ angle_sum()

double angle_sum ( const SurfaceMesh * mesh,
SurfaceMesh::Vertex v )

Compute the sum of angles around a vertex.

Used for Gaussian curvature.

Parameters
meshThe surface mesh containing the vertex.
vThe vertex for which to compute the angle sum.
Returns
The sum of angles around the vertex.

◆ box_intersection()

template<int DIM, typename FT>
GenericBox< DIM, FT > box_intersection ( GenericBox< DIM, FT > const & a,
GenericBox< DIM, FT > const & b )

Compute the intersection of two boxes.

Template Parameters
DIMThe dimension.
FTThe floating point type.
Parameters
aThe first box.
bThe second box.
Returns
The resulting intersection box.

◆ box_union()

template<int DIM, typename FT>
GenericBox< DIM, FT > box_union ( GenericBox< DIM, FT > const & a,
GenericBox< DIM, FT > const & b )

Compute the union of two boxes.

Template Parameters
DIMThe dimension.
FTThe floating point type.
Parameters
aThe first box.
bThe second box.
Returns
The resulting union box.

◆ centroid() [1/2]

vec3 centroid ( const SurfaceMesh * mesh)

Compute the barycenter/centroid of the mesh.

Computed as the area-weighted mean of vertices. Assumes triangular faces.

Parameters
meshThe surface mesh for which to compute the centroid.
Returns
The centroid of the mesh.

◆ centroid() [2/2]

vec3 centroid ( const SurfaceMesh * mesh,
SurfaceMesh::Face f )

Compute the barycenter/centroid of a face.

Parameters
meshThe surface mesh containing the face.
fThe face for which to compute the centroid.
Returns
The centroid of the face.

◆ cotan_weight()

double cotan_weight ( const SurfaceMesh * mesh,
SurfaceMesh::Edge e )

Compute the cotangent weight for an edge.

Parameters
meshThe surface mesh containing the edge.
eThe edge for which to compute the cotangent weight.
Returns
The cotangent weight of the edge.

◆ dual()

void dual ( SurfaceMesh * mesh)

Compute the dual of a mesh.

Warning
Changes the mesh in place. All properties are cleared.
Parameters
meshThe surface mesh for which to compute the dual.

◆ intersect()

template<typename FT>
bool intersect ( const GenericPlane< FT > & plane1,
const GenericPlane< FT > & plane2,
const GenericPlane< FT > & plane3,
typename GenericPlane< FT >::Point3 & point )

Check if three planes intersect. Returns false if one of the planes is parallel to any of the others.

Parameters
plane1The first plane.
plane2The second plane.
plane3The third plane.
pointThe intersecting point.
Note
The intersecting point is valid only if the function returns true.
Returns
true if the three planes intersect at a point.

◆ laplace()

vec3 laplace ( const SurfaceMesh * mesh,
SurfaceMesh::Vertex v )

Compute the Laplace vector for a vertex.

Normalized by the Voronoi area.

Parameters
meshThe surface mesh containing the vertex.
vThe vertex for which to compute the Laplace vector.
Returns
The Laplace vector of the vertex.

◆ surface_area()

float surface_area ( const SurfaceMesh * mesh)

Compute the surface area of the mesh.

Precondition
The input mesh needs to be a pure triangle mesh.
Parameters
meshThe surface mesh for which to compute the surface area.
Returns
The surface area of the mesh.

◆ triangle_area()

float triangle_area ( const SurfaceMesh * mesh,
SurfaceMesh::Face f )

Compute the area of a triangle face in a mesh.

Parameters
meshThe surface mesh containing the face.
fThe face for which to compute the area.
Returns
The area of the triangle face.

◆ vertex_curvature()

VertexCurvature vertex_curvature ( const SurfaceMesh * mesh,
SurfaceMesh::Vertex v )

Compute min, max, mean, and Gaussian curvature for a vertex.

Attention
This will not give reliable values for boundary vertices.
Parameters
meshThe surface mesh containing the vertex.
vThe vertex for which to compute the curvature.
Returns
The curvature information of the vertex.

◆ volume()

float volume ( const SurfaceMesh * mesh)

Compute the volume of a mesh.

See "Zhang and Chen. Efficient feature extraction for 2D/3D objects in mesh representation. 2021".

Precondition
The input mesh needs to be a pure triangle mesh and must be closed.
Parameters
meshThe surface mesh for which to compute the volume.
Returns
The volume of the mesh.

◆ voronoi_area()

double voronoi_area ( const SurfaceMesh * mesh,
SurfaceMesh::Vertex v )

Compute the (mixed) Voronoi area of a vertex.

Parameters
meshThe surface mesh containing the vertex.
vThe vertex for which to compute the Voronoi area.
Returns
The Voronoi area of the vertex.

◆ voronoi_area_barycentric()

double voronoi_area_barycentric ( const SurfaceMesh * mesh,
SurfaceMesh::Vertex v )

Compute the barycentric Voronoi area of a vertex.

Parameters
meshThe surface mesh containing the vertex.
vThe vertex for which to compute the barycentric Voronoi area.
Returns
The barycentric Voronoi area of the vertex.