hemocell
Loading...
Searching...
No Matches
geometryUtils.h
Go to the documentation of this file.
1/*
2This file is part of the HemoCell library
3
4HemoCell is developed and maintained by the Computational Science Lab
5in the University of Amsterdam. Any questions or remarks regarding this library
6can be sent to: info@hemocell.eu
7
8When using the HemoCell library in scientific work please cite the
9corresponding paper: https://doi.org/10.3389/fphys.2017.00563
10
11The HemoCell library is free software: you can redistribute it and/or
12modify it under the terms of the GNU Affero General Public License as
13published by the Free Software Foundation, either version 3 of the
14License, or (at your option) any later version.
15
16The library is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19GNU Affero General Public License for more details.
20
21You should have received a copy of the GNU Affero General Public License
22along 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
33Explanation:
34Va . Vb == |Va| * |Vb| * cos(alpha) (by definition)
35 == |Va| * |Vb| * cos(beta) (cos(alpha) == cos(-alpha) == cos(360° - alpha)
36
37
38Va 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
42Therefore (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*/
50 hemo::Array<T,3> cross = crossProduct (n1, n2);
51 return std::atan2(dot(cross, edge), dot(n1, n2));
52};
53
54#endif
double T
Definition constant_defaults.h:118
T getAngleBetweenFaces(const hemo::Array< T, 3 > n1, const hemo::Array< T, 3 > n2, const hemo::Array< T, 3 > edge)
Definition geometryUtils.h:49
Definition array.h:39