PCL
OsculatingElements.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/OsculatingElements.h - Released 2024-06-18T15:48:54Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_OsculatingElements_h
53 #define __PCL_OsculatingElements_h
54 
56 
57 #include <pcl/Defs.h>
58 
59 #include <pcl/TimePoint.h>
60 #include <pcl/Vector.h>
61 
62 namespace pcl
63 {
64 
65 // ----------------------------------------------------------------------------
66 
90 class PCL_CLASS OsculatingElements
91 {
92 public:
93 
94  double a = 0.0;
95  double q = 0.0;
96  double e = 0.0;
97  double M = 0.0;
98  TimePoint T = 0.0;
99  double i = 0.0;
100  double O = 0.0;
101  double w = 0.0;
102 
107  OsculatingElements() = default;
108 
113 
136  OsculatingElements( const Vector& r, const Vector& v, const TimePoint& t, double GM = 0, double m = 0 );
137 
161  static OsculatingElements FromStateVectors( const Vector& r, const Vector& v, const TimePoint& t, double GM = 0, double m = 0 )
162  {
163  return OsculatingElements( r, v, t, GM, m );
164  }
165 
188  void ToStateVectors( Vector& r, Vector& v, const TimePoint& t, double GM = 0, double m = 0 ) const;
189 
199  inline bool IsNearParabolic() const
200  {
201  return Abs( 1 - this->e ) < 0.001;
202  }
203 
218  double MeanMotion( double GM = 0, double m = 0 ) const;
219 
233  double OrbitalPeriod( double GM = 0, double m = 0 ) const;
234 
249  double MeanAnomalyFromTimeOfPerifocalPassage( const TimePoint& t, double GM = 0, double m = 0 ) const
250  {
251  return Norm2Pi( MeanMotion( GM, m )*(t - this->T) );
252  }
253 
260  double MeanAnomalyFromTimeOfPerihelionPassage( const TimePoint& t, double GM = 0, double m = 0 ) const
261  {
262  return MeanAnomalyFromTimeOfPerifocalPassage( t, GM, m );
263  }
264 
279  TimePoint TimeOfPerifocalPassageFromMeanAnomaly( const TimePoint& t, double GM = 0, double m = 0 ) const
280  {
281  return t - this->M/MeanMotion( GM, m );
282  }
283 
290  TimePoint TimeOfPerihelionPassageFromMeanAnomaly( const TimePoint& t, double GM = 0, double m = 0 ) const
291  {
292  return TimeOfPerifocalPassageFromMeanAnomaly( t, GM, m );
293  }
294 
299  {
300  return (1 - this->e)*this->a;
301  }
302 
310  {
311  return PerifocalDistanceFromSemimajorAxis();
312  }
313 
318  {
319  double ai = (1 - this->e)/this->q;
320  if ( Abs( ai ) < 2*std::numeric_limits<double>::epsilon() )
321  return 0;
322  return 1/ai;
323  }
324 
332  {
333  return SemimajorAxisFromPerifocalDistance();
334  }
335 
361  void ToPerifocalPositionAndVelocity( double& xp, double& yp, double& xv, double& yv, const TimePoint& t, double GM = 0, double m = 0 ) const;
362 
386  void ToPerifocalPosition( double& xp, double& yp, const TimePoint& t, double GM = 0, double m = 0 ) const
387  {
388  double u1, u2;
389  ToPerifocalPositionAndVelocity( xp, yp, u1, u2, t, GM, m );
390  }
391 
423  static void GetOrbitOrientationFromStateVectors( double& i, double& O, double& w, const Vector& r, const Vector& v, double GM = 0, double m = 0 );
424 };
425 
426 // ----------------------------------------------------------------------------
427 
428 } // pcl
429 
430 #endif // __PCL_OsculatingElements_h
431 
432 // ----------------------------------------------------------------------------
433 // EOF pcl/OsculatingElements.h - Released 2024-06-18T15:48:54Z
Generic vector of arbitrary length.
Definition: Vector.h:107
Osculating conic orbital elements.
double MeanMotion(double GM=0, double m=0) const
double PerihelionDistanceFromSemimajorAxis() const
OsculatingElements(const OsculatingElements &)=default
static void GetOrbitOrientationFromStateVectors(double &i, double &O, double &w, const Vector &r, const Vector &v, double GM=0, double m=0)
double MeanAnomalyFromTimeOfPerihelionPassage(const TimePoint &t, double GM=0, double m=0) const
double MeanAnomalyFromTimeOfPerifocalPassage(const TimePoint &t, double GM=0, double m=0) const
void ToPerifocalPosition(double &xp, double &yp, const TimePoint &t, double GM=0, double m=0) const
double OrbitalPeriod(double GM=0, double m=0) const
TimePoint TimeOfPerifocalPassageFromMeanAnomaly(const TimePoint &t, double GM=0, double m=0) const
static OsculatingElements FromStateVectors(const Vector &r, const Vector &v, const TimePoint &t, double GM=0, double m=0)
void ToStateVectors(Vector &r, Vector &v, const TimePoint &t, double GM=0, double m=0) const
TimePoint TimeOfPerihelionPassageFromMeanAnomaly(const TimePoint &t, double GM=0, double m=0) const
void ToPerifocalPositionAndVelocity(double &xp, double &yp, double &xv, double &yv, const TimePoint &t, double GM=0, double m=0) const
double SemimajorAxisFromPerifocalDistance() const
double PerifocalDistanceFromSemimajorAxis() const
double SemimajorAxisFromPerihelionDistance() const
OsculatingElements(const Vector &r, const Vector &v, const TimePoint &t, double GM=0, double m=0)
An instant in any timescale.
Definition: TimePoint.h:103
T Abs(const Complex< T > &c) noexcept
Definition: Complex.h:429
constexpr T Norm2Pi(T x) noexcept
Definition: Math.h:2004
PCL root namespace.
Definition: AbstractImage.h:77