-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.h
46 lines (40 loc) · 928 Bytes
/
common.h
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
#ifndef COMMON_H
#define COMMON_H
#include <array>
#include "definitions.h"
struct Coords {
union {
struct {
double x, y, z, vx, vy, vz;
};
double data[6];
};
Coords() {}
Coords(const double x, const double y, const double z, const double vx,
const double vy, const double vz)
: x(x), y(y), z(z), vx(vx), vy(vy), vz(vz) {}
double &operator[](int i) { return data[i]; }
const double operator[](int i) const { return data[i]; }
};
struct Coords2d {
double x, y, vx, vy;
};
struct Bbh_coords {
union {
struct {
Coords2d bh1, bh2;
};
double data[8];
};
double &operator[](int i) { return data[i]; }
const double operator[](int i) const { return data[i]; }
std::array<double,4> extract_pos() const
{
return {bh1.x, bh1.y, bh2.x, bh2.y};
}
std::array<double,4> extract_vel() const
{
return {bh1.vx, bh1.vy, bh2.vx, bh2.vy};
}
};
#endif