-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsolarsystemcore.h
443 lines (404 loc) · 13.6 KB
/
solarsystemcore.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
#ifndef SOLARSYSTEMCORE_H
#define SOLARSYSTEMCORE_H
#include <QString>
#include <QStringList>
#include <QVector3D>
#include <vector>
namespace SolarSystem
{
// stores all query strings for db
struct SolarStrings
{
// db type
static const QString qSqlLite;
// help
static const QString dbName;
static const QString dbFileName;
static const QString dbFolder;
// db fields
static const QString nameField;
static const QString type;
static const QString orbitalSpeed;
static const QString mass;
static const QString meanRadius;
static const QString surfaceTemp;
static const QString surfaceGravity;
static const QString volume;
static const QString siderealPeriod;
static const QString orbitalPeriod;
static const QString description;
// SQL commands
static const QString select;
static const QString from;
static const QString where;
static const QString like;
static const QString all;
static QString likeObject(const QString& object);
// string representation of object type
static const QString planet;
static const QString dwarfPlanet;
static const QString star;
static const QString moon;
static const QString ring;
static const QString solarSystemBody;
static const QString galaxy;
static const QString asteroid;
// add object types
};
// stores different values for code help
struct SolarValues
{
static const float solarSystemModifier;
static const int zero;
static const int solarDistance;
static const float auScale;
static const float saturnOuterRadius;
static const float uranusOuterRadius;
static const float sunOuterRadiusDelimiter;
static const double sunRadiusDelimeter;
static const float startSize;
static const float startSpeed;
// time scale values
static const int year;
static const int month;
static const int day;
// vector values
static const QVector3D rollAxis;
static const QVector3D tiltAxis;
};
// calculates value by solar system modifier
template<typename Result, typename T>
constexpr Result modified(const T& value)
{
using ModifierType = decltype(SolarValues::solarSystemModifier);
return static_cast<Result>(static_cast<ModifierType>(value)/SolarValues::solarSystemModifier);
}
enum SolarFields
{
SolarType,
Name,
OrbitalSpeed,
Mass,
MeanRadius,
Temperature,
Gravity,
Volume,
SiderealPeriod,
OrbitalPeriod,
Description
};
// solar system object type
enum class ObjectType
{
SolarSystemBody,
Planet,
DwarfPlanet,
Moon,
Ring,
Star,
Asteroid,
Galaxy
};
// all solar objects
// add new if you need
enum class SolarObjects
{
Sun,
Mercury,
Venus,
Earth,
Mars,
Jupiter,
Saturn,
Uranus,
Neptune,
Moon,
Pluto,
// add here
SaturnRing,
UranusRing,
EarthCloud,
// number
SolarSystemView
};
// all material types used in solar system project
enum class SolarMaterials
{
None,
Diffuse,
DiffuseSpecular,
NormalDiffuse,
NormalDiffiseSpecular,
NormalDiffuseAplha,
Phong,
PhongAlpha,
Unlit
};
// stores default camera settings
namespace CameraSettings
{
// camera up vector
const QVector3D defaultUp(0, 1, 0);
// default position
const QVector3D defaultCameraPosition(SolarValues::solarDistance, SolarValues::solarDistance, SolarValues::solarDistance);
// near plane/far plane settings
const float nearPlane = modified<float>(2500000.0f);
const float farPlane = modified<float>(20000000.0f);
// fov
const int fieldOfView = 60;
}
namespace PlanetSettings
{
const float radius = 1.0f;
const bool generateTangents = true;
const int rings = 64;
const int slices = 64;
}
// params for DB fields
namespace DbParams
{
const QStringList paramList = {"", "", "km/s", "kg", "km", "K", "m/s2", "km3", "d", "d", ""};
}
// planets math values
namespace SolarObjectsValues
{
// Planet Data
// radius - planet radius
// tilt - planet axis angle
// N1/2 - longitude of the ascending node
// i1/2 - inclination to the ecliptic (plane of the Earth's orbit)
// w1/2 - argument of perihelion
// a1/2 - semi-major axis, or mean distance from Sun
// e1/2 - eccentricity (0=circle, 0-1=ellipse, 1=parabola)
// M1/2 - mean anomaly (0 at perihelion; increases uniformly with time)
// period - sidereal rotation period
// centerOfOrbit - the planet in the center of the orbit
// (orbital elements based on http://www.stjarnhimlen.se/comp/ppcomp.html)
// solar system values
namespace SolarSystem
{
const QString toString = "Solar System";
}
// sun values
namespace Sun
{
const double radius = 694.439;
const double tilt = 63.87;
const double period = 25.05;
const QString toString = "Sun";
}
// mercury values
namespace Mercury
{
const double radius = 2.433722;
const double tilt = 0.04;
const double N1 = 48.3313;
const double N2 = 0.0000324587;
const double i1 = 7.0047;
const double i2 = 0.0000000500;
const double w1 = 29.1241;
const double w2 = 0.0000101444;
const double a1 = 0.387098;
const double a2 = 0;
const double e1 = 0.205635;
const double e2 = 0.000000000559;
const double M1 = 168.6562;
const double M2 = 4.0923344368;
const double period = 58.646;
const SolarObjects centerOfOrbit = SolarObjects::Sun;
const QString toString = "Mercury";
}
// venus values
namespace Venus
{
const double radius = 6.046079;
const double tilt = 177.36;
const double N1 = 76.6799;
const double N2 = 0.0000246590;
const double i1 = 3.3946;
const double i2 = 0.0000000275;
const double w1 = 54.8910;
const double w2 = 0.0000138374;
const double a1 = 0.723330;
const double a2 = 0;
const double e1 = 0.006773;
const double e2 = -0.000000001302;
const double M1 = 48.0052;
const double M2 = 1.6021302244;
const double period = 243.0185;
const SolarObjects centerOfOrbit = SolarObjects::Sun;
const QString toString = "Venus";
}
// earth values
namespace Earth
{
const double radius = 6.371;
const double tilt = 25.44;
const double N1 = 174.873;
const double N2 = 0;
const double i1 = 0.00005;
const double i2 = 0;
const double w1 = 102.94719;
const double w2 = 0;
const double a1 = 1;
const double a2 = 0;
const double e1 = 0.01671022;
const double e2 = 0;
const double M1 = 357.529;
const double M2 = 0.985608;
const double period = 0.997;
const SolarObjects centerOfOrbit = SolarObjects::Sun;
const QString toString = "Earth";
}
// mars values
namespace Mars
{
const double radius = 3.389372;
const double tilt = 25.19;
const double N1 = 49.5574;
const double N2 = 0.0000211081;
const double i1 = 1.8497;
const double i2 = -0.0000000178;
const double w1 = 286.5016;
const double w2 = 0.0000292961;
const double a1 = 1.523688;
const double a2 = 0;
const double e1 = 0.093405;
const double e2 = 0.000000002516;
const double M1 = 18.6021;
const double M2 = 0.5240207766;
const double period = 1.025957;
const SolarObjects centerOfOrbit = SolarObjects::Sun;
const QString toString = "Mars";
}
// jupiter values
namespace Jupier
{
const double radius = 71.41254;
const double tilt = 3.13;
const double N1 = 100.4542;
const double N2 = 0.0000276854;
const double i1 = 1.3030;
const double i2 = -0.0000001557;
const double w1 = 273.8777;
const double w2 = 0.0000164505;
const double a1 = 5.20256;
const double a2 = 0;
const double e1 = 0.048498;
const double e2 = 0.000000004469;
const double M1 = 19.8950;
const double M2 = 0.0830853001;
const double period = 0.4135;
const SolarObjects centerOfOrbit = SolarObjects::Sun;
const QString toString = "Jupiter";
}
// saturn values
namespace Saturn
{
const double radius = 60.19958;
const double tilt = 26.73;
const double N1 = 113.6634;
const double N2 = 0.0000238980;
const double i1 = 2.4886;
const double i2 = -0.0000001081;
const double w1 = 339.3939;
const double w2 = 0.0000297661;
const double a1 = 9.55475;
const double a2 = 0;
const double e1 = 0.055546;
const double e2 = -0.000000009499;
const double M1 = 316.9670;
const double M2 = 0.0334442282;
const double period = 0.4395;
const SolarObjects centerOfOrbit = SolarObjects::Sun;
const QString toString = "Saturn";
}
// uranus values
namespace Uranus
{
const double radius = 25.5286;
const double tilt = 97.77;
const double N1 = 74.0005;
const double N2 = 0.000013978;
const double i1 = 0.7733;
const double i2 = 0.000000019;
const double w1 = 96.6612;
const double w2 = 0.000030565;
const double a1 = 19.18171;
const double a2 = -0.0000000155;
const double e1 = 0.047318;
const double e2 = 0.00000000745;
const double M1 = 142.5905;
const double M2 = 0.011725806;
const double period = 0.71833;
const SolarObjects centerOfOrbit = SolarObjects::Sun;
const QString toString = "Uranus";
}
// neptune values
namespace Neptune
{
const double radius = 24.73859;
const double tilt = 28.32;
const double N1 = 131.7806;
const double N2 = 0.000030173;
const double i1 = 1.7700;
const double i2 = -0.000000255;
const double w1 = 272.8461;
const double w2 = 0.000006027;
const double a1 = 30.05826;
const double a2 = 0.00000003313;
const double e1 = 0.008606;
const double e2 = 0.00000000215;
const double M1 = 260.2471;
const double M2 = 0.005995147;
const double period = 0.6713;
const SolarObjects centerOfOrbit = SolarObjects::Sun;
const QString toString = "Neptune";
}
// pluto values
namespace Pluto
{
const double radius = 1.187; //radius
const double tilt = 120.00;
const double N1 = 110.30347; //longitude
const double N2 = 0;
const double i1 = 17.14175; //inclination
const double i2 = 0;
const double w1 = 113.834; //perihelion
const double w2 = 0;
const double a1 = 39.48168677; //semi-major axis
const double a2 = 0;
const double e1 = 0.24880766; //eccentricity
const double e2 = 0;
const double M1 = 14.53; //mean anomaly
const double M2 = 0;
const double period = 6.387230; //siderial rotation period
const SolarObjects centerOfOrbit = SolarObjects::Sun;
const QString toString = "Pluto";
}
// moon values
namespace Moon
{
const double radius = 1.5424;
const double tilt = 28.32;
const double N1 = 125.1228;
const double N2 = -0.0529538083;
const double i1 = 5.1454;
const double i2 = 0;
const double w1 = 318.0634;
const double w2 = 0.1643573223;
const double a1 = 0.273;
const double a2 = 0;
const double e1 = 0.054900;
const double e2 = 0;
const double M1 = 115.3654;
const double M2 = 13.0649929509;
const double period = 27.321582;
const SolarObjects centerOfOrbit = SolarObjects::Earth;
const QString toString = "Moon";
}
namespace SaturnRing = Saturn;
namespace UranusRing = Uranus;
}
}
#endif // SOLARSYSTEMCORE_H