-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThreeBody.h
65 lines (52 loc) · 1.02 KB
/
ThreeBody.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
#pragma once
#include "Planet.h"
#include <time.h>
#include <math.h>
class ThreeBody
{
public:
ThreeBody()
{
this->gravitationalConstant = 100.0f;
}
virtual void reset()
{
randomPlanet(this->planetA);
randomPlanet(this->planetB);
randomPlanet(this->planetC);
}
virtual void setGravitationalConstant(float c)
{
this->gravitationalConstant = c;
}
virtual void setPlanetAMess(float m)
{
this->planetA.setMess(m);
}
virtual void setPlanetBMess(float m)
{
this->planetB.setMess(m);
}
virtual void setPlanetCMess(float m)
{
this->planetC.setMess(m);
}
Planet& getPlanetA()
{
return this->planetA;
}
Planet& getPlanetB()
{
return this->planetB;
}
Planet& getPlanetC()
{
return this->planetC;
}
virtual void update(float deltaTime) = 0;
protected:
float gravitationalConstant;
Planet planetA, planetB, planetC;
void randomPlanet(Planet& p);
void computeAcceleration(Planet& planet, Planet& p1, Planet& p2, Vec3& acc);
};