特别声明,本人对于天体物理学、轨道动力学完全是门外汉,不是一个学科方向,本人仅从代码角度以及STK提供的代码和资料作为参考进行分析,欢迎专业人士指正。若不喜,请勿喷!
继续以STK提供的VC++代码实例Events项目为例分析。
加入卫星的代码如下(Helper源文件中,自己增加了注释):
| void CObjectModelHelper::CreateSatellite(STKObjects::IAgStkObjectRootPtr pRoot) { static int iNext = 0; char buf[255]; double aporad, perrad; _bstr_t bstrName; IAgOrbitStateClassicalPtr pClassical; IAgStkObjectPtr pNewObj; // STK Object IAgSatellitePtr pSat; // STK卫星对象 IAgVePropagatorTwoBodyPtr pTwoBodyProp; // 二体轨道预报器 IAgClassicalSizeShapeRadiusPtr pRadius; // Build the satellite name itoa(iNext++, buf, 10); bstrName = "Satellite"; bstrName += buf; // 确保首先执行了 NewScenario 操作 ASSERT(pRoot != NULL); // Add a new instance of the Satellite to the scenario // eSatellite在文件agstkobjects.tlh中定义,表示STK中的卫星对象 //enum AgESTKObjectType //{ // ... = 17, // eSatellite = 18, // ... = 19, //}; // 注:本例中的绝大部分STK对象都是在agstkobjects.tlh/.tli文件中声明的(原型) // IAgStkObjectRootPtr pRoot,此为STK应用中所有对象的ROOT(根) // IAgStkObjectPtr IAgStkObjectRoot::GetCurrentScenario(),通过根对象得到当前的场景对象 // IAgStkObjectCollectionPtr IAgStkObject::GetChildren(),通过当前场景对象得到对象集合(object collection) // IAgStkObjectPtr IAgStkObjectCollection::New(enum AgESTKObjectType EClassType, _bstr_t InstName),通过对象集合新建一个对象 // 执行对象创建的是接口 IAgStkObjectCollection(即,场景的对象集合) pNewObj = pRoot->GetCurrentScenario()->GetChildren()->New(eSatellite, bstrName); // 下面的赋值应当在确定新建对象确实与等号左侧对象为同一类型 pSat = pNewObj; // Set the propagator type // 设置轨道预报器:ePropagatorTwoBody,STK给的对外接口中定义了 15 种轨道预报器 pSat->SetPropagatorType( ePropagatorTwoBody ); // 赋值,pSat->Propagator(IAgVePropagatorPtr Propagator;) // 可以将 IAgVePropagatorPtr 类型的接口指针赋值给 IAgVePropagatorTwoBodyPtr 类型的接口指针? // 类似于前面的赋值语句:pSat = pNewObj; pTwoBodyProp = |

最低0.47元/天 解锁文章
3572

被折叠的 条评论
为什么被折叠?



