]> git.mxchange.org Git - flightgear.git/blob - src/FDM/flightProperties.cxx
24602325cca28f340f682f02887cb0fe42633805
[flightgear.git] / src / FDM / flightProperties.cxx
1 #include <FDM/flightProperties.hxx>
2
3 #include <simgear/props/props.hxx>
4 #include <simgear/math/SGMath.hxx>
5
6 #include <Main/globals.hxx>
7
8 FlightProperties::FlightProperties(SGPropertyNode* root) :
9   _root(root)
10 {
11   if (!_root) {
12     _root = globals->get_props();
13   }
14 }
15
16 FlightProperties::~FlightProperties()
17 {
18 }
19
20 double FlightProperties::get_V_north() const
21 {
22   return _root->getDoubleValue("velocities/speed-north-fps", 0.0);
23 }
24
25 double FlightProperties::get_V_east() const
26 {
27   return _root->getDoubleValue("velocities/speed-east-fps", 0.0);
28 }
29
30 double FlightProperties::get_V_down() const
31 {
32   return _root->getDoubleValue("velocities/speed-down-fps", 0.0);
33 }
34
35 double FlightProperties::get_uBody () const
36 {
37   return _root->getDoubleValue("velocities/uBody-fps", 0.0);
38 }
39
40 double FlightProperties::get_vBody () const
41 {
42   return _root->getDoubleValue("velocities/vBody-fps", 0.0);
43 }
44
45 double FlightProperties::get_wBody () const
46 {
47   return _root->getDoubleValue("velocities/wBody-fps", 0.0);
48 }
49
50 double FlightProperties::get_A_X_pilot() const
51 {
52   return _root->getDoubleValue("accelerations/pilot/x-accel-fps_sec", 0.0);
53 }
54
55 double FlightProperties::get_A_Y_pilot() const
56 {
57   return _root->getDoubleValue("/accelerations/pilot/y-accel-fps_sec", 0.0);
58 }
59
60 double FlightProperties::get_A_Z_pilot() const
61 {
62   return _root->getDoubleValue("/accelerations/pilot/z-accel-fps_sec", 0.0);
63 }
64
65 SGGeod FlightProperties::getPosition() const
66 {
67   return SGGeod::fromDegFt(get_Longitude_deg(), get_Latitude_deg(), get_Altitude());
68 }
69
70 double FlightProperties::get_Latitude() const
71 {
72   return get_Latitude_deg() * SG_DEGREES_TO_RADIANS;
73 }
74
75 double FlightProperties::get_Longitude() const
76 {
77   return get_Longitude_deg() * SG_DEGREES_TO_RADIANS;
78 }
79
80 double FlightProperties::get_Altitude() const
81 {
82   return _root->getDoubleValue("position/altitude-ft");
83 }
84
85 double FlightProperties::get_Altitude_AGL(void) const
86 {
87   return _root->getDoubleValue("position/altitude-agl-ft");
88 }
89
90 double FlightProperties::get_Latitude_deg () const
91 {
92   return _root->getDoubleValue("position/latitude-deg");
93 }
94
95 double FlightProperties::get_Longitude_deg () const
96 {
97   return _root->getDoubleValue("position/longitude-deg");
98 }
99
100 double FlightProperties::get_Track(void) const
101 {
102   return _root->getDoubleValue("orientation/track-deg");
103 }
104
105 double FlightProperties::get_Phi_deg() const
106 {
107   return _root->getDoubleValue("orientation/roll-deg");
108 }
109
110 double FlightProperties::get_Theta_deg() const
111 {
112   return _root->getDoubleValue("orientation/pitch-deg");
113 }
114
115 double FlightProperties::get_Psi_deg() const
116 {
117   return _root->getDoubleValue("orientation/heading-deg");
118 }
119
120 double FlightProperties::get_Phi_dot() const
121 {
122   return get_Phi_dot_degps() * SG_DEGREES_TO_RADIANS;
123 }
124
125 double FlightProperties::get_Theta_dot() const
126 {
127    return get_Theta_dot_degps() * SG_DEGREES_TO_RADIANS;
128 }
129
130 double FlightProperties::get_Psi_dot() const
131 {
132    return get_Psi_dot_degps() * SG_DEGREES_TO_RADIANS;
133 }
134
135 double FlightProperties::get_Alpha() const
136 {
137   return _root->getDoubleValue("orientation/alpha-deg") * SG_DEGREES_TO_RADIANS;
138 }
139
140 double FlightProperties::get_Beta() const
141 {
142   return _root->getDoubleValue("orientation/beta-deg") * SG_DEGREES_TO_RADIANS;
143 }
144
145 double FlightProperties::get_Phi_dot_degps() const
146 {
147   return _root->getDoubleValue("orientation/roll-rate-degps");
148 }
149
150 double FlightProperties::get_Theta_dot_degps() const
151 {
152   return _root->getDoubleValue("orientation/pitch-rate-degps");
153 }
154
155 double FlightProperties::get_Psi_dot_degps() const
156 {
157   return _root->getDoubleValue("orientation/yaw-rate-degps");
158 }
159   
160 double FlightProperties::get_Total_temperature() const
161 {
162   return 0.0;
163 }
164
165 double FlightProperties::get_Total_pressure() const
166 {
167   return 0.0;
168 }
169
170 double FlightProperties::get_Dynamic_pressure() const
171 {
172   return 0.0;
173 }
174
175 void FlightProperties::set_Longitude(double l)
176 {
177   _root->setDoubleValue("position/longitude-deg", l * SG_RADIANS_TO_DEGREES);
178 }
179
180 void FlightProperties::set_Latitude(double l)
181 {
182   _root->setDoubleValue("position/latitude-deg", l * SG_RADIANS_TO_DEGREES);
183 }
184
185 void FlightProperties::set_Altitude(double ft)
186 {
187   _root->setDoubleValue("position/altitude-ft", ft);
188 }
189
190 void FlightProperties::set_Euler_Angles(double phi, double theta, double psi)
191 {
192   _root->setDoubleValue("orientation/roll-deg", phi * SG_RADIANS_TO_DEGREES);
193   _root->setDoubleValue("orientation/pitch-deg", theta * SG_RADIANS_TO_DEGREES);
194   _root->setDoubleValue("orientation/heading-deg", psi * SG_RADIANS_TO_DEGREES);
195 }
196
197 void FlightProperties::set_V_calibrated_kts(double kts)
198 {
199   _root->setDoubleValue("velocities/airspeed-kt", kts);
200 }
201
202 void FlightProperties::set_Climb_Rate(double fps)
203 {
204   _root->setDoubleValue("velocities/vertical-speed-fps", fps);
205 }
206
207 double FlightProperties::get_V_ground_speed() const
208 {
209   const double KNOTS_TO_FTS = (SG_NM_TO_METER * SG_METER_TO_FEET)/ 3600.0;
210   return _root->getDoubleValue("velocities/groundspeed-kt") * KNOTS_TO_FTS;
211 }
212
213 double FlightProperties::get_V_calibrated_kts() const
214 {
215   return _root->getDoubleValue("velocities/airspeed-kt");
216 }
217
218 double FlightProperties::get_V_equiv_kts() const
219 {
220   return _root->getDoubleValue("velocities/equivalent-kt");
221 }
222
223 double FlightProperties::get_Climb_Rate() const
224 {
225   return _root->getDoubleValue("velocities/vertical-speed-fps");
226 }
227
228 double FlightProperties::get_Runway_altitude_m() const
229 {
230   return _root->getDoubleValue("environment/ground-elevation-m");
231 }
232
233 void FlightProperties::set_Accels_Pilot_Body(double x, double y, double z)
234 {
235   _root->setDoubleValue("accelerations/pilot/x-accel-fps_sec", x);
236   _root->setDoubleValue("accelerations/pilot/y-accel-fps_sec", y);
237   _root->setDoubleValue("accelerations/pilot/z-accel-fps_sec", z);
238 }
239
240 void FlightProperties::set_Velocities_Local(double x, double y, double z)
241 {
242   _root->setDoubleValue("velocities/speed-north-fps", x);
243   _root->setDoubleValue("velocities/speed-east-fps", y);
244   _root->setDoubleValue("velocities/speed-down-fps", z);
245 }
246
247 void FlightProperties::set_Velocities_Wind_Body(double x, double y, double z)
248 {
249   _root->setDoubleValue("velocities/vBody-fps", x);
250   _root->setDoubleValue("velocities/uBody-fps", y);
251   _root->setDoubleValue("velocities/wBody-fps", z);
252 }
253
254 void FlightProperties::set_Euler_Rates(double x, double y, double z)
255 {
256   _root->setDoubleValue("orientation/roll-rate-degps", x * SG_RADIANS_TO_DEGREES);
257   _root->setDoubleValue("orientation/pitch-rate-degps", y * SG_RADIANS_TO_DEGREES);
258   _root->setDoubleValue("orientation/yaw-rate-degps", z * SG_RADIANS_TO_DEGREES);
259 }
260
261 void FlightProperties::set_Alpha(double a)
262 {
263   _root->setDoubleValue("orientation/alpha-deg", a * SG_RADIANS_TO_DEGREES);
264 }
265
266 void FlightProperties::set_Beta(double b)
267 {
268   _root->setDoubleValue("orientation/side-slip-rad", b);
269 }
270
271 void FlightProperties::set_Altitude_AGL(double ft)
272 {
273   _root->setDoubleValue("position/altitude-agl-ft", ft);
274 }
275
276 double FlightProperties::get_P_body() const
277 {
278   return _root->getDoubleValue("orientation/p-body", 0.0);
279 }
280
281 double FlightProperties::get_Q_body() const
282 {
283   return _root->getDoubleValue("orientation/q-body", 0.0);
284 }
285
286 double FlightProperties::get_R_body() const
287 {
288   return _root->getDoubleValue("orientation/r-body", 0.0);
289 }