Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
Classes | Typedefs | Enumerations | Functions | Variables
cqsp::common::components::types Namespace Reference

Classes

struct  FuturePosition
 
struct  GalacticCoordinate
 Way to position star systems on the universe. More...
 
struct  Impulse
 
struct  Kinematics
 Relative position from the parent orbiting object. More...
 
struct  MoveTarget
 
struct  Orbit
 
struct  OrbitDirty
 
struct  PolarCoordinate_tp
 
struct  SetTrueAnomaly
 
struct  SurfaceCoordinate
 Longitude and lattitude. Planet coordinates. More...
 

Typedefs

typedef PolarCoordinate_tp< types::astronomical_unitPolarCoordinate
 
typedef glm::dvec3 Vec3AU
 A vector3 where the units are astronomical units More...
 
typedef double astronomical_unit
 
typedef double light_year
 
typedef double kilometer
 
typedef double solar_mass
 
typedef double degree
 
typedef double radian
 
typedef double meter_cube
 
typedef double kilogram
 
typedef double earth_masses
 
typedef double joule
 
typedef double second
 

Enumerations

enum  UnitType {
  Distance , Angle , Mass , Volume ,
  Time
}
 
enum  Distance {
  LightYear , AstronomicalUnit , Kilometer , Meter ,
  Centimeter , Millimeter
}
 

Functions

double GreatCircleDistance (SurfaceCoordinate &coord1, SurfaceCoordinate &coord2)
 Calculates the angle between the two coordinates. Just multiply by the planet's diameter for fun and engagement. More...
 
glm::vec3 toVec3 (const SurfaceCoordinate &coord, const float &radius=1)
 Converts surface coordinate to vector3 in space so that we can get the surface coordinate to render in space More...
 
double GetLaunchAzimuth (double latitude, double inclination)
 Calculates the azimuth of the orbit based on the latitude and inclination More...
 
double GetLaunchInclination (double latitude, double azimuth)
 Calculates the inclination of the orbit based on the latitude and azimuth More...
 
SurfaceCoordinate ToSurfaceCoordinate (const glm::vec3 &vec)
 
glm::vec3 toVec3 (const PolarCoordinate &coordinate)
 2D polar coordinate to opengl 3d coordinate More...
 
double GetOrbitingRadius (const double &e, const double &a, const double &v)
 
glm::dvec3 MatrixConvertOrbParams (const double LAN, const double i, const double w, const glm::dvec3 &vec)
 
glm::dvec3 ConvertOrbParams (const double LAN, const double i, const double w, const glm::dvec3 &vec)
 Transforms a vector to the orbital plane vector More...
 
glm::dvec3 ConvertToOrbitalVector (const double LAN, const double i, const double w, const double v, const glm::dvec3 &vec)
 
Orbit Vec3ToOrbit (const glm::dvec3 &position, const glm::dvec3 &velocity, const double &GM, const double &time)
 Converts position and velocity to orbit. Note: you will have to set the reference body after the orbit is returned More...
 
double GetTrueAnomalyToAsymptope (const Orbit &orbit)
 Calculates v_inf, the true anomaly for the asymtope for a hyperbolic orbit The orbit is bouded within -v_inf < v < v_inf https://orbital-mechanics.space/the-orbit-equation/hyperbolic-trajectories.html#hyperbolic-trajectories-e-1. More...
 
glm::dvec3 OrbitToVec3 (const double &a, const double &e, const radian &i, const radian &LAN, const radian &w, const radian &v)
 Converts an orbit to a vec3. More...
 
double OrbitVelocity (const double v, const double e, const double a, const double GM)
 
double AvgOrbitalVelocity (const Orbit &orb)
 
glm::dvec3 OrbitVelocityToVec3 (const Orbit &orb, double v)
 
glm::dvec3 OrbitVelocityToVec3 (const Orbit &orb)
 
double SolveKeplerElliptic (const double &mean_anomaly, const double &ecc, const int steps=200)
 Computes eccentric anomaly for a elliptic or circular orbit (e < 1) in radians given mean anomaly and eccentricity More...
 
double SolveKeplerHyperbolic (const double &mean_anomaly, const double &ecc, const int steps=200)
 Computes eccentric anomaly for a hyperbolic or parabolic orbit (e > 1) in radians given mean anomaly and eccentricity More...
 
double EccentricAnomalyToTrueAnomaly (const double &ecc, const double &E)
 Calculates true anomaly from eccentricity and eccentric anomaly More...
 
double HyperbolicAnomalyToTrueAnomaly (const double &ecc, const double &H)
 
double GetMtElliptic (const double &M0, const double &nu, const double &time, const double &epoch)
 Gets the Mean anomaly from the time More...
 
double GetMtHyperbolic (const double &M0, const double &nu, const double &time, const double &epoch)
 Calculate mean anomaly from time for a hyperbolic object More...
 
radian TrueAnomalyElliptic (const Orbit &orbit, const second &time)
 
radian TrueAnomalyElliptic (const Orbit &orbit, const second &time, double &E_out)
 
double GetCircularOrbitingVelocity (const double &GM, const double &radius)
 Get the circular orbiting velocity for the radius. More...
 
radian TrueAnomalyHyperbolic (const Orbit &orbit, const second &time)
 
radian EccentricAnomaly (double v, double e)
 Calculates Eccentric anomaly More...
 
radian HyperbolicAnomaly (double v, double e)
 
void UpdateOrbit (Orbit &orb, const second &time)
 Updates the orbit's true anomaly. More...
 
double GetTrueAnomaly (const Orbit &orb, const second &epoch)
 Get anomaly at epoch More...
 
glm::dvec3 CalculateVelocity (const double &E, const double &r, const double &GM, const double &a, const double &e)
 
glm::dvec3 CalculateVelocityHyperbolic (const double &E, const double &r, const double &GM, const double &a, const double &e)
 
glm::dvec3 CalculateVelocityElliptic (const double &E, const double &r, const double &GM, const double &a, const double &e)
 
Orbit ApplyImpulse (const Orbit &orbit, const glm::dvec3 &impulse, double time)
 Applies impulse based on the vector impulse For some reason y is prograde, I'm not sure what the others are. TODO(EhWhoAmI): Determine the axis of thrust for each vector I think x is radial, and z is normal. More...
 
double OrbitVelocityAtR (const double GM, const double a, const double r)
 
glm::dvec3 OrbitTimeToVec3 (const Orbit &orb, const second &time)
 
double CalculateTransferTime (const Orbit &orb1, const Orbit &orb2)
 
double CalculateTransferAngle (const Orbit &start_orbit, const Orbit &end_orbit)
 
double CalculatePhaseAngle (const Orbit &start_orbit, const Orbit &end_orbit, double epoch)
 
double GetHyperbolicAsymptopeAnomaly (double eccentricity)
 
double FlightPathAngle (double eccentricity, double v)
 
glm::dvec3 GetOrbitNormal (const Orbit &orbit)
 
double TrueAnomalyFromVector (const Orbit &orbit, const glm::dvec3 &vec)
 
double AscendingTrueAnomaly (const Orbit &start, const Orbit &dest)
 
Vec3AU toVec3AU (const Orbit &orb, radian theta)
 Convert orbit to AU coordinates More...
 
glm::dvec3 toVec3 (const Orbit &orb, radian theta)
 Converts orbit to theta More...
 
glm::dvec3 toVec3 (const Orbit &orb)
 
Vec3AU toVec3AU (const Orbit &orb)
 Converts orbit to AU coorrdinates. More...
 
void UpdatePos (Kinematics &kin, const Orbit &orb)
 Updates the position of an orbit, in AU. More...
 
constexpr double floatmod (double x, double y)
 
constexpr radian normalize_radian (const radian &radian)
 Normalizes a radian to [0, PI*2) More...
 
constexpr double normalize_radian_coord (const radian &radian)
 
constexpr degree normalize_degree (const degree &radian)
 
constexpr astronomical_unit toAU (kilometer km)
 
constexpr light_year toLightYear (astronomical_unit au)
 
constexpr astronomical_unit LtyrtoAU (light_year ltyr)
 
constexpr kilometer toKm (astronomical_unit au)
 
constexpr radian toRadian (degree theta)
 
constexpr degree toDegree (radian theta)
 
constexpr double operator""_deg (const long double deg)
 
constexpr double operator""_au (const long double au)
 

Variables

constexpr double PI = 3.14159265358979323846
 
constexpr double TWOPI = PI * 2
 
constexpr double HALFPI = PI / 2
 
constexpr double KmInAu = 149597870.700
 
constexpr double G = 6.6743015e-11
 
constexpr double G_km = 6.6743015e-20
 
constexpr double SunMu = 1.32712400188e11
 

Typedef Documentation

◆ astronomical_unit

◆ degree

◆ earth_masses

◆ joule

◆ kilogram

◆ kilometer

◆ light_year

◆ meter_cube

◆ PolarCoordinate

◆ radian

◆ second

◆ solar_mass

◆ Vec3AU

A vector3 where the units are astronomical units

Enumeration Type Documentation

◆ Distance

Enumerator
LightYear 
AstronomicalUnit 
Kilometer 
Meter 
Centimeter 
Millimeter 

◆ UnitType

Enumerator
Distance 
Angle 
Mass 
Volume 
Time 

Function Documentation

◆ ApplyImpulse()

Orbit cqsp::common::components::types::ApplyImpulse ( const Orbit orbit,
const glm::dvec3 &  impulse,
double  time 
)

Applies impulse based on the vector impulse For some reason y is prograde, I'm not sure what the others are. TODO(EhWhoAmI): Determine the axis of thrust for each vector I think x is radial, and z is normal.

Parameters
orbit
impulse
time
Returns

◆ AscendingTrueAnomaly()

double cqsp::common::components::types::AscendingTrueAnomaly ( const Orbit start,
const Orbit dest 
)

◆ AvgOrbitalVelocity()

double cqsp::common::components::types::AvgOrbitalVelocity ( const Orbit orb)

◆ CalculatePhaseAngle()

double cqsp::common::components::types::CalculatePhaseAngle ( const Orbit start_orbit,
const Orbit end_orbit,
double  epoch 
)

◆ CalculateTransferAngle()

double cqsp::common::components::types::CalculateTransferAngle ( const Orbit start_orbit,
const Orbit end_orbit 
)

◆ CalculateTransferTime()

double cqsp::common::components::types::CalculateTransferTime ( const Orbit orb1,
const Orbit orb2 
)

◆ CalculateVelocity()

glm::dvec3 cqsp::common::components::types::CalculateVelocity ( const double &  E,
const kilometer r,
const double &  GM,
const kilometer a,
const double &  e 
)

Calculates the vector velocity of the orbit

Parameters
[in]EEccentric anomaly
[in]rOrbiting radius
[in]GMG*M of orbiting body
[in]aSemi major axis
[in]eeccentricity

◆ CalculateVelocityElliptic()

glm::dvec3 cqsp::common::components::types::CalculateVelocityElliptic ( const double &  E,
const double &  r,
const double &  GM,
const double &  a,
const double &  e 
)

◆ CalculateVelocityHyperbolic()

glm::dvec3 cqsp::common::components::types::CalculateVelocityHyperbolic ( const double &  E,
const double &  r,
const double &  GM,
const double &  a,
const double &  e 
)

◆ ConvertOrbParams()

glm::dvec3 cqsp::common::components::types::ConvertOrbParams ( const double  LAN,
const double  i,
const double  w,
const glm::dvec3 &  vec 
)

Transforms a vector to the orbital plane vector

All units are in radians

Parameters
LANLongitude of the ascending node
iInclination
wArgument of periapsis
vecVector to convert

◆ ConvertToOrbitalVector()

glm::dvec3 cqsp::common::components::types::ConvertToOrbitalVector ( const double  LAN,
const double  i,
const double  w,
const double  v,
const glm::dvec3 &  vec 
)

◆ EccentricAnomaly()

radian cqsp::common::components::types::EccentricAnomaly ( double  v,
double  e 
)

Calculates Eccentric anomaly

Parameters
vTrue anomaly
eEccentricicy
Returns

◆ EccentricAnomalyToTrueAnomaly()

double cqsp::common::components::types::EccentricAnomalyToTrueAnomaly ( const double &  ecc,
const double &  E 
)

Calculates true anomaly from eccentricity and eccentric anomaly

Parameters
[in]eccThe eccentricity of the orbit
[in]EThe eccentric anomaly of the orbit

◆ FlightPathAngle()

double cqsp::common::components::types::FlightPathAngle ( double  eccentricity,
double  v 
)

◆ floatmod()

constexpr double cqsp::common::components::types::floatmod ( double  x,
double  y 
)
inlineconstexpr

◆ GetCircularOrbitingVelocity()

double cqsp::common::components::types::GetCircularOrbitingVelocity ( const double &  GM,
const double &  radius 
)

Get the circular orbiting velocity for the radius.

◆ GetHyperbolicAsymptopeAnomaly()

double cqsp::common::components::types::GetHyperbolicAsymptopeAnomaly ( double  eccentricity)

◆ GetLaunchAzimuth()

double cqsp::common::components::types::GetLaunchAzimuth ( double  latitude,
double  inclination 
)

Calculates the azimuth of the orbit based on the latitude and inclination

Parameters
latitudeLatitude in radians
inclinationLaunch inclination in radians
Returns

◆ GetLaunchInclination()

double cqsp::common::components::types::GetLaunchInclination ( double  latitude,
double  azimuth 
)

Calculates the inclination of the orbit based on the latitude and azimuth

Parameters
latitudeLatitude in radians
azimuthLaunch azimuth in radians
Returns

◆ GetMtElliptic()

double cqsp::common::components::types::GetMtElliptic ( const double &  M0,
const double &  nu,
const double &  time,
const double &  epoch 
)

Gets the Mean anomaly from the time

Parameters
M0Mean anomaly at t=0
nuG*M of orbiting body
timeCurrent time
Returns

◆ GetMtHyperbolic()

double cqsp::common::components::types::GetMtHyperbolic ( const double &  M0,
const double &  nu,
const double &  time,
const double &  epoch 
)

Calculate mean anomaly from time for a hyperbolic object

Parameters
MuG*M of orbiting body
aSemi-major axis
d+tTime from periapsis
Returns

◆ GetOrbitingRadius()

double cqsp::common::components::types::GetOrbitingRadius ( const double &  e,
const double &  a,
const double &  v 
)

◆ GetOrbitNormal()

glm::dvec3 cqsp::common::components::types::GetOrbitNormal ( const Orbit orbit)

◆ GetTrueAnomaly()

double cqsp::common::components::types::GetTrueAnomaly ( const Orbit orb,
const second epoch 
)

Get anomaly at epoch

Parameters
orb
epoch

◆ GetTrueAnomalyToAsymptope()

double cqsp::common::components::types::GetTrueAnomalyToAsymptope ( const Orbit orbit)

Calculates v_inf, the true anomaly for the asymtope for a hyperbolic orbit The orbit is bouded within -v_inf < v < v_inf https://orbital-mechanics.space/the-orbit-equation/hyperbolic-trajectories.html#hyperbolic-trajectories-e-1.

Parameters
orbit
Returns

◆ GreatCircleDistance()

double cqsp::common::components::types::GreatCircleDistance ( SurfaceCoordinate coord1,
SurfaceCoordinate coord2 
)

Calculates the angle between the two coordinates. Just multiply by the planet's diameter for fun and engagement.

Parameters
coord1
coord2
Returns

◆ HyperbolicAnomaly()

radian cqsp::common::components::types::HyperbolicAnomaly ( double  v,
double  e 
)

◆ HyperbolicAnomalyToTrueAnomaly()

double cqsp::common::components::types::HyperbolicAnomalyToTrueAnomaly ( const double &  ecc,
const double &  H 
)

◆ LtyrtoAU()

constexpr astronomical_unit cqsp::common::components::types::LtyrtoAU ( light_year  ltyr)
inlineconstexpr

◆ MatrixConvertOrbParams()

glm::dvec3 cqsp::common::components::types::MatrixConvertOrbParams ( const double  LAN,
const double  i,
const double  w,
const glm::dvec3 &  vec 
)

◆ normalize_degree()

constexpr degree cqsp::common::components::types::normalize_degree ( const degree radian)
inlineconstexpr

◆ normalize_radian()

constexpr radian cqsp::common::components::types::normalize_radian ( const radian radian)
inlineconstexpr

Normalizes a radian to [0, PI*2)

Parameters
[in]Radianto normalizes

◆ normalize_radian_coord()

constexpr double cqsp::common::components::types::normalize_radian_coord ( const radian radian)
inlineconstexpr

◆ operator""_au()

constexpr double cqsp::common::components::types::operator""_au ( const long double  au)
inlineconstexpr

◆ operator""_deg()

constexpr double cqsp::common::components::types::operator""_deg ( const long double  deg)
inlineconstexpr

◆ OrbitTimeToVec3()

glm::dvec3 cqsp::common::components::types::OrbitTimeToVec3 ( const Orbit orb,
const second time 
)

◆ OrbitToVec3()

glm::dvec3 cqsp::common::components::types::OrbitToVec3 ( const double &  a,
const double &  e,
const radian i,
const radian LAN,
const radian w,
const radian v 
)

Converts an orbit to a vec3.

Parameters
aSemi major axis (unit doesn't matter)
eEccentricity (Dimensionless)
iInclinations (radians)
LANLongitude of ascending node (radians)
wArgument of periapsis (radians)
vTrue anomaly (radians)
Returns
The vec3, in whatever unit a was.

◆ OrbitVelocity()

double cqsp::common::components::types::OrbitVelocity ( const double  v,
const double  e,
const double  a,
const double  GM 
)

◆ OrbitVelocityAtR()

double cqsp::common::components::types::OrbitVelocityAtR ( const double  GM,
const double  a,
const double  r 
)

◆ OrbitVelocityToVec3() [1/2]

glm::dvec3 cqsp::common::components::types::OrbitVelocityToVec3 ( const Orbit orb)

◆ OrbitVelocityToVec3() [2/2]

glm::dvec3 cqsp::common::components::types::OrbitVelocityToVec3 ( const Orbit orb,
double  v 
)

◆ SolveKeplerElliptic()

double cqsp::common::components::types::SolveKeplerElliptic ( const double &  mean_anomaly,
const double &  ecc,
const int  steps = 200 
)

Computes eccentric anomaly for a elliptic or circular orbit (e < 1) in radians given mean anomaly and eccentricity

Parameters
mean_anomaly
ecc
stepsNumber of steps for the Newton-Raphson. More steps means more precision but less speed
Returns
Eccentric anomaly (E)goog

◆ SolveKeplerHyperbolic()

double cqsp::common::components::types::SolveKeplerHyperbolic ( const double &  mean_anomaly,
const double &  ecc,
const int  steps = 200 
)

Computes eccentric anomaly for a hyperbolic or parabolic orbit (e > 1) in radians given mean anomaly and eccentricity

Parameters
mean_anomaly
ecc
stepsNumber of steps for the Newton-Raphson. More steps means more precision but less speed
Returns

◆ toAU()

constexpr astronomical_unit cqsp::common::components::types::toAU ( kilometer  km)
inlineconstexpr

◆ toDegree()

constexpr degree cqsp::common::components::types::toDegree ( radian  theta)
inlineconstexpr

◆ toKm()

constexpr kilometer cqsp::common::components::types::toKm ( astronomical_unit  au)
inlineconstexpr

◆ toLightYear()

constexpr light_year cqsp::common::components::types::toLightYear ( astronomical_unit  au)
inlineconstexpr

◆ toRadian()

constexpr radian cqsp::common::components::types::toRadian ( degree  theta)
inlineconstexpr

◆ ToSurfaceCoordinate()

SurfaceCoordinate cqsp::common::components::types::ToSurfaceCoordinate ( const glm::vec3 &  vec)

◆ toVec3() [1/4]

glm::dvec3 cqsp::common::components::types::toVec3 ( const Orbit orb)
inline

◆ toVec3() [2/4]

glm::dvec3 cqsp::common::components::types::toVec3 ( const Orbit orb,
radian  theta 
)
inline

Converts orbit to theta

Parameters
orb
thetaTrue anomaly (radians)
Returns

◆ toVec3() [3/4]

glm::vec3 cqsp::common::components::types::toVec3 ( const PolarCoordinate coordinate)
inline

2D polar coordinate to opengl 3d coordinate

Parameters
coordinate
Returns

◆ toVec3() [4/4]

glm::vec3 cqsp::common::components::types::toVec3 ( const SurfaceCoordinate coord,
const float &  radius 
)

Converts surface coordinate to vector3 in space so that we can get the surface coordinate to render in space

◆ toVec3AU() [1/2]

Vec3AU cqsp::common::components::types::toVec3AU ( const Orbit orb)
inline

Converts orbit to AU coorrdinates.

Parameters
orb[in] orbit of the object to convert
Returns
Vector 3 in orbit, in AU

◆ toVec3AU() [2/2]

Vec3AU cqsp::common::components::types::toVec3AU ( const Orbit orb,
radian  theta 
)
inline

Convert orbit to AU coordinates

Parameters
orbOrbit
thetaTheta to compute
Returns
Vector 3 in orbit, in AU

◆ TrueAnomalyElliptic() [1/2]

radian cqsp::common::components::types::TrueAnomalyElliptic ( const Orbit orbit,
const second time 
)
Parameters
orbit[in] Orbit to compute
time[in] Current time (seconds)
E_put[out] Eccentric anomaly
Returns
True anomaly in radians

◆ TrueAnomalyElliptic() [2/2]

radian cqsp::common::components::types::TrueAnomalyElliptic ( const Orbit orbit,
const second time,
double &  E_out 
)

◆ TrueAnomalyFromVector()

double cqsp::common::components::types::TrueAnomalyFromVector ( const Orbit orbit,
const glm::dvec3 &  vec 
)

◆ TrueAnomalyHyperbolic()

radian cqsp::common::components::types::TrueAnomalyHyperbolic ( const Orbit orbit,
const second time 
)

◆ UpdateOrbit()

void cqsp::common::components::types::UpdateOrbit ( Orbit orb,
const second time 
)

Updates the orbit's true anomaly.

You need to call it before calculating anything to do with the orbit

Parameters
orb
time

◆ UpdatePos()

void cqsp::common::components::types::UpdatePos ( Kinematics kin,
const Orbit orb 
)
inline

Updates the position of an orbit, in AU.

Parameters
kin[out] the kinematics of the orbit
orb[in] the orbit of the orbit

◆ Vec3ToOrbit()

Orbit cqsp::common::components::types::Vec3ToOrbit ( const glm::dvec3 &  position,
const glm::dvec3 &  velocity,
const double &  GM,
const double &  time 
)

Converts position and velocity to orbit. Note: you will have to set the reference body after the orbit is returned

Parameters
positionPosition of the body
velocityVelocity of the body
GMG*M of the orbiting body

Variable Documentation

◆ G

constexpr double cqsp::common::components::types::G = 6.6743015e-11
constexpr

◆ G_km

constexpr double cqsp::common::components::types::G_km = 6.6743015e-20
constexpr

◆ HALFPI

constexpr double cqsp::common::components::types::HALFPI = PI / 2
constexpr

◆ KmInAu

constexpr double cqsp::common::components::types::KmInAu = 149597870.700
constexpr

◆ PI

constexpr double cqsp::common::components::types::PI = 3.14159265358979323846
constexpr

◆ SunMu

constexpr double cqsp::common::components::types::SunMu = 1.32712400188e11
constexpr

◆ TWOPI

constexpr double cqsp::common::components::types::TWOPI = PI * 2
constexpr