Skip to content

Commit

Permalink
Remove debug statements from rv2coe function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Kumar committed May 30, 2023
1 parent db1ef98 commit 46671f3
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions include/astro/orbitalElementConversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

#include "astro/stateVectorIndices.hpp"

// (debug)
#include <iostream>

namespace astro
{

Expand Down Expand Up @@ -103,9 +100,6 @@ Vector6 convertCartesianToKeplerianElements(
const Real positionNorm = std::sqrt(positionNormSquared);
const Real positionNormInverse = 1.0 / positionNorm;

std::cout << "(debug) r: " << positionNorm << std::endl;
std::cout << "(debug) r_scaled: " << positionNorm / 6378.137 << std::endl;

// Cartesian velocity
const Vector velocity = Vector({cartesianElements[xVelocityIndex],
cartesianElements[yVelocityIndex],
Expand All @@ -115,9 +109,6 @@ std::cout << "(debug) r_scaled: " << positionNorm / 6378.137 << std::endl;
+ velocity[2] * velocity[2];
const Real velocityNorm = std::sqrt(velocityNormSquared);

std::cout << "(debug) v: " << std::sqrt(velocityNormSquared) << std::endl;
std::cout << "(debug) v_scaled: " << velocityNorm / 7.905365719014 << std::endl;

// Angular momentum
const Vector angularMomentum
= Vector({position[1] * velocity[2] - position[2] * velocity[1],
Expand All @@ -131,11 +122,6 @@ std::cout << "(debug) v_scaled: " << velocityNorm / 7.905365719014 << std::endl;
= Vector({angularMomentum[0] / angularMomentumNorm,
angularMomentum[1] / angularMomentumNorm,
angularMomentum[2] / angularMomentumNorm});
std::cout << "(debug) hx: " << angularMomentum[0] << std::endl;
std::cout << "(debug) hy: " << angularMomentum[1] << std::endl;
std::cout << "(debug) hz: " << angularMomentum[2] << std::endl;
std::cout << "(debug) h: " << angularMomentumNorm << std::endl;
std::cout << "(debug) h_scaled: " << angularMomentumNorm / (6378.137 * 7.905365719014) << std::endl;

// Eccentricity
const Real eccentricityVectorFirsTermMultiplier
Expand All @@ -162,19 +148,10 @@ std::cout << "(debug) h_scaled: " << angularMomentumNorm / (6378.137 * 7.9053657
const Real eccentricity = std::sqrt(eccentricityNormSquared);
keplerianElements[1] = eccentricity;

std::cout << "(debug) ex: " << eccentricityVector[0] << std::endl;
std::cout << "(debug) ey: " << eccentricityVector[1] << std::endl;
std::cout << "(debug) ez: " << eccentricityVector[2] << std::endl;
std::cout << "(debug) e: " << keplerianElements[1] << std::endl;
std::cout << "(debug) kep1: " << keplerianElements[1] << std::endl;

// Specifc total energy using the vis-viva equation
const Real specificTotalEnergy
= 0.5 * velocityNormSquared - gravitationalParameter / positionNorm;

std::cout << "(debug) Esp: " << specificTotalEnergy << std::endl;
std::cout << "(debug) Esp_scaled: " << specificTotalEnergy / (7.905365719014 * 7.905365719014)<< std::endl;

// Semi-major axis
Real semiMajorAxis = std::numeric_limits<Real>::quiet_NaN();
Real semiLatusRectum = std::numeric_limits<Real>::quiet_NaN();
Expand All @@ -191,27 +168,14 @@ std::cout << "(debug) Esp_scaled: " << specificTotalEnergy / (7.905365719014 * 7
keplerianElements[0] = semiLatusRectum;
}
assert(semiMajorAxis > 0.0);
std::cout << "(debug) a: " << semiMajorAxis << std::endl;
std::cout << "(debug) p: " << semiLatusRectum << std::endl;
std::cout << "(debug) kep0: " << keplerianElements[0] << std::endl;

// Inclination
const Real inclination = std::acos(angularMomentumUnitVector[2]);
keplerianElements[2] = inclination;

std::cout << "(debug) i: " << keplerianElements[2] / pi * 180.0 << std::endl;
std::cout << "(debug) kep2: " << keplerianElements[2] << std::endl;

// Ascending node vector
const Vector ascendingNodeVector
= Vector({-angularMomentum[1], angularMomentum[0], 0.0});
std::cout << "(debug) nx: " << ascendingNodeVector[0] << std::endl;
std::cout << "(debug) ny: " << ascendingNodeVector[1] << std::endl;
std::cout << "(debug) nz: " << ascendingNodeVector[2] << std::endl;

std::cout << "(debug) nx_scaled: " << ascendingNodeVector[0] / (6378.137 * 7.905365719014) << std::endl;
std::cout << "(debug) ny_scaled: " << ascendingNodeVector[1] / (6378.137 * 7.905365719014) << std::endl;
std::cout << "(debug) nz_scaled: " << ascendingNodeVector[2] / (6378.137 * 7.905365719014) << std::endl;

const Real ascendingNodeVectorNormSquared
= ascendingNodeVector[0] * ascendingNodeVector[0]
Expand All @@ -220,33 +184,21 @@ std::cout << "(debug) nz_scaled: " << ascendingNodeVector[2] / (6378.137 * 7.905

const Real ascendingNodeVectorNorm = std::sqrt(ascendingNodeVectorNormSquared);

std::cout << "(debug) n: " << ascendingNodeVectorNorm / (6378.137 * 7.905365719014) << std::endl;

const Vector ascendingNodeUnitVector
= Vector({ascendingNodeVector[0] / ascendingNodeVectorNorm,
ascendingNodeVector[1] / ascendingNodeVectorNorm,
ascendingNodeVector[2] / ascendingNodeVectorNorm });

std::cout << "(debug) nx_unit: " << ascendingNodeUnitVector[0] << std::endl;
std::cout << "(debug) ny_unit: " << ascendingNodeUnitVector[1] << std::endl;
std::cout << "(debug) nz_unit: " << ascendingNodeUnitVector[2] << std::endl;
std::cout << "(debug) n_unit: " << ascendingNodeUnitVector[0] * ascendingNodeUnitVector[0]
+ ascendingNodeUnitVector[1] * ascendingNodeUnitVector[1]
+ ascendingNodeUnitVector[2] * ascendingNodeUnitVector[2] << std::endl;

// Longitude of ascending node
Real longitudeOfAscendingNode = std::acos(ascendingNodeUnitVector[0]);

if (ascendingNodeVector[1] < 0.0)
{
longitudeOfAscendingNode = 2.0 * pi - longitudeOfAscendingNode;
}
std::cout << "(debug) raan: " << longitudeOfAscendingNode << std::endl;

keplerianElements[4] = longitudeOfAscendingNode;

std::cout << "(debug) kep4: " << keplerianElements[4] / pi * 180.0 << std::endl;

// Argument of periapsis
const Real ascendingNodeVectorDotEccentricityVector
= ascendingNodeVector[0] * eccentricityVector[0]
Expand All @@ -261,12 +213,8 @@ std::cout << "(debug) kep4: " << keplerianElements[4] / pi * 180.0 << std::endl;
argumentOfPeriapsis = 2.0 * pi - argumentOfPeriapsis;
}

std::cout << "(debug) omega: " << argumentOfPeriapsis << std::endl;

keplerianElements[3] = argumentOfPeriapsis;

std::cout << "(debug) kep3: " << keplerianElements[3] / pi * 180.0 << std::endl;

// True anomaly
const Real eccentricityVectorDotPosition = eccentricityVector[0] * position[0]
+ eccentricityVector[1] * position[1]
Expand All @@ -279,12 +227,8 @@ std::cout << "(debug) kep3: " << keplerianElements[3] / pi * 180.0 << std::endl;
trueAnomaly = 2.0 * pi - trueAnomaly;
}

std::cout << "(debug) ta: " << trueAnomaly << std::endl;

keplerianElements[5] = trueAnomaly;

std::cout << "(debug) kep5: " << keplerianElements[5] / pi * 180.0 << std::endl;

// True longitude of periapsis
Real trueLongitudeOfPeriapsis = std::acos(eccentricityVector[0] / eccentricity);

Expand All @@ -293,18 +237,13 @@ std::cout << "(debug) kep5: " << keplerianElements[5] / pi * 180.0 << std::endl;
trueLongitudeOfPeriapsis = 2.0 * pi - trueLongitudeOfPeriapsis;
}

std::cout << "(debug) omega_true: " << trueLongitudeOfPeriapsis / pi * 180.0 << std::endl;

// Special case: elliptical, equatorial
if(std::fabs(eccentricity) > tolerance && std::fabs(inclination) < tolerance)
{
longitudeOfAscendingNode = std::numeric_limits<Real>::quiet_NaN();
keplerianElements[4] = trueLongitudeOfPeriapsis;
}

std::cout << "(debug) raan: " << longitudeOfAscendingNode << std::endl;
std::cout << "(debug) kep4: " << keplerianElements[4] / pi * 180.0 << std::endl;

// Argument of latitude
const Real ascendingNodeVectorDotPosition = ascendingNodeVector[0] * position[0]
+ ascendingNodeVector[1] * position[1]
Expand All @@ -318,27 +257,20 @@ std::cout << "(debug) kep4: " << keplerianElements[4] / pi * 180.0 << std::endl;
argumentOfLatitude = 2.0 * pi - argumentOfLatitude;
}

std::cout << "(debug) u: " << argumentOfLatitude / pi * 180.0 << std::endl;

// Special case: circular, inclined
if(std::fabs(eccentricity) < tolerance && std::fabs(inclination) > tolerance)
{
argumentOfPeriapsis = std::numeric_limits<Real>::quiet_NaN();
keplerianElements[3] = argumentOfLatitude;
}

std::cout << "(debug) omega: " << argumentOfPeriapsis << std::endl;
std::cout << "(debug) kep3: " << keplerianElements[3] / pi * 180.0 << std::endl;

// True longitude
Real trueLongitude = std::acos(position[0] / positionNorm);
if (position[1] < 0.0)
{
trueLongitude = 2.0 * pi - trueLongitude;
}

std::cout << "(debug) lambda: " << trueLongitude / pi * 180.0 << std::endl;

// // Special case: circular, equatorial
if (std::fabs(eccentricity) < tolerance && std::fabs(inclination) < tolerance)
{
Expand All @@ -347,10 +279,6 @@ std::cout << "(debug) lambda: " << trueLongitude / pi * 180.0 << std::endl;
keplerianElements[5] = trueLongitude;
}

std::cout << "(debug) omega: " << argumentOfPeriapsis << std::endl;
std::cout << "(debug) raan: " << longitudeOfAscendingNode << std::endl;
std::cout << "(debug) kep5: " << keplerianElements[5] / pi * 180.0 << std::endl;

return keplerianElements;
}

Expand Down

0 comments on commit 46671f3

Please sign in to comment.