-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspacecraft.cpp
More file actions
64 lines (53 loc) · 1.3 KB
/
Copy pathspacecraft.cpp
File metadata and controls
64 lines (53 loc) · 1.3 KB
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
#include "spacecraft.h"
#include "trajectory.h"
#include "manoeuvre.h"
#include <cmath>
#include <iostream>
Spacecraft::Spacecraft(Trajectory* a_traj)
{
trajectory = a_traj;
x = trajectory->xPos;
y = trajectory->yPos;
x_v = trajectory->xVel;
y_v = trajectory->yVel;
time = 0;
halted = false;
}
double Spacecraft::getX() {
return x;
}
double Spacecraft::getY() {
return y;
}
void Spacecraft::setX(double setx) {
x = setx;
}
void Spacecraft::setY(double sety) {
y = sety;
}
double Spacecraft::getXVel() {
return x_v;
}
double Spacecraft::getYVel() {
return y_v;
}
void Spacecraft::applyImpulse(double x_acc, double y_acc, int a_time) {
time += a_time;
if (!halted) {
x_v += x_acc * a_time;
y_v += y_acc * a_time;
x += x_v * a_time;
y += y_v * a_time;
if (trajectory->getPoints()->contains(time)) {
std::cout << "Entry found: " << time << "s" << std::endl;
Manoeuvre* man = trajectory->getPoints()->find(time).value();
x_v += (man->deltaV) * cos((180/PI)*(man->heading));
y_v += (man->deltaV) * sin((180/PI)*(man->heading));
}
}
}
void Spacecraft::halt() {
halted = true;
x_v = 0;
y_v = 0;
}