-
Notifications
You must be signed in to change notification settings - Fork 0
/
cellgeometry.cpp
37 lines (32 loc) · 1.1 KB
/
cellgeometry.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
36
37
//
// Created by Jon on 25/08/2015.
//
#include "cellgeometry.h"
namespace CIF {
CellGeometry::CellGeometry(double ain, double bin, double cin, double alphain, double betain, double gammain) {
a = ain;
b = bin;
c = cin;
alpha = alphain;
beta = betain;
gamma = gammain;
calculateCartesianBasis();
}
void CellGeometry::calculateCartesianBasis() {
// !! convert to radians
double arad = alpha * (CIF::Utilities::pi / 180);
double brad = beta * (CIF::Utilities::pi / 180);
double grad = gamma * (CIF::Utilities::pi / 180);
// easy enough
avec = {a, 0.0, 0.0};
// slightly trickier
bvec = {b * std::cos(grad), b * std::sin(grad), 0.0};
// WOAH
double cv1 = c * std::cos(brad);
double cv2 = c * (std::cos(arad) - std::cos(brad) * std::cos(grad)) / std::sin(grad);
double cv3 =
c * std::sqrt((std::cos(brad - grad) - std::cos(arad)) * (std::cos(arad) - std::cos(brad + grad))) /
std::sin(grad);
cvec = {cv1, cv2, cv3};
}
}