Skip to content

Commit

Permalink
feat: add overloaded ctor for COE
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-liang3 committed Dec 16, 2024
1 parent 8e27340 commit 3b270a3
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Model_Kepler_COE(py

using ostk::core::type::Real;

using ostk::physics::environment::object::Celestial;
using ostk::physics::unit::Angle;
using ostk::physics::unit::Length;

Expand Down Expand Up @@ -389,7 +390,69 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Trajectory_Orbit_Model_Kepler_COE(py

.def_static(
"frozen_orbit",
&COE::FrozenOrbit,
overload_cast<
const Length&,
const Shared<const Celestial>&,
const Real&,
const Angle&,
const Angle&,
const Angle&,
const Angle&>(&COE::FrozenOrbit),
R"doc(
Build a `COE` model of a frozen orbit.
The critical angles for inclination are 63.4349 degrees and 116.5651 degrees.
The critical angles for AoP are 90.0 degrees and 270.0 degrees.
At a minimum, a semi-major axis and shared pointer to a central celestial body with a defined J2 and J3
must be provided. In this case, the inclination and AoP are set to critical angles, and the eccentricity
is derived from inclination. RAAN and true anomaly default to zero degrees.
Additionally, the following combinations of inputs are supported:
- AoP (inclination set to critical value, eccentricity derived)
- AoP and eccentricity (inclination derived)
- AoP and inclination, but at least one of them must be a critical value (eccentricity derived)
- Inclination (AoP set to critical value, eccentricity derived)
- Eccentricity (AoP set to critical value, inclination derived)
Note that inclination and eccentricity cannot both be proivided.
RAAN and True Anomaly may be provided alongside any of these arguments, and will be passed through
to the resulting COE as they do not impact the frozen orbit condition.
Args:
semi_major_axis (Length): The semi-major axis.
celestial_object (Celestial): The celestial object.
eccentricity (float): The eccentricity.
inclination (Angle): The inclination.
raan (Angle): The right ascension of the ascending node.
aop (Angle): The argument of periapsis.
true_anomaly (Angle): The true anomaly.
Returns:
COE: The `COE` model.
)doc",
arg("semi_major_axis"),
arg("celestial_object"),
arg_v("eccentricity", Real::Undefined(), "Real.undefined()"),
arg_v("inclination", Angle::Undefined(), "Angle.undefined()"),
arg_v("raan", Angle::Degrees(0.0), "Angle.degrees(0.0)"),
arg_v("aop", Angle::Undefined(), "Angle.undefined()"),
arg_v("true_anomaly", Angle::Degrees(0.0), "Angle.degrees(0.0)")
)

.def_static(
"frozen_orbit",
overload_cast<
const Length&,
const Length&,
const Real&,
const Real&,
const Real&,
const Angle&,
const Angle&,
const Angle&,
const Angle&>(&COE::FrozenOrbit),
R"doc(
Build a `COE` model of a frozen orbit.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ using ostk::mathematics::object::Vector6d;
using ostk::physics::coordinate::Frame;
using ostk::physics::coordinate::Position;
using ostk::physics::coordinate::Velocity;
using ostk::physics::environment::object::Celestial;
using ostk::physics::environment::object::celestial::Sun;
using ostk::physics::time::Duration;
using ostk::physics::time::Instant;
Expand Down Expand Up @@ -252,6 +253,45 @@ class COE
/// @return COE
static COE FromSIVector(const Vector6d& aCOEVector, const AnomalyType& anAnomalyType);

/// @brief Construct a frozen orbit from an incomplete set of COEs
///
/// The critical angles for inclination are 63.4349 degrees and 116.5651 degrees.
/// The critical angles for AoP are 90.0 degrees and 270.0 degrees.
///
/// At a minimum, a semi-major axis and shared pointer to a central celestial body with a defined J2 and J3
/// must be provided. In this case, the inclination and AoP are set to critical angles, and the eccentricity
/// is derived from inclination. RAAN and true anomaly default to zero degrees.
///
/// Additionally, the following combinations of inputs are supported:
/// - AoP (inclination set to critical value, eccentricity derived)
/// - AoP and eccentricity (inclination derived)
/// - AoP and inclination, but at least one of them must be a critical value (eccentricity derived)
/// - Inclination (AoP set to critical value, eccentricity derived)
/// - Eccentricity (AoP set to critical value, inclination derived)
///
/// Note that inclination and eccentricity cannot both be proivided.
///
/// RAAN and True Anomaly may be provided alongside any of these arguments, and will be passed through
/// to the resulting COE as they do not impact the frozen orbit condition.
///
/// @param aSemiMajorAxis A semi-major axis
/// @param aCelestialObjectSPtr A shared pointer to a central celestial body
/// @param anEccentricity An eccentricity
/// @param anInclination An inclination
/// @param aRaan A raan
/// @param anAop An aop
/// @param aTrueAnomaly A true anomaly
/// @return COE
static COE FrozenOrbit(
const Length& aSemiMajorAxis,
const Shared<const Celestial>& aCelestialObjectSPtr,
const Real& anEccentricity = Real::Undefined(),
const Angle& anInclination = Angle::Undefined(),
const Angle& aRaan = Angle::Degrees(0.0),
const Angle& anAop = Angle::Undefined(),
const Angle& aTrueAnomaly = Angle::Degrees(0.0)
);

/// @brief Construct a frozen orbit from an incomplete set of COEs
///
/// The critical angles for inclination are 63.4349 degrees and 116.5651 degrees.
Expand Down
6 changes: 1 addition & 5 deletions src/OpenSpaceToolkit/Astrodynamics/Trajectory/Orbit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,24 +1093,20 @@ Orbit Orbit::Frozen(
{
throw ostk::core::error::runtime::Undefined("Epoch");
}

if (!anAltitude.isDefined())
{
throw ostk::core::error::runtime::Undefined("Altitude");
}

if ((aCelestialObjectSPtr == nullptr) || (!aCelestialObjectSPtr->isDefined()))
{
throw ostk::core::error::runtime::Undefined("Celestial object");
}

const Length equatorialRadius = aCelestialObjectSPtr->getEquatorialRadius();
const Length semiMajorAxis = equatorialRadius + anAltitude;
const Real j2 = aCelestialObjectSPtr->accessGravitationalModel()->getParameters().J2_;
const Real j3 = aCelestialObjectSPtr->accessGravitationalModel()->getParameters().J3_;

const COE coe = COE::FrozenOrbit(
semiMajorAxis, equatorialRadius, j2, j3, anEccentricity, anInclination, aRaan, anAop, aTrueAnomaly
semiMajorAxis, aCelestialObjectSPtr, anEccentricity, anInclination, aRaan, anAop, aTrueAnomaly
);

const Kepler orbitalModel = {coe, anEpoch, {*aCelestialObjectSPtr}, Kepler::PerturbationType::J2, false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,30 @@ COE COE::FromSIVector(const Vector6d& aCOEVector, const AnomalyType& anAnomalyTy
};
}

COE COE::FrozenOrbit(
const Length& aSemiMajorAxis,
const Shared<const Celestial>& aCelestialObjectSPtr,
const Real& anEccentricity,
const Angle& anInclination,
const Angle& aRaan,
const Angle& anAop,
const Angle& aTrueAnomaly
)
{
if ((aCelestialObjectSPtr == nullptr) || (!aCelestialObjectSPtr->isDefined()))
{
throw ostk::core::error::runtime::Undefined("Celestial object");
}

const Length equatorialRadius = aCelestialObjectSPtr->getEquatorialRadius();
const Real j2 = aCelestialObjectSPtr->accessGravitationalModel()->getParameters().J2_;
const Real j3 = aCelestialObjectSPtr->accessGravitationalModel()->getParameters().J3_;

return COE::FrozenOrbit(
aSemiMajorAxis, equatorialRadius, j2, j3, anEccentricity, anInclination, aRaan, anAop, aTrueAnomaly
);
}

COE COE::FrozenOrbit(
const Length& aSemiMajorAxis,
const Length& anEquatorialRadius,
Expand Down

0 comments on commit 3b270a3

Please sign in to comment.