-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrocket.cpp
43 lines (32 loc) · 900 Bytes
/
rocket.cpp
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
#include "rocket.h"
#include <QtDebug>
#define PI 3.14159265
double globalMass;
double globalR;
double globalThrust;
double acceleration;
double velocity;
double globalDeltaT;
double globalThrustAngle;
Rocket::Rocket(double mass, double r, double deltaT, double thrust) {
globalDeltaT = deltaT;
globalR = r;
globalMass = mass;
globalThrust = thrust;
}
double Rocket::getAcceleration() {
return acceleration;
}
double Rocket::getVelocity() {
return velocity;
}
void Rocket::setThrustAngle(double thrustAngle) {
globalThrustAngle = thrustAngle;
}
void Rocket::setAngle(double *currentAngle) {
double torque = globalR * globalThrust * qSin(globalThrustAngle*PI/180);
acceleration = torque / (globalMass * globalR * globalR * 0.5);
velocity += acceleration * globalDeltaT;
// qDebug() << acceleration;
*currentAngle += velocity * globalDeltaT;
}