forked from sb-ncbr/ChargeFW2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geometry.cpp
35 lines (25 loc) · 1003 Bytes
/
geometry.cpp
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
#include <cmath>
#include "structures/atom.h"
#include "structures/bond.h"
#include "geometry.h"
double distance(const Atom &atom1, const Atom &atom2) {
double dx = atom1.pos()[0] - atom2.pos()[0];
double dy = atom1.pos()[1] - atom2.pos()[1];
double dz = atom1.pos()[2] - atom2.pos()[2];
return std::sqrt(dx * dx + dy * dy + dz * dz);
}
double distance(const Atom &atom, const Bond &bond, bool weighted) {
std::array<double, 3> bc = bond.get_center(weighted);
double dx = atom.pos()[0] - bc[0];
double dy = atom.pos()[1] - bc[1];
double dz = atom.pos()[2] - bc[2];
return std::sqrt(dx * dx + dy * dy + dz * dz);
}
double distance(const Bond &bond1, const Bond &bond2, bool weighted) {
std::array<double, 3> bc1 = bond1.get_center(weighted);
std::array<double, 3> bc2 = bond2.get_center(weighted);
double dx = bc1[0] - bc2[0];
double dy = bc1[1] - bc2[1];
double dz = bc1[2] - bc2[2];
return std::sqrt(dx * dx + dy * dy + dz * dz);
}