Repository navigation
Expand file tree
/
Copy pathtelemetry.cpp
More file actions
52 lines (46 loc) · 1.38 KB
/
Copy pathtelemetry.cpp
File metadata and controls
52 lines (46 loc) · 1.38 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
#include <iostream>
#include <string>
#include <cmath>
#include "utility.h"
using namespace std;
// Both functions need to be completely rethought
float * velocityUpdate(float velocity[3], float acc[3]) {
float timestep = 0.5;
float* velocityUpdated = new float[3];
for (int n = 0; n < 3; n++) {
*(velocityUpdated + n) = acc[n]*timestep + velocity[n];
}
return velocityUpdated;
}
float * positionalUpdate(float position[3], float velocity[3], float acc[3]) {
float timestep = 0.5;
float *positionUpdated = new float[3];
for (int n = 0; n < 3; n++) {
*(positionUpdated + n) = position[n] + velocity[n]*timestep + 0.5*acc[n]*pow(timestep,2);
}
return positionUpdated;
}
void accelerationUpdate(float forces[3], float acc[3], float totalMass) {
float timestep = 0.5;
for (int n = 0; n < 3; n++) {
acc[n] = forces[n]/totalMass;
}
}
void speedUpdate(float velocity[3], float acc[3]) {
float timestep = 0.5;
for (int n = 0; n < 3; n++) {
velocity[n] += acc[n]*timestep;
}
}
void positionUpdate(float position[3], float velocity[3], float acc[3]) {
float timestep = 0.5;
for (int n = 0; n < 3; n++) {
position[n] += velocity[n]*timestep + 0.5*acc[n]*pow(timestep,2);
}
}
bool flightOn(float position[3]) {
if (vectorModulus(position) < 6.371e6) {
return false;
}
return true;
}