hemocell
Loading...
Searching...
No Matches
helper
geometryUtils.h
Go to the documentation of this file.
1
/*
2
This file is part of the HemoCell library
3
4
HemoCell is developed and maintained by the Computational Science Lab
5
in the University of Amsterdam. Any questions or remarks regarding this library
6
can be sent to: info@hemocell.eu
7
8
When using the HemoCell library in scientific work please cite the
9
corresponding paper: https://doi.org/10.3389/fphys.2017.00563
10
11
The HemoCell library is free software: you can redistribute it and/or
12
modify it under the terms of the GNU Affero General Public License as
13
published by the Free Software Foundation, either version 3 of the
14
License, or (at your option) any later version.
15
16
The library is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
GNU Affero General Public License for more details.
20
21
You should have received a copy of the GNU Affero General Public License
22
along with this program. If not, see <http://www.gnu.org/licenses/>.
23
*/
24
#ifndef HEMOCELL_GEOMETRY_UTILS_H
25
#define HEMOCELL_GEOMETRY_UTILS_H
26
27
#include "
array.h
"
28
#include "
constant_defaults.h
"
29
30
/*
31
- returns atan2((Va x Vb) . Vn, Va . Vb)
32
- change Va x Vb to Vb x Va for left handed coordinate system
33
Explanation:
34
Va . Vb == |Va| * |Vb| * cos(alpha) (by definition)
35
== |Va| * |Vb| * cos(beta) (cos(alpha) == cos(-alpha) == cos(360° - alpha)
36
37
38
Va x Vb == |Va| * |Vb| * sin(alpha) * n1
39
(by definition; n1 is a unit vector perpendicular to Va and Vb with
40
orientation matching the right-hand rule)
41
42
Therefore (again assuming Vn is normalized):
43
n1 . Vn == 1 when beta < 180
44
n1 . Vn == -1 when beta > 180
45
46
==> (Va x Vb) . Vn == |Va| * |Vb| * sin(beta)
47
==> tan(beta) = sin(beta) / cos(beta) == ((Va x Vb) . Vn) / (Va . Vb)
48
*/
49
inline
T
getAngleBetweenFaces
(
const
hemo::Array<T,3>
n1,
const
hemo::Array<T,3>
n2,
const
hemo::Array<T,3>
edge) {
50
hemo::Array<T,3>
cross = crossProduct (n1, n2);
51
return
std::atan2(dot(cross, edge), dot(n1, n2));
52
};
53
54
#endif
array.h
constant_defaults.h
T
double T
Definition
constant_defaults.h:118
getAngleBetweenFaces
T getAngleBetweenFaces(const hemo::Array< T, 3 > n1, const hemo::Array< T, 3 > n2, const hemo::Array< T, 3 > edge)
Definition
geometryUtils.h:49
hemo::Array
Definition
array.h:39
Generated by
1.9.8