二体预报器
2026/1/21大约 2 分钟
二体预报器
概述
二体预报器基于开普勒方程的解析解,提供理想二体问题的轨道预报功能。该方法计算效率高,适用于对精度要求不高的快速轨道预报场景。
核心概念
二体问题
二体问题假设系统中只有两个质点,在相互引力作用下运动。该问题有解析解,轨道形状为圆锥曲线(椭圆、抛物线或双曲线)。
预报原理
二体预报器使用开普勒方程计算给定时间间隔后的轨道状态
主要接口
函数接口
AST_CORE_CAPI errc_t aTwoBodyProp(double duration, double gm, Vector3d& r, Vector3d& v);参数说明:
duration:传播时间间隔(秒)gm:引力常数(m³/s²)r:输入/输出位置向量(米)v:输入/输出速度向量(米/秒)
返回值:
- 成功返回
0 - 失败返回相应的错误码
用法示例
1. 基本二体传播
#include "AstCore/TwoBody.hpp"
#include "AstCore/TimePoint.hpp"
#include "AstMath/Vector.hpp"
#include "AstUtil/Literals.hpp"
#include "AstUtil/Constants.h"
#include <iostream>
#include <iomanip>
AST_USING_NAMESPACE
using namespace _AST literals;
int main()
{
// 地球引力常数 (m³/s²)
const double gm_earth = 3.986004418e14;
// 初始轨道状态 (近地轨道)
Vector3d position{7000_km, 0.0, 0.0}; // 位置向量 (米)
Vector3d velocity{0.0, 7.5_km_s, 0.0}; // 速度向量 (米/秒)
std::cout << "初始轨道状态:" << std::endl;
std::cout << "位置: (" << position[0] << ", " << position[1] << ", " << position[2] << ") m" << std::endl;
std::cout << "速度: (" << velocity[0] << ", " << velocity[1] << ", " << velocity[2] << ") m/s" << std::endl;
std::cout << std::endl;
// 传播时间间隔 (1小时)
double duration = 3600.0; // 秒
// 执行二体传播
errc_t result = aTwoBodyProp(duration, gm_earth, position, velocity);
if (result == eNoError) {
std::cout << "传播后轨道状态 (" << duration << " 秒后):" << std::endl;
std::cout << "位置: (" << position[0] << ", " << position[1] << ", " << position[2] << ") m" << std::endl;
std::cout << "速度: (" << velocity[0] << ", " << velocity[1] << ", " << velocity[2] << ") m/s" << std::endl;
// 计算轨道半径
double radius = position.norm();
std::cout << "轨道半径: " << radius / 1000.0 << " km" << std::endl;
// 计算轨道速度
double speed = velocity.norm();
std::cout << "轨道速度: " << speed / 1000.0 << " km/s" << std::endl;
} else {
std::cout << "传播失败,错误码: " << result << std::endl;
}
return 0;
}2. 地球轨道传播
#include "AstCore/TwoBody.hpp"
#include "AstMath/Vector.hpp"
#include "AstUtil/Literals.hpp"
#include "AstUtil/Constants.h"
#include <iostream>
#include <iomanip>
#include <cmath>
AST_USING_NAMESPACE
using namespace _AST literals;
int main()
{
// 地球引力常数
const double gm_earth = kEarthGrav;
// 地球同步轨道示例 (高度约35786 km)
double altitude = 35786_km;
double radius = kEarthRadius + altitude;
// 计算轨道速度 (圆轨道)
double orbital_velocity = std::sqrt(gm_earth / radius);
// 初始轨道状态 (地球同步轨道)
Vector3d position{radius, 0.0, 0.0};
Vector3d velocity{0.0, orbital_velocity, 0.0};
std::cout << std::fixed << std::setprecision(3);
std::cout << "地球同步轨道传播示例" << std::endl;
std::cout << "=====================" << std::endl;
std::cout << "轨道高度: " << altitude / 1000.0 << " km" << std::endl;
std::cout << "轨道半径: " << radius / 1000.0 << " km" << std::endl;
std::cout << "轨道速度: " << orbital_velocity / 1000.0 << " km/s" << std::endl;
std::cout << "轨道周期: " << (2 * kPI * radius / orbital_velocity) / 3600.0 << " 小时" << std::endl;
std::cout << std::endl;
// 传播多个时间点
double orbital_period = 2 * kPI * radius / orbital_velocity; // 轨道周期 (秒)
std::cout << "轨道传播结果:" << std::endl;
std::cout << "时间(小时)\tX(km)\t\tY(km)\t\tZ(km)\t\t速度(km/s)" << std::endl;
std::cout << "----------------------------------------------------------------" << std::endl;
for (int i = 0; i <= 4; i++) {
double time = i * orbital_period / 4.0; // 四分之一轨道周期
// 复制初始状态
Vector3d current_pos = position;
Vector3d current_vel = velocity;
// 执行二体传播
errc_t result = aTwoBodyProp(time, gm_earth, current_pos, current_vel);
if (result == eNoError) {
double speed = current_vel.norm();
std::cout << std::setw(8) << time/3600.0 << "\t"
<< std::setw(10) << current_pos[0]/1000.0 << "\t"
<< std::setw(10) << current_pos[1]/1000.0 << "\t"
<< std::setw(10) << current_pos[2]/1000.0 << "\t"
<< std::setw(10) << speed/1000.0 << std::endl;
} else {
std::cout << "传播失败,错误码: " << result << std::endl;
break;
}
}
return 0;
}精度与限制
精度特点
- 计算精度:解析解,理论上无截断误差
- 适用范围:理想二体问题,忽略所有摄动力
- 计算效率:非常高,适合需要极高计算效率的应用
使用限制
- 不适用于需要考虑地球扁率、大气阻力、三体引力等摄动力的场景
- 长时间传播时,由于模型简化,误差会累积
- 对于高精度轨道预报需求,建议使用HPOP等数值方法
注意事项
- 输入的位置和速度向量应在同一惯性坐标系下
- 引力常数应与中心天体匹配
- 传播时间间隔不宜过长,避免数值误差累积
- 对于近圆轨道,计算精度较高;对于高偏心率轨道,需要注意数值稳定性
API参考
///
/// @file TwoBody.hpp
/// @brief
/// @details ~
/// @author axel
/// @date 15.11.2025
/// @copyright 版权所有 (C) 2025-present, ast项目.
///
/// ast项目(https://github.com/space-ast/ast)
/// 本项目基于 Apache 2.0 开源许可证分发。
/// 您可在遵守许可证条款的前提下使用、修改和分发本软件。
/// 许可证全文请见:
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// 重要须知:
/// 软件按“现有状态”提供,无任何明示或暗示的担保条件。
/// 除非法律要求或书面同意,作者与贡献者不承担任何责任。
/// 使用本软件所产生的风险,需由您自行承担。
#pragma once
#include "AstGlobal.h"
#include "Propagator.hpp"
AST_NAMESPACE_BEGIN
/*!
@addtogroup Propagator
@{
*/
/// @brief 二体传播
/// @details
/// @param duration 传播时间
/// @param gm 引力常数
/// @param r 位置向量
/// @param v 速度向量
/// @return 错误码
AST_CORE_CAPI errc_t aTwoBodyProp(double duration, double gm, Vector3d& r, Vector3d& v);
class TwoBody : public Propagator
{
public:
};
/*! @} */
AST_NAMESPACE_END