-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cell.cpp
110 lines (93 loc) · 2.23 KB
/
Cell.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// Created by Benedikt on 08.11.2016.
//
#include <cmath>
#include <iostream>
#include "Cell.h"
using namespace std;
//Konstruktoren
Cell::Cell(int nummer, vector<double> Koordinaten) {
id = nummer;
value = 0;
coords = Koordinaten;
};
Cell::Cell(int nummer, int wert, vector<double> Koordinaten) {
id = nummer;
value = wert;
coords = Koordinaten;
}
Cell::Cell() {
id = -1;
value = -1;
coords = vector<double>();
}
//Getter-Methoden
int Cell::get_id() const {
return id;
}
int Cell::get_value() const {
return value;
}
vector<double> Cell::get_coords() const {
return coords;
}
Basis Cell::get_atoms() {
return base;
}
//Relationen
vector<double> Cell::distance__to(Cell c) {
vector<double> vector1;
for (int i = 0; i < c.get_coords().size(); i++) {
if (i < get_coords().size()) {
vector1.push_back(c.get_coords()[i] - get_coords()[i]);
}
}
return vector1;
}
double Cell::distance_to(Cell c) {
double res = 0;
vector<double> dist = distance__to(c);
for (int i = 0; i < dist.size(); i++) {
res += pow((double) dist[i], dist.size());
}
res = pow(res, 1.0 / dist.size());
return res;
}
//Setter-Methoden
void Cell::set_value(int wert) {
value = wert;
}
void Cell::move_to(vector<double> Koordinaten) {
coords = Koordinaten;
}
void Cell::set_base(Basis basis) {
for (int i = 0; i < basis.Atome().size(); ++i) {
for (int j = 0; j < coords.size(); ++j) {
try {
if (j < basis.Atome()[i].second.size()) {
basis.Atome()[i].second[j] += coords[j];
} else {
throw "Dimension Mismatch";
}
} catch (exception exception1) {
cout << exception1.what();
}
}
}
base = basis;
}
//Operatoren
bool Cell::operator==(const Cell &comp) {
return get_id() == comp.get_id() && get_value() == comp.get_value();
}
bool Cell::operator!=(const Cell &comp) {
return !operator==(comp);
}
//Transformationen
void Cell::move_by(vector<double> Vektor) {
for (int i = 0; i < coords.size(); i++) {
if (i < Vektor.size()) {
coords[i] = Vektor[i];
}
}
}