Skip to content

Commit 5c593c3

Browse files
Merge pull request #12 from open-space-collective/users/lucas/update-physics
[misc] Update Physics dependency, and Derived::Unit
2 parents 5cbd3aa + 0ca46e2 commit 5c593c3

File tree

5 files changed

+149
-139
lines changed

5 files changed

+149
-139
lines changed

src/Library/Astrodynamics/Trajectory/Orbit.cpp

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ namespace astro
3838
namespace trajectory
3939
{
4040

41+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
42+
43+
using library::physics::units::Length ;
44+
using library::physics::units::Derived ;
45+
46+
static const Derived::Unit GravitationalParameterSIUnit = Derived::Unit::GravitationalParameter(Length::Unit::Meter, library::physics::units::Time::Unit::Second) ;
47+
4148
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
4249

4350
Orbit::Orbit ( const orbit::Model& aModel,
@@ -140,7 +147,7 @@ Pass Orbit::getPassAt (
140147
}
141148

142149
return this->getPassWithRevolutionNumber(this->getRevolutionNumberAt(anInstant)) ;
143-
150+
144151
}
145152

146153
Pass Orbit::getPassWithRevolutionNumber ( const Integer& aRevolutionNumber ) const
@@ -181,7 +188,7 @@ Pass Orbit::getPassWithRevolutionNumber (
181188

182189
const auto lowerBoundMapIt = passMap_.lower_bound(aRevolutionNumber) ;
183190

184-
if (lowerBoundMapIt != passMap_.end())
191+
if (lowerBoundMapIt != passMap_.end())
185192
{
186193
// std::cout << "lowerBoundMap = " << lowerBoundMapIt->second << std::endl ;
187194

@@ -202,7 +209,7 @@ Pass Orbit::getPassWithRevolutionNumber (
202209
{
203210
closestPassPtr = &(lowerBoundMapIt->second) ;
204211
}
205-
212+
206213
}
207214

208215
}
@@ -284,7 +291,7 @@ Pass Orbit::getPassWithRevolutionNumber (
284291
{
285292
stepDuration = Duration::Seconds(-currentStateCoordinates_ECI_z * stepDuration.inSeconds() / (currentStateCoordinates_ECI_z - previousStateCoordinates_ECI_z)) ;
286293
}
287-
294+
288295
if (stepDuration.isZero())
289296
{
290297
stepDuration = (currentStateCoordinates_ECI_z < 0.0) ? Duration::Nanoseconds(+1.0) : Duration::Nanoseconds(-1.0) ;
@@ -356,7 +363,7 @@ Pass Orbit::getPassWithRevolutionNumber (
356363
}
357364

358365
return Pass::Undefined() ;
359-
366+
360367
}
361368

362369
Shared<const Frame> Orbit::getOrbitalFrame ( const Orbit::FrameType& aFrameType ) const
@@ -421,14 +428,14 @@ Shared<const Frame> Orbit::getOrbitalFrame (
421428
break ;
422429

423430
}
424-
431+
425432
case Orbit::FrameType::LVLH:
426433
{
427434

428435
// X axis along position vector
429436
// Z axis along orbital momentum
430437
// Y axis toward velocity vector
431-
438+
432439
const Shared<const DynamicProvider> dynamicProviderSPtr = std::make_shared<const DynamicProvider>
433440
(
434441
[this] (const Instant& anInstant) -> Transform // [TBI] Use shared_from_this instead
@@ -456,7 +463,7 @@ Shared<const Frame> Orbit::getOrbitalFrame (
456463
orbitalFrameSPtr = Frame::Construct(frameName, false, Frame::GCRF(), dynamicProviderSPtr) ;
457464

458465
break ;
459-
466+
460467
}
461468

462469
case Orbit::FrameType::VVLH:
@@ -465,7 +472,7 @@ Shared<const Frame> Orbit::getOrbitalFrame (
465472
// Z axis along negative position vector
466473
// Y axis along negative orbital momentum
467474
// X axis toward velocity vector
468-
475+
469476
const Shared<const DynamicProvider> dynamicProviderSPtr = std::make_shared<const DynamicProvider>
470477
(
471478
[this] (const Instant& anInstant) -> Transform // [TBI] Use shared_from_this instead
@@ -493,7 +500,7 @@ Shared<const Frame> Orbit::getOrbitalFrame (
493500
orbitalFrameSPtr = Frame::Construct(frameName, false, Frame::GCRF(), dynamicProviderSPtr) ;
494501

495502
break ;
496-
503+
497504
}
498505

499506
case Orbit::FrameType::QSW:
@@ -571,7 +578,7 @@ Shared<const Frame> Orbit::getOrbitalFrame (
571578
case Orbit::FrameType::VNC:
572579
{
573580

574-
// X axis along velocity vector
581+
// X axis along velocity vector
575582
// Y axis along orbital momentum
576583

577584
const Shared<const DynamicProvider> dynamicProviderSPtr = std::make_shared<const DynamicProvider>
@@ -764,9 +771,9 @@ Orbit Orbit::SunSynchronous (
764771
{
765772

766773
using library::core::types::Uint8 ;
767-
774+
768775
using library::math::obj::Vector3d ;
769-
776+
770777
using library::physics::units::Mass ;
771778
using library::physics::units::Derived ;
772779
using library::physics::time::Scale ;
@@ -802,7 +809,7 @@ Orbit Orbit::SunSynchronous (
802809

803810
const Real a = aSemiMajorAxis.inMeters() ;
804811
const Real R = aCelestialObjectSPtr->getEquatorialRadius().inMeters() ;
805-
const Real mu = aCelestialObjectSPtr->getGravitationalParameter().in({ Length::Unit::Meter, Derived::Order(3), Mass::Unit::Undefined, Derived::Order::Zero(), library::physics::units::Time::Unit::Second, Derived::Order(-2), Angle::Unit::Undefined, Derived::Order::Zero() }) ;
812+
const Real mu = aCelestialObjectSPtr->getGravitationalParameter().in(GravitationalParameterSIUnit) ;
806813
const Real j2 = aCelestialObjectSPtr->getJ2() ;
807814

808815
const Real T_sid = 31558149.504 ; // [s] Sidereal year
@@ -838,7 +845,7 @@ Orbit Orbit::SunSynchronous (
838845
const Real sunEclipticLatitude_rad = Angle::Degrees(std::fmod(sunMeanLongitude_deg + 1.914666471 * std::sin(sunMeanAnomaly_rad) + 0.019994643 * std::sin(2.0 * sunMeanAnomaly_rad), 360.0)).inRadians() ;
839846

840847
// Compute the equation of time
841-
848+
842849
const Real equationOfTime_deg = - 1.914666471 * std::sin(sunMeanAnomaly_rad)
843850
- 0.019994643 * std::sin(2.0 * sunMeanAnomaly_rad)
844851
+ 2.466 * std::sin(2.0 * sunEclipticLatitude_rad)
@@ -865,30 +872,30 @@ Orbit Orbit::SunSynchronous (
865872
environment.setInstant(anEpoch) ;
866873

867874
// Sun direction in GCRF
868-
875+
869876
const Vector3d sunDirection_GCRF = environment.accessCelestialObjectWithName("Sun")->getPositionIn(Frame::GCRF()).getCoordinates().normalized() ;
870877

871878
// Desired angle between the Sun and the ascending node
872-
879+
873880
const Angle alpha = Angle::Degrees((localTime - 12.0) / 12.0 * 180.0) ;
874881

875882
// Sun Apparent Local Time (right ascension of the Sun in GCRF)
876883
// https://en.wikipedia.org/wiki/Solar_time#Apparent_solar_time
877-
884+
878885
const Angle apparentSolarTime = Angle::Radians(std::atan2(sunDirection_GCRF.y(), sunDirection_GCRF.x())) ;
879886

880887
// Equation of Time
881888
// https://en.wikipedia.org/wiki/Equation_of_time
882-
889+
883890
const Angle equationOfTime = calculateEquationOfTime(anEpoch) ;
884891

885892
// Sun Mean Local Time
886893
// https://en.wikipedia.org/wiki/Solar_time#Mean_solar_time
887894

888895
const Angle meanSolarTime = apparentSolarTime + equationOfTime ;
889-
896+
890897
// Right Ascension of the Ascending Node
891-
898+
892899
const Angle raan = Angle::Radians(std::fmod(meanSolarTime.inRadians() + alpha.inRadians(), Real::TwoPi())) ;
893900

894901
return raan ;
@@ -1077,4 +1084,4 @@ String Orbit::StringFromFrameType (
10771084
}
10781085
}
10791086

1080-
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1087+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)