-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtakeoff.h
159 lines (120 loc) · 3.5 KB
/
takeoff.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/*
* File: takeoff_t.h
* Author: gg
*
* Created on 4 de dezembro de 2019, 23:27
*/
#ifndef TAKEOFF_T_H
#define TAKEOFF_T_H
#include <ctime>
#include "shapes.h"
#include "behaviourupdate.h"
/**
* A class that helps with the takeoff of the airplane. The takeoff was
* previously called lifter, but now is called Takeoff. In the previous version,
* the takeoff consisted of the airplane moving from the start of the airstrip
* to the end of it, by increasing the radius and increasing the velocity as
* well. In 3D though, we wont need the increase of radius, but we need a
* vertical velocity that makes the airplane go up. The airplane translates to
* the middle of the airstrip with a constant acceleration. The middle is the
* point that the airplane takeoff the land and starts flying. There are two
* sections then for the takeoff.
*/
class takeoff_t : public behaviour_update_t {
private:
/**
* The starting point of the airstrip.
*/
point3f start;
/**
* The end point of the airstrip.
*/
point3f end;
/**
* A vector on ground that is the normal of the airstrip.
*/
vector3f normal;
/**
* The horizontal angle is the angle of the airstrip in the xy plane.
*/
float horizontalAngle;
float verticalAngle;
/**
* The length of the airstrip. This is the distance between the starting and
* ending points of the airstrip.
*/
float length;
/**
* The height that the airplane goes until the end of the takeoff.
*/
float height;
/**
* The acceleration on the xy plane of the airplane when taking off. This is
* a constant magnitude acceleration on the xy plane of the airplane.
*/
float acceleration;
/**
* The total time that the airplane must complete the takeoff. The time
* measured between the start and end of the takeoff must not be greater
* than this time.
*/
time_t timeToComplete = 0L;
/**
* The time since the start of the current takeoff.
*/
time_t currentTime = 0L;
/**
* The current position of the target that takes off.
*/
point3f position;
/**
* Whether the takeoff is complete.
*/
bool completed = false;
bool secondHalf = false;
float velocity;
public:
takeoff_t(const point3f& start, const point3f& end,
float height, unsigned int timeToComplete);
float getVelocityMagnitude() const override {
return velocity;
}
void reset();
void update(int time);
/**
* Returns the velocity that the airplane has at the end of the airstrip
* when the takeoff is completed.
*/
float getFinalVelocity() const;
bool isCompleted() const {
return completed;
}
point3f getPosition() const {
return position;
}
float getHorizontalAngle() const {
return horizontalAngle;
}
float getVerticalAngle() const {
return verticalAngle;
}
float getHorizontalAngularVelocity() const {
// There is no rotation around its own axis yet.
return 0;
}
point3f getStart() const {
return start;
}
float getHeight() const {
return height;
}
private:
void setGround(float k);
void setTakeoff(float k, float distance);
float getTakeoffHeight(float x) const;
float getTakeoffTangentZ(float x) const;
public:
static float getTakeoffFactor(float x);
static float getTakeoffTangent(float x);
};
#endif /* TAKEOFF_T_H */