Two-Body Propagator
1/21/26About 1 min
Two-Body Propagator
Note: This document is AI-translated.
Overview
The two-body propagator provides orbit propagation functionality for ideal two-body problems based on the analytical solution of Kepler's equation. This method offers high computational efficiency and is suitable for fast orbit prediction scenarios where high precision is not required.
Core Concepts
Two-Body Problem
The two-body problem assumes a system with only two point masses moving under mutual gravitational attraction. This problem has an analytical solution, with orbital shapes being conic sections (ellipse, parabola, or hyperbola).
Propagation Principle
The two-body propagator uses Kepler's equation to calculate orbital state after a given time interval:
- Calculate orbital elements from initial position and velocity
- Use Kepler's equation to compute true anomaly after given time
- Calculate position and velocity vectors based on the new true anomaly
Main Interfaces
Function Interface
AST_CORE_CAPI errc_t aTwoBodyProp(double duration, double gm, Vector3d& r, Vector3d& v);Parameter Description:
duration: Propagation time interval (seconds)gm: Gravitational constant (m³/s²)r: Input/output position vector (meters)v: Input/output velocity vector (m/s)
Return Value:
- Returns
AST_OKon success - Returns corresponding error code on failure
Usage Examples
1. Basic Two-Body Propagation
#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. Earth Orbit Propagation
#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;
}Accuracy and Limitations
Accuracy Characteristics
- Calculation Accuracy: Analytical solution, theoretically no truncation error
- Applicability: Ideal two-body problems, ignoring all perturbation forces
- Computational Efficiency: Very high, suitable for real-time applications
Usage Limitations
- Not suitable for scenarios requiring consideration of Earth oblateness, atmospheric drag, third-body gravity, etc.
- Errors accumulate during long-term propagation due to model simplification
- For high-precision orbit prediction requirements, recommend using numerical methods like HPOP
Notes
- Input position and velocity vectors should be in the same inertial coordinate system
- Gravitational constant should match the central body
- Propagation time interval should not be too long to avoid numerical error accumulation
- Higher accuracy for near-circular orbits; numerical stability considerations needed for high-eccentricity orbits
API Reference
///
/// @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