Skip to content

Instantly share code, notes, and snippets.

@GlaireDaggers
Created May 31, 2017 19:05
Show Gist options
  • Save GlaireDaggers/2d938b5431536300a6013b01e1fc9f6b to your computer and use it in GitHub Desktop.
Save GlaireDaggers/2d938b5431536300a6013b01e1fc9f6b to your computer and use it in GitHub Desktop.
Celestial Body Class
/// <summary>
/// A celestial body that exists in a solar system
/// See http://www.stjarnhimlen.se/comp/ppcomp.html
/// </summary>
public abstract class CelestialBody
{
/// <summary>
/// The day number
/// </summary>
public static float d;
/// <summary>
/// longitude of the ascending node
/// If you imagine the earth's orbit around the sun forming a plane, the ascending node is where a planet's orbit intersects that plane going "up".
/// The longitude of that node, again imagining that plane of earth's orbit, is pretty much that node's direction as a Y-axis rotation.
/// If this is a geocentric (earth-centric) celestial body, the plane we're talking about is actually Earth's equatorial plane instead (a plane bisecting the north and south hemispheres)
/// </summary>
public abstract float N { get; }
/// <summary>
/// inclination to the ecliptic (plane of the Earth's orbit)
/// Basically, if you imagine an axis formed by the N angle, how much is the orbit rotated on that axis? 0 means orbit lies directly on the ecliptic.
/// </summary>
public abstract float i { get; }
/// <summary>
/// argument of perihelion
/// Pretty much just a rotation around the ecliptic plane's up vector for the whole orbit
/// </summary>
public abstract float w { get; }
/// <summary>
/// semi-major axis, or mean distance from Sun (given in earth radii for the moon, but AU for the sun and other planets)
/// Basically this is half the longest diameter of an ellipse
/// </summary>
public abstract float a { get; }
/// <summary>
/// eccentricity (0=circle, 0-1=ellipse, 1=parabola)
/// </summary>
public abstract float e { get; }
/// <summary>
/// current mean anomaly (0 at perihelion; increases uniformly with time)
/// This is the angular distance from the start of orbit ("pericenter") that an object with a purely circular orbit with the same orbital period would have moved in the same time.
/// </summary>
public abstract float M { get; }
/// <summary>
/// obliquity of the ecliptic (the "tilt" of the Earth's axis of rotation)
/// </summary>
public float ecl
{
get { return 23.4393f - 3.563E-7f * d; }
}
/// <summary>
/// whether this celestial body's calculations are relative to the sun
/// </summary>
public abstract bool IsHeliocentric { get; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment