-
Notifications
You must be signed in to change notification settings - Fork 0
/
libspaceturtle.h
81 lines (70 loc) · 2.26 KB
/
libspaceturtle.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
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
#ifndef LIBSPACETURTLE
#define LIBSPACETURTLE
#include <math.h>
#define G 0.0000000000667408
#define CALCACCEL(d2, m) G * m / (d2)
#define SQUARE(x) x * x
#define VECTOR_BITS 512 // this is so that loops get sizes that are efficiently vectorized
struct body{
long double xpos; // meters
long double ypos;
long double xvel; // meters/sec
long double yvel;
long double radi;
long double mass; // kg
struct body * next;
unsigned char flags;
void * attribs; // your application can stick whatever it wants here
void * privattribs;
};
struct qtree{
struct qtree * next_node[4];
struct qtree * parent;
struct body * cbody;
long double x;
long double y;
long double w;
long double h;
long double cmx;
long double cmy;
long double mass;
};
struct octree{
struct octree * next_node[8];
struct octree * parent;
struct body3 * cbody;
long double cmx;
long double cmy;
long double cmz;
long double mass;
};
struct body3{
long double xpos;
long double ypos;
long double zpos;
long double xvel;
long double yvel;
long double zvel;
long double radi;
long double mass;
struct body3 * next;
unsigned char flags;
void * attribs;
void * privattribs;
};
struct world_config{
long double tickspersec;
};
int step_forward(struct body * root, struct world_config config, unsigned long long int ticks);
int step_forward3(struct body3 * root, struct world_config config, unsigned long long int ticks);
int step_forward_tctd(struct body * root, struct world_config config, unsigned long long ticks);
struct body * add_body(long double xpos, long double ypos, long double xvel, long double yvel, long double mass,
long double radi, void * attribs, struct body * parent, struct body * root);
struct body3 * add_body3(long double xpos, long double ypos, long double zpos, long double xvel, long double yvel, long double zvel,
long double mass, long double radi, void * attribs, struct body3 * parent, struct body3 * root);
struct qtree * create_qtree(struct body * root, struct qtree * root_node);
//struct octree * create_octree(struct body3 * root);
int delete_qtree(struct qtree * root);
struct body * delete_body(struct body * object, struct body * root);
struct body3 * delete_body3(struct body3 * object, struct body3 * root);
#endif