🛰️航天仿真算法库 SpaceAST 0.3.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 getGravityRefDistance() const { return gravityField_.refDistance(); }
125
127 double getJ2() const { return getJn(2); }
128
130 double getJ3() const { return getJn(3); }
131
133 double getJ4() const { return getJn(4); }
134
136 double getJ5() const { return getJn(5); }
137
139 double getJ6() const { return getJn(6); }
140
142 bool isEarth() const { return jplIndex_ == JplDe::eEarth; }
143
145 bool isLuna() const { return jplIndex_ == JplDe::eMoon; }
146
151 errc_t getPosICRF(const TimePoint& tp, Vector3d& pos) const;
152
153
159 errc_t getPosVelICRF(const TimePoint& tp, Vector3d& pos, Vector3d& vel) const;
160
161public: // 从Point继承重写的函数
162
163 Frame* getFrame() const final;
164 errc_t getPos(const TimePoint& tp, Vector3d& pos) const final;
165 errc_t getPosVel(const TimePoint& tp, Vector3d& pos, Vector3d& vel) const final;
166
167PROPERTIES: // 天体的形状、重力场、星历、姿态
168
170 BodyShape* getShape() const { return shape_.get(); }
171 BodyShape* shape() const {return shape_.get(); }
172
174 BodyEphemeris* getEphemeris() const { return ephemeris_.get(); }
175 BodyEphemeris* ephemeris() const {return ephemeris_.get(); }
176
178 BodyOrientation* getOrientation() const { return orientation_.get(); }
179 BodyOrientation* orientation() const {return orientation_.get(); }
180public:
181 BodyEphemeris* getEphemeris(EEphemerisSource ephemerisSource) const;
182public:
184 const GravityField& getGravityField() const { return gravityField_; }
185 const GravityField& gravityField() const {return gravityField_; }
186
187public:
188
190 Point* getPointCenter() const { return const_cast<CelestialBody*>(this); }
191 Point* pointCenter() const {return const_cast<CelestialBody*>(this); }
192
194 Axes* getAxesInertial() const { return axesInertial_.get(); }
195 Axes* axesInertial() const {return axesInertial_.get(); }
196
198 Axes* getAxesFixed() const { return axesFixed_.get(); }
199 Axes* axesFixed() const {return axesFixed_.get(); }
200
202 Axes* getAxesMOD() const { return axesMOD_.get(); }
203 Axes* axesMOD() const {return axesMOD_.get(); }
204
206 Axes* getAxesTOD() const { return axesTOD_.get(); }
207 Axes* axesTOD() const {return axesTOD_.get(); }
208
213 Axes* getAxes(StringView name) const;
214
215#ifndef SWIG // 还没解决好swig封装智能指针的问题,暂时屏蔽
216public:
222 HAxes makeEpochAxes(Axes* sourceAxes, const TimePoint& tp, Axes* reference) const{return aMakeEpochAxes(sourceAxes, tp, reference);}
223
229 HAxes makeEpochAxes(Axes* sourceAxes, EventTime* time, Axes* reference) const{return aMakeEpochAxes(sourceAxes, time, reference);}
230
231
237 HFrame makeEpochFrame(Axes* sourceAxes, const TimePoint& tp, Axes* reference) const;
238
244 HFrame makeEpochFrame(Axes* sourceAxes, EventTime* time, Axes* reference) const;
245
247 HAxes makeAxesMOE(const TimePoint& tp) const;
248
250 HAxes makeAxesMOE(EventTime* time) const;
251
253 HAxes makeAxesTOE(const TimePoint& tp) const;
254
256 HAxes makeAxesTOE(EventTime* time) const;
257
259 HFrame makeFrameMOE(const TimePoint& tp) const;
260
262 HFrame makeFrameMOE(EventTime* time) const;
263
265 HFrame makeFrameTOE(const TimePoint& tp) const;
266
268 HFrame makeFrameTOE(EventTime* time) const;
269
270public:
273 HFrame makeFrame(Axes* axes) const;
274
276 HFrame makeFrameInertial() const;
277
279 HFrame makeFrameFixed() const;
280
282 HFrame makeFrameMOD() const;
283
285 HFrame makeFrameTOD() const;
286
288 HFrame makeFrameJ2000() const;
289
291 HFrame makeFrameICRF() const;
292public:
294 Frame* getFrameInertial() const;
295 Frame* frameInertial() const {return getFrameInertial();}
296
298 Frame* getFrameFixed() const;
299 Frame* frameFixed() const {return getFrameFixed();}
300
301 Frame* getFrameICRF() const;
302
303 Frame* getFrameJ2000() const;
304
305#endif
306protected:
307
308 Axes* getEpochAxesReference() const;
309protected:
311 double getJn(int n) const { return gravityField_.getJn(n); }
312
314 errc_t loadGravityModel(StringView model);
315protected:
316 friend class SolarSystem;
317
319 errc_t loadAstroDefinition(BKVParser& parser);
320
322 errc_t loadSpinData(BKVParser& parser);
323
325 errc_t loadEphemerisData(BKVParser& parser);
326
328 errc_t loadEarth(BKVParser& parser);
329
331 errc_t loadMoon(BKVParser& parser);
332
334 errc_t loadMeanEarthDefinition(BKVParser& parser);
335
336 A_DISABLE_COPY(CelestialBody)
337private:
338 WeakPtr<SolarSystem> solarSystem_{};
339 SharedPtr<CelestialBody> parent_{};
340 double gm_{0.0};
341 double systemGM_{0.0};
342 double radius_{0.0};
343 int jplSpiceId_{-1};
344 int jplIndex_{-1};
345 GravityField gravityField_{};
346 SharedPtr<BodyShape> shape_{};
347 SharedPtr<BodyOrientation> orientation_{};
348 SharedPtr<BodyEphemeris> ephemeris_{};
349
350 SharedPtr<AxesBodyInertial> axesInertial_{};
351 SharedPtr<AxesBodyFixed> axesFixed_{};
352 SharedPtr<AxesBodyMOD> axesMOD_{};
353 SharedPtr<AxesBodyTOD> axesTOD_{};
354
355 mutable WeakPtr<Frame> frameInertial_{};
356 mutable WeakPtr<Frame> frameFixed_{};
357
358 mutable SharedPtr<BodyEphemeris> ephemerisDE_{};
359 mutable SharedPtr<BodyEphemeris> ephemerisSpice_{};
360 mutable SharedPtr<BodyEphemeris> ephemerisSpiceBarycenter_{};
361};
362
363
364enum ESpiceId: int;
365
369AST_CORE_CAPI ESpiceId aGetPlanetBarycenterId(ESpiceId planetId);
370
371
378AST_CORE_CAPI errc_t aBodyOrbitNormalIn
379(
380 Axes& axes,
381 const Body& body,
382 const TimePoint& tp,
383 Vector3d& normal
384);
385
386
392AST_CORE_CAPI errc_t aBodyOrbitNormalInParentInertial
393(
394 const Body& body,
395 const TimePoint& tp,
396 Vector3d& normal
397);
398
399
405AST_CORE_CAPI errc_t aBodyOrbitNormalInICRF
406(
407 const Body& body,
408 const TimePoint& tp,
409 Vector3d& normal
410);
411
412
413
416enum ESpiceId: int
417{
428
429 eSun = 10,
430
431 eMercury = 199,
432
433 eVenus = 299,
434
435 eEarth = 399,
436 eMoon = 301,
437
438 eMars = 499,
439 ePhobos = 401,
440 eDeimos = 402,
441
442
443 eJupiter = 599,
444 eIo = 501,
445 eEuropa = 502,
446 eGanymede = 503,
447 eCallisto = 504,
448 eAmalthea = 505,
449 eHimalia = 506,
450 eElara = 507,
451 ePasiphae = 508,
452 eSinope = 509,
453 eLysithea = 510,
454 eCarme = 511,
455 eAnanke = 512,
456 eLeda = 513,
457 eThebe = 514,
458 eAdrastea = 515,
459 eMetis = 516,
460
461 eSaturn = 699,
462 eMimas = 601,
463 eEnceladus = 602,
464 eTethys = 603,
465 eDione = 604,
466 eRhea = 605,
467 eTitan = 606,
468 eHyperion = 607,
469 eIapetus = 608,
470 ePhoebe = 609,
471 eJanus = 610,
472 eEpimetheus = 611,
473 eHelene = 612,
474 eTelesto = 613,
475 eCalypso = 614,
476 eAtlas = 615,
477 ePrometheus = 616,
478 ePandora = 617,
479 ePan = 618,
480 eMethone = 632,
481 ePallene = 633,
482 ePolydeuces = 634,
483 eDaphnis = 635,
484 eAnthe = 649,
485 eAegaeon = 653,
486
487
488 eUranus = 799,
489 eAriel = 701,
490 eUmbriel = 702,
491 eTitania = 703,
492 eOberon = 704,
493 eMiranda = 705,
494 eCordelia = 706,
495 eOphelia = 707,
496 eBianca = 708,
497 eCressida = 709,
498 eDesdemona = 710,
499 eJuliet = 711,
500 ePortia = 712,
501 eRosalind = 713,
502 eBelinda = 714,
503 ePuck = 715,
504
505
506 eNeptune = 899,
507 eTriton = 801,
508 eNereid = 802,
509 eNaiad = 803,
510 eThalassa = 804,
511 eDespina = 805,
512 eGalatea = 806,
513 eLarissa = 807,
514 eProteus = 808,
515
516 ePluto = 999,
517 eCharon = 901,
518};
519
520
521
526
527
530
531
534AST_NAMESPACE_END
535
536
537#include "SolarSystem.hpp"
轴系抽象基类
定义 Axes.hpp:86
键值对解析器(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:130
HAxes makeEpochAxes(Axes *sourceAxes, const TimePoint &tp, Axes *reference) const
创建新的历元轴系
定义 CelestialBody.hpp:222
double getJn(int n) const
获取Jn项
定义 CelestialBody.hpp:311
const std::string & getGravityModel() const
获取重力模型名称
定义 CelestialBody.hpp:104
double getJ4() const
获取J4项
定义 CelestialBody.hpp:133
BodyEphemeris * getEphemeris() const
获取天体星历
定义 CelestialBody.hpp:174
CelestialBody * getParent() const
获取父天体
定义 CelestialBody.hpp:100
double getJ2() const
获取J2项
定义 CelestialBody.hpp:127
Axes * getAxesTOD() const
获取天体TOD轴系
定义 CelestialBody.hpp:206
double getGM() const
获取天体的引力常数
定义 CelestialBody.hpp:115
HAxes makeEpochAxes(Axes *sourceAxes, EventTime *time, Axes *reference) const
创建新的历元轴系
定义 CelestialBody.hpp:229
Axes * getAxesMOD() const
获取天体MOD轴系
定义 CelestialBody.hpp:202
Point * getPointCenter() const
获取天体中心
定义 CelestialBody.hpp:190
Axes * getAxesFixed() const
获取天体固定轴系
定义 CelestialBody.hpp:198
double getSystemGM() const
获取天体系引力常数(考虑天体的卫星)
定义 CelestialBody.hpp:118
double getRadius() const
获取天体半径
定义 CelestialBody.hpp:112
double getGravityRefDistance() const
获取重力场参考半径
定义 CelestialBody.hpp:124
bool isEarth() const
是否为地球
定义 CelestialBody.hpp:142
BodyOrientation * getOrientation() const
获取天体姿态
定义 CelestialBody.hpp:178
const GravityField & getGravityField() const
获取天体重力场
定义 CelestialBody.hpp:184
double getJ6() const
获取J6项
定义 CelestialBody.hpp:139
Axes * getAxesInertial() const
获取天体惯性轴系
定义 CelestialBody.hpp:194
int getJplSpiceId() const
获取JPL SPICE ID
定义 CelestialBody.hpp:86
bool isLuna() const
是否为月球
定义 CelestialBody.hpp:145
double getJ5() const
获取J5项
定义 CelestialBody.hpp:136
事件时间
定义 EventTime.hpp:44
坐标系抽象基类
定义 Frame.hpp:74
重力场系数
定义 GravityField.hpp:91
@ eEarth
地球
定义 JplDe.hpp:51
@ eMoon
月球
定义 JplDe.hpp:58
static Object * Resolve(StringView value)
解析字符串
定义 Object.cpp:39
点抽象基类
定义 Point.hpp:42
virtual Frame * getFrame() const =0
获取点所在的参考坐标系
太阳系
定义 SolarSystem.hpp:54
绝对时间点
定义 TimePoint.hpp:108
弱引用指针
定义 WeakPtr.hpp:35
@ eJplDE
来自JPL DE星历的引力常数
ESpiceId
SPICE 天体ID
定义 CelestialBody.hpp:417
ESpiceId aGetPlanetBarycenterId(ESpiceId planetId)
获取行星系质心ID
定义 CelestialBody.cpp:551
errc_t aBodyOrbitNormalIn(Axes &axes, const Body &body, const TimePoint &tp, Vector3d &normal)
获取天体绕其父天体的轨道法向
定义 CelestialBody.cpp:518
EEphemerisSource
星历来源
定义 CelestialBody.hpp:53
errc_t aBodyOrbitNormalInParentInertial(const Body &body, const TimePoint &tp, Vector3d &normal)
获取天体绕其父天体的轨道法向
定义 CelestialBody.cpp:536
errc_t aBodyOrbitNormalInICRF(const Body &body, const TimePoint &tp, Vector3d &normal)
获取天体绕其父天体的轨道法向
定义 CelestialBody.cpp:546
@ eJupiter
木星
定义 CelestialBody.hpp:443
@ eVenus
金星
定义 CelestialBody.hpp:433
@ ePlutoBarycenter
冥王星系质心
定义 CelestialBody.hpp:427
@ eVenusBarycenter
金星系质心
定义 CelestialBody.hpp:420
@ eMoon
月球
定义 CelestialBody.hpp:436
@ eUranus
天王星
定义 CelestialBody.hpp:488
@ eMercury
水星
定义 CelestialBody.hpp:431
@ eEarthBarycenter
地月系质心
定义 CelestialBody.hpp:421
@ eSaturnBarycenter
土星系质心
定义 CelestialBody.hpp:424
@ eNeptune
海王星
定义 CelestialBody.hpp:506
@ eJupiterBarycenter
木星系质心
定义 CelestialBody.hpp:423
@ eSaturn
土星
定义 CelestialBody.hpp:461
@ eEarth
地球
定义 CelestialBody.hpp:435
@ eMarsBarycenter
火星系质心
定义 CelestialBody.hpp:422
@ eSun
太阳
定义 CelestialBody.hpp:429
@ eMars
火星
定义 CelestialBody.hpp:438
@ ePluto
冥王星
定义 CelestialBody.hpp:516
@ eSolarSystemBarycenter
太阳系质心
定义 CelestialBody.hpp:418
@ eNeptuneBarycenter
海王星系质心
定义 CelestialBody.hpp:426
@ eMercuryBarycenter
水星系质心
定义 CelestialBody.hpp:419
@ eUranusBarycenter
天王星系质心
定义 CelestialBody.hpp:425
@ eJplSpice
JPL SPICE 星历
@ eJplSpiceBarycenter
JPL SPICE 行星系质心星历
@ eBodyEphemeris
天体星历
HAxes aMakeEpochAxes(Axes *sourceAxes, const TimePoint &tp, Axes *referenceAxes)
创建一个历元轴系
定义 AxesAPI.cpp:27