-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGeometry.hh
85 lines (59 loc) · 2.68 KB
/
Geometry.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef _AMANZI_GEOM_H
#define _AMANZI_GEOM_H
#include <vector>
#include "Point.hh"
namespace Amanzi
{
namespace AmanziGeometry
{
// Return the volume and centroid of a general polyhedron
//
// ccoords - vertices of the polyhedron (in no particular order)
// nf - number of faces of polyhedron
// nfnodes - number of nodes for each face
// fcoords - linear array of face coordinates in in ccw manner
// assuming normal of face is pointing out (
//
// So if the polyhedron has 5 faces with 5,3,3,3 and 3 nodes each
// then entries 1-5 of fcoords describes face 1, entries 6-9
// describes face 2 and so on
//
// So much common work has to be done for computing the centroid
// and volume calculations that they have been combined into one
//
// The volume of all polyhedra except tets is computed as a sum of
// volumes of tets created by connecting the polyhedron center to
// a face center and an edge of the face
void polyhed_get_vol_centroid(const std::vector<Point> ccoords,
const std::size_t nf,
const std::vector<std::size_t> nfnodes,
const std::vector<Point> fcoords,
double *volume,
Point *centroid);
// Is point in polyhed
bool point_in_polyhed(const Point testpnt,
const std::vector<Point> ccoords,
const std::size_t nf,
const std::vector<std::size_t> nfnodes,
const std::vector<Point> fcoords);
// Compute area, centroid and normal of polygon
// In 2D, the area is computed by a contour integral around the
// perimeter. In 3D, the area is computed by connecting a
// "center" point of the polygon to the edges of the polygon and
// summing the areas of the resulting triangles
//
// The normal of a 3D polygon is computed as the sum of the area
// weighted normals of the triangular facets
void polygon_get_area_centroid_normal(const std::vector<Point> coords,
double *area, Point *centroid,
Point *normal);
// Get area weighted normal of polygon
// In 2D, the normal is unambiguous - the normal is evaluated at one corner
// In 3D, the procedure evaluates the normal at each corner and averages it
// Point polygon_get_normal(const std::vector<Point> coords);
// Is point in polygon
bool point_in_polygon(const Point testpnt,
const std::vector<Point> coords);
} // end namespace AmanziGeometry
} // end namespace Amanzi
#endif