2 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 // + This file is part of enGrid. +
6 // + Copyright 2008,2009 Oliver Gloth +
8 // + enGrid is free software: you can redistribute it and/or modify +
9 // + it under the terms of the GNU General Public License as published by +
10 // + the Free Software Foundation, either version 3 of the License, or +
11 // + (at your option) any later version. +
13 // + enGrid is distributed in the hope that it will be useful, +
14 // + but WITHOUT ANY WARRANTY; without even the implied warranty of +
15 // + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +
16 // + GNU General Public License for more details. +
18 // + You should have received a copy of the GNU General Public License +
19 // + along with enGrid. If not, see <http://www.gnu.org/licenses/>. +
21 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
23 #ifndef geometrytools_H
24 #define geometrytools_H
26 #include "math/mathvector.h"
27 #include "math/smallsquarematrix.h"
29 #include <vtkUnstructuredGrid.h>
31 namespace GeometryTools
34 /** Converts radians to degrees */
35 double rad2deg( double rad
);
37 /** Converts degrees to radians */
38 double deg2rad( double deg
);
40 void rotate(vec3_t g1
, vec3_t g2
, vec3_t g3
, vec3_t
&b
, double theta
);
42 /** Rotates vector v around vector axis by an angle theta */
43 vec3_t
rotate(vec3_t v
, vec3_t axis
, double theta
);
45 vec3_t
orthogonalVector(vec3_t v
);
47 double intersection(vec3_t x_straight
, vec3_t v_straight
,
48 vec3_t x_plane
, vec3_t n_plane
);
50 double intersection(vec3_t x_straight
, vec3_t v_straight
,
51 vec3_t x_plane
, vec3_t u_plane
, vec3_t v_plane
);
53 bool intersection (double &k1
, double &k2
, vec2_t r1
, vec2_t u1
, vec2_t r2
, vec2_t u2
);
55 void sliceTriangle(const vector
<vec3_t
> &Tin
, vec3_t x
, vec3_t n
, vector
<vector
<vec3_t
> > &Tout
);
57 double tetraVol(vec3_t x1
, vec3_t x2
, vec3_t x3
, vec3_t x4
, bool neg
= false);
59 double pyraVol(vec3_t x1
, vec3_t x2
, vec3_t x3
, vec3_t x4
, vec3_t x5
, bool neg
= false);
61 double prismVol(vec3_t x1
, vec3_t x2
, vec3_t x3
, vec3_t x4
, vec3_t x5
, vec3_t x6
, bool neg
= false);
63 double hexaVol(vec3_t x1
, vec3_t x2
, vec3_t x3
, vec3_t x4
, vec3_t x5
, vec3_t x6
, vec3_t x7
, vec3_t x8
, bool neg
= false);
65 double triArea(vec3_t x1
, vec3_t x2
, vec3_t x3
);
67 double quadArea(vec3_t x1
, vec3_t x2
, vec3_t x3
, vec3_t x4
);
69 vec3_t
triNormal(vec3_t x1
, vec3_t x2
, vec3_t x3
);
71 vec3_t
quadNormal(vec3_t x1
, vec3_t x2
, vec3_t x3
, vec3_t x4
);
73 vec3_t
triNormal(vtkUnstructuredGrid
*grid
, vtkIdType p1
, vtkIdType p2
, vtkIdType p3
);
75 vec3_t
quadNormal(vtkUnstructuredGrid
*grid
, vtkIdType p1
, vtkIdType p2
, vtkIdType p3
, vtkIdType p4
);
77 vec3_t
cellNormal(vtkUnstructuredGrid
*grid
, vtkIdType i
);
79 double cellVA(vtkUnstructuredGrid
*grid
, vtkIdType cellId
, bool neg
= false);
81 inline vec2_t
turnRight(const vec2_t
&v
)
89 inline vec2_t
turnLeft(const vec2_t
&v
)
97 /** return the angle w.r.t. another 3-vector */
98 double angle(const vec3_t
& u
, const vec3_t
& v
);