🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
CelestialBody.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include "AstCore/Object.hpp"
25#include "AstCore/GravityField.hpp"
26#include "AstCore/JplDe.hpp"
27#include "AstCore/BodyEphemeris.hpp"
28#include "AstCore/BodyOrientation.hpp"
29#include "AstCore/AxesBodyInertial.hpp"
30#include "AstCore/AxesBodyFixed.hpp"
31#include "AstCore/AxesBodyMOD.hpp"
32#include "AstCore/AxesBodyTOD.hpp"
33#include "AstCore/Point.hpp"
34#include "AstCore/Frame.hpp"
35#include "AstCore/AxesAPI.hpp"
36#include "AstCore/BodyShape.hpp"
37#include "AstUtil/SharedPtr.hpp"
38#include "AstUtil/ScopedPtr.hpp"
39
40AST_NAMESPACE_BEGIN
41
47class CelestialBody;
48using Body = CelestialBody;
49
50
59
60
61
67AST_CORE_CAPI errc_t aGetGravityParameter(const Body& body, StringView gravityModel, double& gm);
68
69
71class AST_CORE_API CelestialBody : public Point
72{
73public:
74 AST_OBJECT(CelestialBody)
75 AST_PROPERT(Shape)
76 AST_PROPERT(Ephemeris)
77 AST_PROPERT(Orientation)
78 static CelestialBody* Resolve(StringView value);
79
81 explicit CelestialBody(SolarSystem* solarSystem);
82 explicit CelestialBody(CelestialBody* parentBody);
84
86 int getJplSpiceId() const { return jplSpiceId_; }
87 void setJplSpiceId(int id) { jplSpiceId_ = id; }
88
90 int getJplIndex() const { return jplIndex_; }
91 void setJplIndex(int index);
92
94 std::string getDirpath() const;
95
97 SolarSystem* getSolarSystem() const;
98
100 CelestialBody* getParent() const { return parent_.get(); }
101public:
102
104 const std::string& getGravityModel() const{ return gravityField_.getModelName(); }
105
109 errc_t load(StringView filepath);
110
112 double getRadius() const { return radius_; }
113
115 double getGM() const { return gm_; }
116
118 double getSystemGM() const { return systemGM_; }
119
121 errc_t setGravityModel(StringView model);
122
124 double getJ2() const { return getJn(2); }
125
127 double getJ3() const { return getJn(3); }
128
130 double getJ4() const { return getJn(4); }
131
133 double getJ5() const { return getJn(5); }
134
136 double getJ6() const { return getJn(6); }
137
139 bool isEarth() const { return jplIndex_ == JplDe::eEarth; }
140
142 bool isLuna() const { return jplIndex_ == JplDe::eMoon; }
143
148 errc_t getPosICRF(const TimePoint& tp, Vector3d& pos) const;
149
150
156 errc_t getPosVelICRF(const TimePoint& tp, Vector3d& pos, Vector3d& vel) const;
157
158public: // 从Point继承重写的函数
159
160 Frame* getFrame() const final;
161 errc_t getPos(const TimePoint& tp, Vector3d& pos) const final;
162 errc_t getPosVel(const TimePoint& tp, Vector3d& pos, Vector3d& vel) const final;
163
164PROPERTIES: // 天体的形状、重力场、星历、姿态
165
167 BodyShape* getShape() const { return shape_.get(); }
168 BodyShape* shape() const {return shape_.get(); }
169
171 BodyEphemeris* getEphemeris() const { return ephemeris_.get(); }
172 BodyEphemeris* ephemeris() const {return ephemeris_.get(); }
173
175 BodyOrientation* getOrientation() const { return orientation_.get(); }
176 BodyOrientation* orientation() const {return orientation_.get(); }
177public:
178 BodyEphemeris* getEphemeris(EEphemerisSource ephemerisSource) const;
179public:
181 const GravityField& getGravityField() const { return gravityField_; }
182 const GravityField& gravityField() const {return gravityField_; }
183
184public:
185
187 Point* getPointCenter() const { return const_cast<CelestialBody*>(this); }
188 Point* pointCenter() const {return const_cast<CelestialBody*>(this); }
189
191 Axes* getAxesInertial() const { return axesInertial_.get(); }
192 Axes* axesInertial() const {return axesInertial_.get(); }
193
195 Axes* getAxesFixed() const { return axesFixed_.get(); }
196 Axes* axesFixed() const {return axesFixed_.get(); }
197
199 Axes* getAxesMOD() const { return axesMOD_.get(); }
200 Axes* axesMOD() const {return axesMOD_.get(); }
201
203 Axes* getAxesTOD() const { return axesTOD_.get(); }
204 Axes* axesTOD() const {return axesTOD_.get(); }
205
210 Axes* getAxes(StringView name) const;
211
212#ifndef SWIG // 还没解决好swig封装智能指针的问题,暂时屏蔽
213public:
219 HAxes makeEpochAxes(Axes* sourceAxes, const TimePoint& tp, Axes* reference) const{return aMakeEpochAxes(sourceAxes, tp, reference);}
220
226 HAxes makeEpochAxes(Axes* sourceAxes, EventTime* time, Axes* reference) const{return aMakeEpochAxes(sourceAxes, time, reference);}
227
228
234 HFrame makeEpochFrame(Axes* sourceAxes, const TimePoint& tp, Axes* reference) const;
235
241 HFrame makeEpochFrame(Axes* sourceAxes, EventTime* time, Axes* reference) const;
242
244 HAxes makeAxesMOE(const TimePoint& tp) const;
245
247 HAxes makeAxesMOE(EventTime* time) const;
248
250 HAxes makeAxesTOE(const TimePoint& tp) const;
251
253 HAxes makeAxesTOE(EventTime* time) const;
254
256 HFrame makeFrameMOE(const TimePoint& tp) const;
257
259 HFrame makeFrameMOE(EventTime* time) const;
260
262 HFrame makeFrameTOE(const TimePoint& tp) const;
263
265 HFrame makeFrameTOE(EventTime* time) const;
266
267public:
270 HFrame makeFrame(Axes* axes) const;
271
273 HFrame makeFrameInertial() const;
274
276 HFrame makeFrameFixed() const;
277
279 HFrame makeFrameMOD() const;
280
282 HFrame makeFrameTOD() const;
283
285 HFrame makeFrameJ2000() const;
286
288 HFrame makeFrameICRF() const;
289public:
291 Frame* getFrameInertial() const;
292 Frame* frameInertial() const {return getFrameInertial();}
293
295 Frame* getFrameFixed() const;
296 Frame* frameFixed() const {return getFrameFixed();}
297
298#endif
299protected:
300
301 Axes* getEpochAxesReference() const;
302protected:
304 double getJn(int n) const { return gravityField_.getJn(n); }
305
307 errc_t loadGravityModel(StringView model);
308protected:
309 friend class SolarSystem;
310
312 errc_t loadAstroDefinition(BKVParser& parser);
313
315 errc_t loadSpinData(BKVParser& parser);
316
318 errc_t loadEphemerisData(BKVParser& parser);
319
321 errc_t loadEarth(BKVParser& parser);
322
324 errc_t loadMoon(BKVParser& parser);
325
327 errc_t loadMeanEarthDefinition(BKVParser& parser);
328
329 A_DISABLE_COPY(CelestialBody)
330private:
331 WeakPtr<SolarSystem> solarSystem_;
333 double gm_{0.0};
334 double systemGM_{0.0};
335 double radius_{0.0};
336 int jplSpiceId_{-1};
337 int jplIndex_{-1};
338 GravityField gravityField_;
339 SharedPtr<BodyShape> shape_;
340 SharedPtr<BodyOrientation> orientation_;
341 SharedPtr<BodyEphemeris> ephemeris_;
342
343 SharedPtr<AxesBodyInertial> axesInertial_;
344 SharedPtr<AxesBodyFixed> axesFixed_;
345 SharedPtr<AxesBodyMOD> axesMOD_;
346 SharedPtr<AxesBodyTOD> axesTOD_;
347
348 mutable WeakPtr<Frame> frameInertial_;
349 mutable WeakPtr<Frame> frameFixed_;
350
351 mutable SharedPtr<BodyEphemeris> ephemerisDE_;
352 mutable SharedPtr<BodyEphemeris> ephemerisSpice_;
353 mutable SharedPtr<BodyEphemeris> ephemerisSpiceBarycenter_;
354};
355
356
357enum ESpiceId: int;
358
362AST_CORE_CAPI ESpiceId aGetPlanetBarycenterId(ESpiceId planetId);
363
364
367enum ESpiceId: int
368{
379
380 eSun = 10,
381
382 eMercury = 199,
383
384 eVenus = 299,
385
386 eEarth = 399,
387 eMoon = 301,
388
389 eMars = 499,
390 ePhobos = 401,
391 eDeimos = 402,
392
393
394 eJupiter = 599,
395 eIo = 501,
396 eEuropa = 502,
397 eGanymede = 503,
398 eCallisto = 504,
399 eAmalthea = 505,
400 eHimalia = 506,
401 eElara = 507,
402 ePasiphae = 508,
403 eSinope = 509,
404 eLysithea = 510,
405 eCarme = 511,
406 eAnanke = 512,
407 eLeda = 513,
408 eThebe = 514,
409 eAdrastea = 515,
410 eMetis = 516,
411
412 eSaturn = 699,
413 eMimas = 601,
414 eEnceladus = 602,
415 eTethys = 603,
416 eDione = 604,
417 eRhea = 605,
418 eTitan = 606,
419 eHyperion = 607,
420 eIapetus = 608,
421 ePhoebe = 609,
422 eJanus = 610,
423 eEpimetheus = 611,
424 eHelene = 612,
425 eTelesto = 613,
426 eCalypso = 614,
427 eAtlas = 615,
428 ePrometheus = 616,
429 ePandora = 617,
430 ePan = 618,
431 eMethone = 632,
432 ePallene = 633,
433 ePolydeuces = 634,
434 eDaphnis = 635,
435 eAnthe = 649,
436 eAegaeon = 653,
437
438
439 eUranus = 799,
440 eAriel = 701,
441 eUmbriel = 702,
442 eTitania = 703,
443 eOberon = 704,
444 eMiranda = 705,
445 eCordelia = 706,
446 eOphelia = 707,
447 eBianca = 708,
448 eCressida = 709,
449 eDesdemona = 710,
450 eJuliet = 711,
451 ePortia = 712,
452 eRosalind = 713,
453 eBelinda = 714,
454 ePuck = 715,
455
456
457 eNeptune = 899,
458 eTriton = 801,
459 eNereid = 802,
460 eNaiad = 803,
461 eThalassa = 804,
462 eDespina = 805,
463 eGalatea = 806,
464 eLarissa = 807,
465 eProteus = 808,
466
467 ePluto = 999,
468 eCharon = 901,
469};
470
471
472
475
478
479
482AST_NAMESPACE_END
483
484
485
轴系类
定义 Axes.hpp:70
键值对解析器(BlockKeyValueParser)
定义 BKVParser.hpp:45
天体星历接口
定义 BodyEphemeris.hpp:38
天体姿态/指向
定义 BodyOrientation.hpp:39
天体形状基类
定义 BodyShape.hpp:33
天体
定义 CelestialBody.hpp:72
int getJplIndex() const
获取JPL索引
定义 CelestialBody.hpp:90
double getJ3() const
获取J3项
定义 CelestialBody.hpp:127
HAxes makeEpochAxes(Axes *sourceAxes, const TimePoint &tp, Axes *reference) const
创建新的历元轴系
定义 CelestialBody.hpp:219
double getJn(int n) const
获取Jn项
定义 CelestialBody.hpp:304
const std::string & getGravityModel() const
获取重力模型名称
定义 CelestialBody.hpp:104
double getJ4() const
获取J4项
定义 CelestialBody.hpp:130
BodyEphemeris * getEphemeris() const
获取天体星历
定义 CelestialBody.hpp:171
CelestialBody * getParent() const
获取父天体
定义 CelestialBody.hpp:100
double getJ2() const
获取J2项
定义 CelestialBody.hpp:124
Axes * getAxesTOD() const
获取天体TOD轴系
定义 CelestialBody.hpp:203
double getGM() const
获取天体的引力常数
定义 CelestialBody.hpp:115
HAxes makeEpochAxes(Axes *sourceAxes, EventTime *time, Axes *reference) const
创建新的历元轴系
定义 CelestialBody.hpp:226
Axes * getAxesMOD() const
获取天体MOD轴系
定义 CelestialBody.hpp:199
Point * getPointCenter() const
获取天体中心
定义 CelestialBody.hpp:187
Axes * getAxesFixed() const
获取天体固定轴系
定义 CelestialBody.hpp:195
double getSystemGM() const
获取天体系引力常数(考虑天体的卫星)
定义 CelestialBody.hpp:118
double getRadius() const
获取天体半径
定义 CelestialBody.hpp:112
bool isEarth() const
是否为地球
定义 CelestialBody.hpp:139
BodyOrientation * getOrientation() const
获取天体姿态
定义 CelestialBody.hpp:175
const GravityField & getGravityField() const
获取天体重力场
定义 CelestialBody.hpp:181
double getJ6() const
获取J6项
定义 CelestialBody.hpp:136
Axes * getAxesInertial() const
获取天体惯性轴系
定义 CelestialBody.hpp:191
int getJplSpiceId() const
获取JPL SPICE ID
定义 CelestialBody.hpp:86
bool isLuna() const
是否为月球
定义 CelestialBody.hpp:142
double getJ5() const
获取J5项
定义 CelestialBody.hpp:133
星历接口
定义 Ephemeris.hpp:44
事件时间
定义 EventTime.hpp:44
坐标系类
定义 Frame.hpp:60
重力场系数
定义 GravityField.hpp:88
@ eEarth
地球
定义 JplDe.hpp:48
@ eMoon
月球
定义 JplDe.hpp:55
static Object * Resolve(StringView value)
解析字符串
定义 Object.cpp:39
定义 Point.hpp:38
virtual Frame * getFrame() const =0
获取点所在的参考坐标系
太阳系
定义 SolarSystem.hpp:54
绝对时间点
定义 TimePoint.hpp:107
弱引用指针
定义 WeakPtr.hpp:35
@ eJplDE
来自JPL DE星历的引力常数
ESpiceId
SPICE 天体ID
定义 CelestialBody.hpp:368
ESpiceId aGetPlanetBarycenterId(ESpiceId planetId)
获取行星系质心ID
定义 CelestialBody.cpp:463
EEphemerisSource
星历来源
定义 CelestialBody.hpp:53
@ eJupiter
木星
定义 CelestialBody.hpp:394
@ eVenus
金星
定义 CelestialBody.hpp:384
@ ePlutoBarycenter
冥王星系质心
定义 CelestialBody.hpp:378
@ eVenusBarycenter
金星系质心
定义 CelestialBody.hpp:371
@ eMoon
月球
定义 CelestialBody.hpp:387
@ eUranus
天王星
定义 CelestialBody.hpp:439
@ eMercury
水星
定义 CelestialBody.hpp:382
@ eEarthBarycenter
地月系质心
定义 CelestialBody.hpp:372
@ eSaturnBarycenter
土星系质心
定义 CelestialBody.hpp:375
@ eNeptune
海王星
定义 CelestialBody.hpp:457
@ eJupiterBarycenter
木星系质心
定义 CelestialBody.hpp:374
@ eSaturn
土星
定义 CelestialBody.hpp:412
@ eEarth
地球
定义 CelestialBody.hpp:386
@ eMarsBarycenter
火星系质心
定义 CelestialBody.hpp:373
@ eSun
太阳
定义 CelestialBody.hpp:380
@ eMars
火星
定义 CelestialBody.hpp:389
@ ePluto
冥王星
定义 CelestialBody.hpp:467
@ eSolarSystemBarycenter
太阳系质心
定义 CelestialBody.hpp:369
@ eNeptuneBarycenter
海王星系质心
定义 CelestialBody.hpp:377
@ eMercuryBarycenter
水星系质心
定义 CelestialBody.hpp:370
@ eUranusBarycenter
天王星系质心
定义 CelestialBody.hpp:376
@ eJplSpice
JPL SPICE 星历
@ eJplSpiceBarycenter
JPL SPICE 行星系质心星历
@ eBodyEphemeris
天体星历
HAxes aMakeEpochAxes(Axes *sourceAxes, const TimePoint &tp, Axes *referenceAxes)
创建一个历元轴系
定义 AxesAPI.cpp:27