Geogram  Version 1.9.1
A programming library of geometric algorithms
GEO::Geom Namespace Reference

Geometric functions and utilities. More...

Functions

vec3 barycenter (const vec3 &p1, const vec3 &p2)
 Computes the barycenter of two points in 3d. More...
 
vec3 barycenter (const vec3 &p1, const vec3 &p2, const vec3 &p3)
 Computes the barycenter of three points in 3d. More...
 
double cos_angle (const vec3 &a, const vec3 &b)
 Computes the cosine of the angle between two 3d vectors. More...
 
double angle (const vec3 &a, const vec3 &b)
 Computes the angle between two 3d vectors. More...
 
double det (const vec2 &a, const vec2 &b)
 Computes the determinant of two vectors. More...
 
vec3 triangle_normal (const vec3 &p1, const vec3 &p2, const vec3 &p3)
 Computes the normal of a 3d triangle. More...
 
double triangle_area_3d (const double *p1, const double *p2, const double *p3)
 Computes the area of a 3d triangle. More...
 
double triangle_area (const vec3 &p1, const vec3 &p2, const vec3 &p3)
 Computes the area of a 3d triangle. More...
 
double triangle_signed_area_2d (const double *p1, const double *p2, const double *p3)
 Computes the area of a 2d triangle. More...
 
double triangle_signed_area (const vec2 &p1, const vec2 &p2, const vec2 &p3)
 Computes the area of a 2d triangle. More...
 
double triangle_area_2d (const double *p1, const double *p2, const double *p3)
 Computes the area of a 2d triangle. More...
 
vec2 triangle_circumcenter (const vec2 &p1, const vec2 &p2, const vec2 &p3)
 Computes the center of the circumscribed circle of a 2d triangle. More...
 
bool has_nan (const vec3 &v)
 Tests whether a 3d vector has a NaN (not a number) coordinate. More...
 
vec3 perpendicular (const vec3 &V)
 Computes a 3d vector orthogonal to another one. More...
 
double tetra_signed_volume (const vec3 &p1, const vec3 &p2, const vec3 &p3, const vec3 &p4)
 Computes the signed volume of a 3d tetrahedron. More...
 
double tetra_signed_volume (const double *p1, const double *p2, const double *p3, const double *p4)
 Computes the signed volume of a 3d tetrahedron. More...
 
double tetra_volume (const vec3 &p1, const vec3 &p2, const vec3 &p3, const vec3 &p4)
 Computes the volume of a 3d tetrahedron. More...
 
vec3 tetra_circum_center (const vec3 &p1, const vec3 &p2, const vec3 &p3, const vec3 &p4)
 Computes the center of the circumscribed sphere of 3d tetrahedron. More...
 
void triangle_centroid (const vec3 &p, const vec3 &q, const vec3 &r, double a, double b, double c, vec3 &Vg, double &V)
 Computes the centroid of a 3d triangle with weighted points. More...
 
double triangle_mass (const vec3 &p, const vec3 &q, const vec3 &r, double a, double b, double c)
 Computes the mass of a 3d triangle with weighted points. More...
 
vec3 random_point_in_triangle (const vec3 &p1, const vec3 &p2, const vec3 &p3)
 Generates a random point in a 3d triangle. More...
 
template<class COORD_T >
double distance2 (const COORD_T *p1, const COORD_T *p2, coord_index_t dim)
 Computes the squared distance between two nd points. More...
 
template<class COORD_T >
double distance (const COORD_T *p1, const COORD_T *p2, coord_index_t dim)
 Computes the distance between two nd points. More...
 
template<class VEC >
double distance2 (const VEC &p1, const VEC &p2)
 Computes the squared distance between two nd points. More...
 
template<class VEC >
double distance (const VEC &p1, const VEC &p2)
 Computes the distance between two nd points. More...
 
template<class COORD_T >
double triangle_area (const COORD_T *p1, const COORD_T *p2, const COORD_T *p3, coord_index_t dim)
 Computes the area of a nd triangle. More...
 
template<class COORD_T >
void triangle_centroid (const COORD_T *p, const COORD_T *q, const COORD_T *r, COORD_T a, COORD_T b, COORD_T c, double *Vg, double &V, coord_index_t dim)
 Computes the centroid of a 3d triangle with weighted points. More...
 
template<class VEC >
double triangle_area (const VEC &p1, const VEC &p2, const VEC &p3)
 Computes the area of a nd triangle. More...
 
template<class VEC >
double triangle_mass (const VEC &p, const VEC &q, const VEC &r, double a, double b, double c)
 Computes the mass of a nd triangle with weighted points. More...
 
template<class POINT >
POINT triangle_circumcenter (const POINT &Q1, const POINT &Q2, const POINT &Q3, double *denom=nullptr)
 Computes the center of the circumscribed circle of a nd triangle. More...
 
template<class VEC >
void triangle_centroid (const VEC &p, const VEC &q, const VEC &r, double a, double b, double c, VEC &Vg, double &V)
 Computes the centroid of a nd triangle with weighted points. More...
 
template<class VEC >
VEC random_point_in_triangle (const VEC &p1, const VEC &p2, const VEC &p3)
 Generates a random point in a nd triangle. More...
 
template<class VEC >
VEC random_point_in_tetra (const VEC &p1, const VEC &p2, const VEC &p3, const VEC &p4)
 Generates a random point in a nd tetrahedron. More...
 
template<class VEC >
double point_segment_squared_distance (const VEC &point, const VEC &V0, const VEC &V1, VEC &closest_point, double &lambda0, double &lambda1)
 Computes the point closest to a given point in a nd segment. More...
 
template<class VEC >
double point_segment_squared_distance (const VEC &point, const VEC &V0, const VEC &V1)
 Computes the point closest to a given point in a nd segment. More...
 
template<class VEC >
double point_triangle_squared_distance (const VEC &point, const VEC &V0, const VEC &V1, const VEC &V2, VEC &closest_point, double &lambda0, double &lambda1, double &lambda2)
 Computes the point closest to a given point in a nd triangle. More...
 
template<class VEC >
double point_triangle_squared_distance (const VEC &p, const VEC &q1, const VEC &q2, const VEC &q3)
 Computes the squared distance between a point and a nd triangle. More...
 
double tetra_volume_from_edge_lengths (double u, double U, double v, double V, double w, double W)
 Computes the volume of a tetrahedron from edge lengths. More...
 
template<class VEC >
double tetra_volume (const VEC &p1, const VEC &p2, const VEC &p3, const VEC &p4)
 Computes the volume of a nd tetrahedron. More...
 
template<int DIM>
double tetra_volume (const double *p1, const double *p2, const double *p3, const double *p4)
 Computes the volume of a nd tetrahedron. More...
 
template<>
double tetra_volume< 3 > (const double *p1, const double *p2, const double *p3, const double *p4)
 Computes the volume of a 3d tetrahedron. More...
 
const vec3mesh_vertex (const Mesh &M, index_t v)
 Gets a mesh vertex by its index. More...
 
const vec3mesh_vertex_ref (const Mesh &M, index_t v)
 Gets a mesh vertex by its index. More...
 
vec3mesh_vertex_ref (Mesh &M, index_t v)
 Gets a mesh vertex by its index. More...
 
const vec3mesh_corner_vertex (const Mesh &M, index_t c)
 Gets a mesh vertex by an incident corner index. More...
 
vec3mesh_corner_vertex_ref (Mesh &M, index_t c)
 Gets a mesh vertex by an incident corner index. More...
 
const vec3mesh_vertex_normal (const Mesh &M, index_t v)
 Gets a mesh vertex normal by vertex index. More...
 
vec3mesh_vertex_normal_ref (Mesh &M, index_t v)
 Gets a mesh vertex normal by vertex index. More...
 
const vec3mesh_vertex_normal_ref (const Mesh &M, index_t v)
 Gets a mesh vertex normal by vertex index. More...
 
double mesh_facet_area (const Mesh &M, index_t f, index_t dim=0)
 Computes the area of a facet. More...
 
vec3 mesh_facet_normal (const Mesh &M, index_t f)
 Computes the normal to a mesh facet. More...
 
vec3 mesh_facet_center (const Mesh &M, index_t f)
 Gets the centroid of the vertices of a facet in a mesh. More...
 
vec3 mesh_cell_center (const Mesh &M, index_t c)
 Gets the centroid of the vertices of a cell in a mesh. More...
 
vec3 mesh_tet_center (const Mesh &M, index_t t)
 Gets the centroid of a tetrahedron in a mesh. More...
 
vec3 mesh_corner_vector (const Mesh &M, index_t c1)
 Gets a vector by a mesh corner. More...
 
double mesh_normal_angle (const Mesh &M, index_t c)
 Computes the angle between the normal vectors of two mesh facets sharing an edge. More...
 
double mesh_unsigned_normal_angle (const Mesh &M, index_t f1, index_t f2)
 Computes the angle between the normal vectors of two mesh facets sharing an edge. More...
 
double mesh_area (const Mesh &M, index_t dim)
 Computes the total surface area of a mesh in arbitrary dimension. More...
 
double mesh_area (const Mesh &M)
 Computes the total surface area of a mesh. More...
 
double mesh_enclosed_volume (const Mesh &M)
 Computes the volume enclosed by a surfacic mesh. More...
 
const vec3halfedge_vertex_from (const Mesh &M, const MeshHalfedges::Halfedge &H)
 Gets the origin point of a Halfedge. More...
 
const vec3halfedge_vertex_to (const Mesh &M, const MeshHalfedges::Halfedge &H)
 Gets the arrow extremity point of a Halfedge. More...
 
vec3 halfedge_vector (const Mesh &M, const MeshHalfedges::Halfedge &H)
 Gets a 3d vector that connects the origin with the arrow extremity of a Halfedge. More...
 
double edge_length (const Mesh &M, const MeshHalfedges::Halfedge &H)
 Gets the length of a Halfedge. More...
 
index_t colocate (const double *points, coord_index_t dim, index_t nb_points, vector< index_t > &old2new, double tolerance=0.0, index_t stride=0, const std::string &nn_algo="default")
 Finds sets of identical points in a point set. More...
 
index_t colocate_by_lexico_sort (const double *points, coord_index_t dim, index_t nb_points, vector< index_t > &old2new, index_t stride)
 Finds sets of identical points in a point set. More...
 

Detailed Description

Geometric functions and utilities.

Function Documentation

◆ angle()

double GEO::Geom::angle ( const vec3 a,
const vec3 b 
)
inline

Computes the angle between two 3d vectors.

Computes the angle between two 2d vectors.

Parameters
[in]afirst vector
[in]bsecond vector
Returns
the angle between a and b in radians, in the interval \( [ 0 \ldots \pi ] \).
Parameters
[in]afirst vector
[in]bsecond vector
Returns
the angle between and in radians, in the interval \( [-\pi \ldots \pi] \)

Definition at line 266 of file geometry.h.

◆ barycenter() [1/2]

vec3 GEO::Geom::barycenter ( const vec3 p1,
const vec3 p2 
)
inline

Computes the barycenter of two points in 3d.

Computes the barycenter of two points in 2d.

Parameters
[in]p1first point
[in]p2second point
Returns
the barycenter of p1 and p2

Definition at line 189 of file geometry.h.

◆ barycenter() [2/2]

vec3 GEO::Geom::barycenter ( const vec3 p1,
const vec3 p2,
const vec3 p3 
)
inline

Computes the barycenter of three points in 3d.

Computes the barycenter of three points in 2d.

Parameters
[in]p1first point
[in]p2second point
[in]p3third point
Returns
the barycenter of p1, p2 and p3

Definition at line 217 of file geometry.h.

◆ colocate()

index_t GEO::Geom::colocate ( const double *  points,
coord_index_t  dim,
index_t  nb_points,
vector< index_t > &  old2new,
double  tolerance = 0.0,
index_t  stride = 0,
const std::string &  nn_algo = "default" 
)

Finds sets of identical points in a point set.

Parameters
[in]pointsthe point array
[in]dimdimension of the points
[in]nb_pointsnumber of points
[out]old2newan array of size nb_points.
[in]tolerancethreshold for colocating points.
[in]stridenumber of doubles between two consecutive points (set to dim if unspecified).
[in]nn_algofactory name for nearest neighbor search.
Returns
the number of unique points

◆ colocate_by_lexico_sort()

index_t GEO::Geom::colocate_by_lexico_sort ( const double *  points,
coord_index_t  dim,
index_t  nb_points,
vector< index_t > &  old2new,
index_t  stride 
)

Finds sets of identical points in a point set.

This version uses a lexicographic sort. It does not have a 'tolerance' parameter (only points with exactly the same coordinates can be colocated).

Parameters
[in]pointsthe point array
[in]dimdimension of the points
[in]nb_pointsnumber of points
[out]old2newan array of size nb_points.
[in]stridenumber of doubles between two consecutive points (set to dim if unspecified).
Returns
the number of unique points

◆ cos_angle()

double GEO::Geom::cos_angle ( const vec3 a,
const vec3 b 
)
inline

Computes the cosine of the angle between two 3d vectors.

Computes the cosine of the angle between two 2d vectors.

Parameters
[in]afirst vector
[in]bsecond vector
Returns
the cosine of the angle between a and b

Definition at line 249 of file geometry.h.

◆ det()

double GEO::Geom::det ( const vec2 a,
const vec2 b 
)
inline

Computes the determinant of two vectors.

Parameters
[in]afirst vector
[in]bsecond vector
Returns
the determinant of a and b

Definition at line 292 of file geometry.h.

◆ distance() [1/2]

template<class COORD_T >
double GEO::Geom::distance ( const COORD_T *  p1,
const COORD_T *  p2,
coord_index_t  dim 
)
inline

Computes the distance between two nd points.

Parameters
[in]p1a pointer to the coordinates of the first point
[in]p2a pointer to the coordinates of the second point
[in]dimdimension (number of coordinates of the points)
Returns
the distance between p1 and p2
Template Parameters
COORD_Tthe numeric type of the point coordinates

Definition at line 84 of file geometry_nd.h.

◆ distance() [2/2]

template<class VEC >
double GEO::Geom::distance ( const VEC &  p1,
const VEC &  p2 
)
inline

Computes the distance between two nd points.

Parameters
[in]p1first point
[in]p2second point
Template Parameters
VECthe class that represents the points. VEC needs to implement data(), that returns a pointer to the coordinates of the point.
Returns
the distance between p1 and p2

Definition at line 120 of file geometry_nd.h.

◆ distance2() [1/2]

template<class COORD_T >
double GEO::Geom::distance2 ( const COORD_T *  p1,
const COORD_T *  p2,
coord_index_t  dim 
)
inline

Computes the squared distance between two nd points.

Parameters
[in]p1a pointer to the coordinates of the first point
[in]p2a pointer to the coordinates of the second point
[in]dimdimension (number of coordinates of the points)
Returns
the squared distance between p1 and p2
Template Parameters
COORD_Tthe numeric type of the point coordinates

Definition at line 65 of file geometry_nd.h.

◆ distance2() [2/2]

template<class VEC >
double GEO::Geom::distance2 ( const VEC &  p1,
const VEC &  p2 
)
inline

Computes the squared distance between two nd points.

Parameters
[in]p1first point
[in]p2second point
Template Parameters
VECthe class that represents the points. VEC needs to implement data(), that returns a pointer to the coordinates of the point.
Returns
the squared distance between p1 and p2

Definition at line 100 of file geometry_nd.h.

◆ edge_length()

double GEO::Geom::edge_length ( const Mesh M,
const MeshHalfedges::Halfedge H 
)
inline

Gets the length of a Halfedge.

Parameters
[in]Mthe Mesh
[in]Hthe Halfedge
Returns
the 3d length of H

Definition at line 358 of file mesh_halfedges.h.

◆ halfedge_vector()

vec3 GEO::Geom::halfedge_vector ( const Mesh M,
const MeshHalfedges::Halfedge H 
)
inline

Gets a 3d vector that connects the origin with the arrow extremity of a Halfedge.

Parameters
[in]Mthe Mesh
[in]Hthe Halfedge
Returns
a 3d vector that connects the origin with the arrow extremity of H

Definition at line 346 of file mesh_halfedges.h.

◆ halfedge_vertex_from()

const vec3& GEO::Geom::halfedge_vertex_from ( const Mesh M,
const MeshHalfedges::Halfedge H 
)
inline

Gets the origin point of a Halfedge.

Parameters
[in]Mthe mesh
[in]Hthe Halfedge
Returns
a const reference to the origin of H

Definition at line 319 of file mesh_halfedges.h.

◆ halfedge_vertex_to()

const vec3& GEO::Geom::halfedge_vertex_to ( const Mesh M,
const MeshHalfedges::Halfedge H 
)
inline

Gets the arrow extremity point of a Halfedge.

Parameters
[in]Mthe mesh
[in]Hthe Halfedge
Returns
a const reference to the arrow extremity of H

Definition at line 331 of file mesh_halfedges.h.

◆ has_nan()

bool GEO::Geom::has_nan ( const vec3 v)
inline

Tests whether a 3d vector has a NaN (not a number) coordinate.

Tests whether a 2d vector has a NaN (not a number) coordinate.

Parameters
[in]va 3d vector
Returns
true if one of the coordinates is a NaN, false otherwise
Parameters
[in]va 2d vector
Returns
true if one of the coordinates is a NaN, false otherwise

Definition at line 429 of file geometry.h.

◆ mesh_area() [1/2]

double GEO::Geom::mesh_area ( const Mesh M)
inline

Computes the total surface area of a mesh.

Parameters
[in]Mthe mesh
Returns
the area of the mesh computed in M.vertices.dimension() dim.

Definition at line 301 of file mesh_geometry.h.

◆ mesh_area() [2/2]

double GEO::Geom::mesh_area ( const Mesh M,
index_t  dim 
)

Computes the total surface area of a mesh in arbitrary dimension.

Parameters
[in]Mthe mesh
[in]dimthe dimension to be used for the computation
Returns
the area of the mesh M computed in dim d.
Precondition
dim <= M.vertices.dimension()

◆ mesh_cell_center()

vec3 GEO::Geom::mesh_cell_center ( const Mesh M,
index_t  c 
)
inline

Gets the centroid of the vertices of a cell in a mesh.

Parameters
[in]Mthe mesh
[in]cthe index of the facet
Returns
the 3d centroid of facet f in M

Definition at line 219 of file mesh_geometry.h.

◆ mesh_corner_vector()

vec3 GEO::Geom::mesh_corner_vector ( const Mesh M,
index_t  c1 
)
inline

Gets a vector by a mesh corner.

Parameters
[in]Ma const reference to the mesh
[in]c1a corner index in M
Returns
a vector originating at c1 and pointing at the next corner around the facet incident to c1
Precondition
M.facets.are_simplices()

Definition at line 256 of file mesh_geometry.h.

◆ mesh_corner_vertex()

const vec3& GEO::Geom::mesh_corner_vertex ( const Mesh M,
index_t  c 
)
inline

Gets a mesh vertex by an incident corner index.

Parameters
[in]Mthe mesh
[in]cthe index of a corner incident to the vertex
Returns
a reference to the vth vertex of a mesh
Precondition
M.vertices.dimension() >= 3

Definition at line 100 of file mesh_geometry.h.

◆ mesh_corner_vertex_ref()

vec3& GEO::Geom::mesh_corner_vertex_ref ( Mesh M,
index_t  c 
)
inline

Gets a mesh vertex by an incident corner index.

Parameters
[in]Mthe mesh
[in]cthe index of a corner incident to the vertex
Returns
a const reference to the vth vertex of a mesh
Precondition
M.vertices.dimension() >= 3

Definition at line 111 of file mesh_geometry.h.

◆ mesh_enclosed_volume()

double GEO::Geom::mesh_enclosed_volume ( const Mesh M)

Computes the volume enclosed by a surfacic mesh.

Parameters
[in]Ma closed surfacic mesh.
Returns
the volume enclosed by M.

◆ mesh_facet_area()

double GEO::Geom::mesh_facet_area ( const Mesh M,
index_t  f,
index_t  dim = 0 
)
inline

Computes the area of a facet.

Parameters
[in]Ma const reference to the mesh
[in]findex of the facet
[in]dimdimension that will be used to compute the area
Returns
the area of the facet, obtained by considering the dim first coordinates of the vertices only

Definition at line 159 of file mesh_geometry.h.

◆ mesh_facet_center()

vec3 GEO::Geom::mesh_facet_center ( const Mesh M,
index_t  f 
)
inline

Gets the centroid of the vertices of a facet in a mesh.

Parameters
[in]Mthe mesh
[in]fthe index of the facet
Returns
the 3d centroid of facet f in M

Definition at line 202 of file mesh_geometry.h.

◆ mesh_facet_normal()

vec3 GEO::Geom::mesh_facet_normal ( const Mesh M,
index_t  f 
)

Computes the normal to a mesh facet.

Parameters
[in]Mthe mesh
[in]fthe facet index in M
Returns
the normal to facet f
Precondition
dimension >= 3
Note
the computed vector is not normalized.

◆ mesh_normal_angle()

double GEO::Geom::mesh_normal_angle ( const Mesh M,
index_t  c 
)

Computes the angle between the normal vectors of two mesh facets sharing an edge.

Parameters
[in]Ma const reference to the mesh
[in]ca corner index in M
Returns
the angle between the facet that contains c and the facet adjacent to c
Precondition
M.facets.are_simplices() && M.corner_adjacent_facet(c) != -1

◆ mesh_tet_center()

vec3 GEO::Geom::mesh_tet_center ( const Mesh M,
index_t  t 
)
inline

Gets the centroid of a tetrahedron in a mesh.

Parameters
[in]Mthe mesh
[in]tthe index of the tetrahedron
Returns
the 3d centroid of tetrahedron t in M

Definition at line 235 of file mesh_geometry.h.

◆ mesh_unsigned_normal_angle()

double GEO::Geom::mesh_unsigned_normal_angle ( const Mesh M,
index_t  f1,
index_t  f2 
)

Computes the angle between the normal vectors of two mesh facets sharing an edge.

Parameters
[in]Ma const reference to the mesh
[in]f1,f2two facets of the mesh
Returns
the angle between f1 and f2 in radians

◆ mesh_vertex()

const vec3& GEO::Geom::mesh_vertex ( const Mesh M,
index_t  v 
)
inline

Gets a mesh vertex by its index.

Parameters
[in]Mthe mesh
[in]vthe index of the vertex
Returns
a const reference to the vth vertex of a mesh
Precondition
M.vertices.dimension() >= 3

Definition at line 64 of file mesh_geometry.h.

◆ mesh_vertex_normal()

const vec3& GEO::Geom::mesh_vertex_normal ( const Mesh M,
index_t  v 
)
inline

Gets a mesh vertex normal by vertex index.

Parameters
[in]Mthe mesh
[in]vthe index of the vertex
Returns
a const reference to the stored normal of vertex v
Precondition
M.vertices.dimension() >= 6

Definition at line 122 of file mesh_geometry.h.

◆ mesh_vertex_normal_ref() [1/2]

const vec3& GEO::Geom::mesh_vertex_normal_ref ( const Mesh M,
index_t  v 
)
inline

Gets a mesh vertex normal by vertex index.

Parameters
[in]Mthe mesh
[in]vthe index of the vertex
Returns
a const reference to the stored normal of vertex v
Precondition
M.vertices.dimension() >= 6

Definition at line 146 of file mesh_geometry.h.

◆ mesh_vertex_normal_ref() [2/2]

vec3& GEO::Geom::mesh_vertex_normal_ref ( Mesh M,
index_t  v 
)
inline

Gets a mesh vertex normal by vertex index.

Parameters
[in]Mthe mesh
[in]vthe index of the vertex
Returns
a reference to the stored normal of vertex v
Precondition
M.vertices.dimension() >= 6

Definition at line 134 of file mesh_geometry.h.

◆ mesh_vertex_ref() [1/2]

const vec3& GEO::Geom::mesh_vertex_ref ( const Mesh M,
index_t  v 
)
inline

Gets a mesh vertex by its index.

Parameters
[in]Mthe mesh
[in]vthe index of the vertex
Returns
a const reference to the vth vertex of a mesh
Precondition
M.vertices.dimension() >= 3

Definition at line 76 of file mesh_geometry.h.

◆ mesh_vertex_ref() [2/2]

vec3& GEO::Geom::mesh_vertex_ref ( Mesh M,
index_t  v 
)
inline

Gets a mesh vertex by its index.

Parameters
[in]Mthe mesh
[in]vthe index of the vertex
Returns
a reference to the vth vertex of a mesh
Precondition
M.vertices.dimension() >= 3

Definition at line 88 of file mesh_geometry.h.

◆ perpendicular()

vec3 GEO::Geom::perpendicular ( const vec3 V)

Computes a 3d vector orthogonal to another one.

Parameters
[in]Va 3d vector
Returns
a 3d vector orthogonal to V

◆ point_segment_squared_distance() [1/2]

template<class VEC >
double GEO::Geom::point_segment_squared_distance ( const VEC &  point,
const VEC &  V0,
const VEC &  V1 
)
inline

Computes the point closest to a given point in a nd segment.

Parameters
[in]pointthe query point
[in]V0first extremity of the segment
[in]V1second extremity of the segment
Template Parameters
VECthe class that represents the points.
Returns
the squared distance between the point and the segment [V0, V1]

Definition at line 441 of file geometry_nd.h.

◆ point_segment_squared_distance() [2/2]

template<class VEC >
double GEO::Geom::point_segment_squared_distance ( const VEC &  point,
const VEC &  V0,
const VEC &  V1,
VEC &  closest_point,
double &  lambda0,
double &  lambda1 
)
inline

Computes the point closest to a given point in a nd segment.

Parameters
[in]pointthe query point
[in]V0first extremity of the segment
[in]V1second extremity of the segment
[out]closest_pointthe point closest to point in the segment [V0, V1]
[out]lambda0barycentric coordinate of the closest point relative to V0
[out]lambda1barycentric coordinate of the closest point relative to V1
Template Parameters
VECthe class that represents the points.
Returns
the squared distance between the point and the segment [V0, V1]

Definition at line 403 of file geometry_nd.h.

◆ point_triangle_squared_distance() [1/2]

template<class VEC >
double GEO::Geom::point_triangle_squared_distance ( const VEC &  p,
const VEC &  q1,
const VEC &  q2,
const VEC &  q3 
)
inline

Computes the squared distance between a point and a nd triangle.

See http://www.geometrictools.com/LibMathematics/Distance/Distance.html

Parameters
[in]pthe query point
[in]q1first vertex of the triangle
[in]q2second vertex of the triangle
[in]q3third vertex of the triangle
Template Parameters
VECthe class that represents the points.
Returns
the squared distance between the point and the triangle (V0, V1, V2)

Definition at line 696 of file geometry_nd.h.

◆ point_triangle_squared_distance() [2/2]

template<class VEC >
double GEO::Geom::point_triangle_squared_distance ( const VEC &  point,
const VEC &  V0,
const VEC &  V1,
const VEC &  V2,
VEC &  closest_point,
double &  lambda0,
double &  lambda1,
double &  lambda2 
)
inline

Computes the point closest to a given point in a nd triangle.

See http://www.geometrictools.com/LibMathematics/Distance/Distance.html

Parameters
[in]pointthe query point
[in]V0first vertex of the triangle
[in]V1second vertex of the triangle
[in]V2third vertex of the triangle
[out]closest_pointthe point closest to point in the triangle (V0, V1, V2)
[out]lambda0barycentric coordinate of the closest point relative to V0
[out]lambda1barycentric coordinate of the closest point relative to V1
[out]lambda2barycentric coordinate of the closest point relative to V2
Template Parameters
VECthe class that represents the points.
Returns
the squared distance between the point and the triangle (V0, V1, V2)

Definition at line 475 of file geometry_nd.h.

◆ random_point_in_tetra()

template<class VEC >
VEC GEO::Geom::random_point_in_tetra ( const VEC &  p1,
const VEC &  p2,
const VEC &  p3,
const VEC &  p4 
)
inline

Generates a random point in a nd tetrahedron.

Uses Greg Turk's second method (see article in Graphic Gems).

Parameters
[in]p1first vertex of the triangle
[in]p2second vertex of the triangle
[in]p3third vertex of the triangle
[in]p4fourth vertex of the triangle
Returns
a random point in tetrahedron ( p1, p2, p3, p4)
Template Parameters
VECthe class used to represent the vertices of the triangle

Definition at line 364 of file geometry_nd.h.

◆ random_point_in_triangle() [1/2]

template<class VEC >
VEC GEO::Geom::random_point_in_triangle ( const VEC &  p1,
const VEC &  p2,
const VEC &  p3 
)
inline

Generates a random point in a nd triangle.

Uses Greg Turk's second method (see article in Graphic Gems).

Parameters
[in]p1first vertex of the triangle
[in]p2second vertex of the triangle
[in]p3third vertex of the triangle
Returns
a random point in triangle ( p1, p2, p3 )
Template Parameters
VECthe class used to represent the vertices of the triangle

Definition at line 338 of file geometry_nd.h.

◆ random_point_in_triangle() [2/2]

vec3 GEO::Geom::random_point_in_triangle ( const vec3 p1,
const vec3 p2,
const vec3 p3 
)
inline

Generates a random point in a 3d triangle.

Uses Greg Turk's second method. Reference: Greg Turk, Generating Random Points in Triangles, Graphics Gems, p. 24-28, code: p. 649-650.

Parameters
[in]p1first vertex of the triangle
[in]p2second vertex of the triangle
[in]p3third vertex of the triangle
Returns
a random point in triangle ( p1, p2, p3 )

Definition at line 582 of file geometry.h.

◆ tetra_circum_center()

vec3 GEO::Geom::tetra_circum_center ( const vec3 p1,
const vec3 p2,
const vec3 p3,
const vec3 p4 
)

Computes the center of the circumscribed sphere of 3d tetrahedron.

Parameters
[in]p1first vertex of the tetrahedron
[in]p2second vertex of the tetrahedron
[in]p3third vertex of the tetrahedron
[in]p4fourth vertex of the tetrahedron
Returns
the circumcenter of the tetrahedron (p1, p2, p3, p4)

◆ tetra_signed_volume() [1/2]

double GEO::Geom::tetra_signed_volume ( const double *  p1,
const double *  p2,
const double *  p3,
const double *  p4 
)
inline

Computes the signed volume of a 3d tetrahedron.

Parameters
[in]p1first vertex of the tetrahedron
[in]p2second vertex of the tetrahedron
[in]p3third vertex of the tetrahedron
[in]p4fourth vertex of the tetrahedron
Returns
the signed volume of the tetrahedron (p1, p2, p3, p4)

Definition at line 479 of file geometry.h.

◆ tetra_signed_volume() [2/2]

double GEO::Geom::tetra_signed_volume ( const vec3 p1,
const vec3 p2,
const vec3 p3,
const vec3 p4 
)
inline

Computes the signed volume of a 3d tetrahedron.

Parameters
[in]p1first vertex of the tetrahedron
[in]p2second vertex of the tetrahedron
[in]p3third vertex of the tetrahedron
[in]p4fourth vertex of the tetrahedron
Returns
the signed volume of the tetrahedron (p1, p2, p3, p4)

Definition at line 463 of file geometry.h.

◆ tetra_volume() [1/3]

template<int DIM>
double GEO::Geom::tetra_volume ( const double *  p1,
const double *  p2,
const double *  p3,
const double *  p4 
)
inline

Computes the volume of a nd tetrahedron.

Uses a form of generalized Heron formula: W. Kahan, "What has the Volume of a Tetrahedron to do with Computer Programming Languages?"

Parameters
[in]p1first vertex of the tetrahedron
[in]p2second vertex of the tetrahedron
[in]p3third vertex of the tetrahedron
[in]p4fourth vertex of the tetrahedron
Template Parameters
DIMdimension of the points
Returns
the volume of the tetrahedron (p1, p2, p3, p4)

Definition at line 783 of file geometry_nd.h.

◆ tetra_volume() [2/3]

template<class VEC >
double GEO::Geom::tetra_volume ( const VEC &  p1,
const VEC &  p2,
const VEC &  p3,
const VEC &  p4 
)
inline

Computes the volume of a nd tetrahedron.

Uses a form of generalized Heron formula: W. Kahan, "What has the Volume of a Tetrahedron to do with Computer Programming Languages?"

Parameters
[in]p1first vertex of the tetrahedron
[in]p2second vertex of the tetrahedron
[in]p3third vertex of the tetrahedron
[in]p4fourth vertex of the tetrahedron
Template Parameters
VECthe class that represents the points
Returns
the volume of the tetrahedron (p1, p2, p3, p4)

Definition at line 757 of file geometry_nd.h.

◆ tetra_volume() [3/3]

double GEO::Geom::tetra_volume ( const vec3 p1,
const vec3 p2,
const vec3 p3,
const vec3 p4 
)
inline

Computes the volume of a 3d tetrahedron.

Parameters
[in]p1first vertex of the tetrahedron
[in]p2second vertex of the tetrahedron
[in]p3third vertex of the tetrahedron
[in]p4fourth vertex of the tetrahedron
Returns
the volume of the tetrahedron (p1, p2, p3, p4)

Definition at line 500 of file geometry.h.

◆ tetra_volume< 3 >()

template<>
double GEO::Geom::tetra_volume< 3 > ( const double *  p1,
const double *  p2,
const double *  p3,
const double *  p4 
)
inline

Computes the volume of a 3d tetrahedron.

Partial specialization of tetra_volume() for DIM == 3. It uses the standard formula, much simpler than the N dimension version.

Parameters
[in]p1first vertex of the tetrahedron
[in]p2second vertex of the tetrahedron
[in]p3third vertex of the tetrahedron
[in]p4fourth vertex of the tetrahedron
Returns
the volume of the tetrahedron (p1, p2, p3, p4)

Definition at line 809 of file geometry_nd.h.

◆ tetra_volume_from_edge_lengths()

double GEO::Geom::tetra_volume_from_edge_lengths ( double  u,
double  U,
double  v,
double  V,
double  w,
double  W 
)
inline

Computes the volume of a tetrahedron from edge lengths.

Uses a form of generalized Heron formula: W. Kahan, "What has the Volume of a Tetrahedron to do with Computer Programming Languages?"

Parameters
[in]udistance between p1 and p4
[in]Udistance between p2 and p3
[in]vdistance between p2 and p4
[in]Vdistance between p3 and p1
[in]wdistance between p3 and p4
[in]Wdistance between p1 and p2
Returns
the volume of the tetrahedron

Definition at line 720 of file geometry_nd.h.

◆ triangle_area() [1/3]

template<class COORD_T >
double GEO::Geom::triangle_area ( const COORD_T *  p1,
const COORD_T *  p2,
const COORD_T *  p3,
coord_index_t  dim 
)
inline

Computes the area of a nd triangle.

Uses Heron formula (that computes the area from the lengths of the three edges).

Parameters
[in]p1a pointer to the coordinates of the first vertex of the triangle
[in]p2a pointer to the coordinates of the second vertex of the triangle
[in]p3a pointer to the coordinates of the third vertex of the triangle
[in]dimdimension of the points
Template Parameters
COORD_Tthe numeric type that represents the coordinates of the points
Returns
the area of triangle ( p1, p2, p3)

Definition at line 143 of file geometry_nd.h.

◆ triangle_area() [2/3]

template<class VEC >
double GEO::Geom::triangle_area ( const VEC &  p1,
const VEC &  p2,
const VEC &  p3 
)
inline

Computes the area of a nd triangle.

Uses Heron formula (that compures the area from the lengths of the three edges).

Parameters
[in]p1first vertex of the triangle
[in]p2second vertex of the triangle
[in]p3third vertex of the triangle
Template Parameters
VECthe class used to represent the vertices of the triangle
Returns
the area of triangle (p1, p2, p3)

Definition at line 212 of file geometry_nd.h.

◆ triangle_area() [3/3]

double GEO::Geom::triangle_area ( const vec3 p1,
const vec3 p2,
const vec3 p3 
)
inline

Computes the area of a 3d triangle.

Computes the area of a 2d triangle.

Parameters
[in]p1,p2,p3the three vertices of the triangle
Returns
the area of the triangle (p1, p2, p3).
Parameters
[in]p1first vertex of the triangle
[in]p2second vertex of the triangle
[in]p3third vertex of the triangle
Returns
the area of the triangle (p1, p2, p3).

Definition at line 348 of file geometry.h.

◆ triangle_area_2d()

double GEO::Geom::triangle_area_2d ( const double *  p1,
const double *  p2,
const double *  p3 
)
inline

Computes the area of a 2d triangle.

Parameters
[in]p1first vertex of the triangle
[in]p2second vertex of the triangle
[in]p3third vertex of the triangle
Returns
the area of the triangle (p1, p2, p3).

Definition at line 406 of file geometry.h.

◆ triangle_area_3d()

double GEO::Geom::triangle_area_3d ( const double *  p1,
const double *  p2,
const double *  p3 
)
inline

Computes the area of a 3d triangle.

Parameters
[in]p1,p2,p3the three vertices of the triangle
Returns
the area of the triangle (p1, p2, p3).

Definition at line 326 of file geometry.h.

◆ triangle_centroid() [1/3]

template<class COORD_T >
void GEO::Geom::triangle_centroid ( const COORD_T *  p,
const COORD_T *  q,
const COORD_T *  r,
COORD_T  a,
COORD_T  b,
COORD_T  c,
double *  Vg,
double &  V,
coord_index_t  dim 
)
inline

Computes the centroid of a 3d triangle with weighted points.

The integrated weight varies linearly in the triangle.

Parameters
[in]pa pointer to the coordinates of the first vertex of the triangle
[in]qa pointer to the coordinates of the second vertex of the triangle
[in]ra pointer to the coordinates of the third vertex of the triangle
[in]athe weight associated with vertex p
[in]bthe weight associated with vertex q
[in]cthe weight associated with vertex r
[out]Vgthe total weight times the centroid ( a pointer to a caller-allocated array of dim COORD_Ts)
[out]Vthe total weight
[in]dimthe dimension of the vertices
Template Parameters
COORD_Tthe numeric type that represents the coordinates of the points

Definition at line 178 of file geometry_nd.h.

◆ triangle_centroid() [2/3]

template<class VEC >
void GEO::Geom::triangle_centroid ( const VEC &  p,
const VEC &  q,
const VEC &  r,
double  a,
double  b,
double  c,
VEC &  Vg,
double &  V 
)
inline

Computes the centroid of a nd triangle with weighted points.

The integrated weight varies linearly in the triangle.

Parameters
[in]pfirst vertex of the triangle
[in]qsecond vertex of the triangle
[in]rthird vertex of the triangle
[in]athe weight associated with vertex p
[in]bthe weight associated with vertex q
[in]cthe weight associated with vertex r
[out]Vgthe total weight times the centroid
[out]Vthe total weight
Template Parameters
VECthe class used to represent the vertices of the triangle

Definition at line 311 of file geometry_nd.h.

◆ triangle_centroid() [3/3]

void GEO::Geom::triangle_centroid ( const vec3 p,
const vec3 q,
const vec3 r,
double  a,
double  b,
double  c,
vec3 Vg,
double &  V 
)
inline

Computes the centroid of a 3d triangle with weighted points.

The integrated weight varies linearly in the triangle.

Parameters
[in]pfirst vertex of the triangle
[in]qsecond vertex of the triangle
[in]rthird vertex of the triangle
[in]athe weight associated with vertex p
[in]bthe weight associated with vertex q
[in]cthe weight associated with vertex r
[out]Vgthe total weight times the centroid
[out]Vthe total weight

Definition at line 534 of file geometry.h.

◆ triangle_circumcenter() [1/2]

template<class POINT >
POINT GEO::Geom::triangle_circumcenter ( const POINT &  Q1,
const POINT &  Q2,
const POINT &  Q3,
double *  denom = nullptr 
)

Computes the center of the circumscribed circle of a nd triangle.

Parameters
[in]Q1first vertex of the triangle
[in]Q2second vertex of the triangle
[in]Q3third vertex of the triangle
[out]denomif the parameter is non null, it is set to the denominator of the barycentric coordinates of the circumcenter.
Template Parameters
POINTthe class used to represent the vertices of the triangle
Returns
the circumcenter of the triangle (p1, p2, p3).

Definition at line 267 of file geometry_nd.h.

◆ triangle_circumcenter() [2/2]

vec2 GEO::Geom::triangle_circumcenter ( const vec2 p1,
const vec2 p2,
const vec2 p3 
)

Computes the center of the circumscribed circle of a 2d triangle.

Parameters
[in]p1first vertex of the triangle
[in]p2second vertex of the triangle
[in]p3third vertex of the triangle
Returns
the circumcenter of the triangle (p1, p2, p3).

◆ triangle_mass() [1/2]

template<class VEC >
double GEO::Geom::triangle_mass ( const VEC &  p,
const VEC &  q,
const VEC &  r,
double  a,
double  b,
double  c 
)
inline

Computes the mass of a nd triangle with weighted points.

The integrated weight varies linearly in the triangle.

Parameters
[in]pfirst vertex of the triangle
[in]qsecond vertex of the triangle
[in]rthird vertex of the triangle
[in]athe weight associated with vertex p
[in]bthe weight associated with vertex q
[in]cthe weight associated with vertex r
Template Parameters
VECthe class used to represent the vertices of the triangle
Returns
the mass of the weighted triangle ( p, a), ( q, b), ( r, c)

Definition at line 237 of file geometry_nd.h.

◆ triangle_mass() [2/2]

double GEO::Geom::triangle_mass ( const vec3 p,
const vec3 q,
const vec3 r,
double  a,
double  b,
double  c 
)
inline

Computes the mass of a 3d triangle with weighted points.

The integrated weight varies linearly in the triangle.

Parameters
[in]pfirst vertex of the triangle
[in]qsecond vertex of the triangle
[in]rthird vertex of the triangle
[in]athe weight associated with vertex p
[in]bthe weight associated with vertex q
[in]cthe weight associated with vertex r
Returns
the mass of the weighted triangle ( p, a), ( q, b), ( r, c)

Definition at line 563 of file geometry.h.

◆ triangle_normal()

vec3 GEO::Geom::triangle_normal ( const vec3 p1,
const vec3 p2,
const vec3 p3 
)
inline

Computes the normal of a 3d triangle.

Parameters
[in]p1,p2,p3the three vertices of the triangle
Returns
the normal of the triangle (p1, p2, p3).

Definition at line 315 of file geometry.h.

◆ triangle_signed_area()

double GEO::Geom::triangle_signed_area ( const vec2 p1,
const vec2 p2,
const vec2 p3 
)
inline

Computes the area of a 2d triangle.

Parameters
[in]p1first vertex of the triangle
[in]p2second vertex of the triangle
[in]p3third vertex of the triangle
Returns
the signed area of the triangle (p1, p2, p3), positive if the triangle is oriented clockwise, negative otherwise.

Definition at line 380 of file geometry.h.

◆ triangle_signed_area_2d()

double GEO::Geom::triangle_signed_area_2d ( const double *  p1,
const double *  p2,
const double *  p3 
)
inline

Computes the area of a 2d triangle.

Parameters
[in]p1first vertex of the triangle
[in]p2second vertex of the triangle
[in]p3third vertex of the triangle
Returns
the signed area of the 2D triangle (p1, p2, p3), positive if the triangle is oriented clockwise, negative otherwise.

Definition at line 362 of file geometry.h.