Orbital Ellipse Projection









Details

This program generates an orthographic projection of an orbital ellipse from Keplerian orbital elements.

Orbital Elements

Unique orbits may be defined using the following orbital elements variables, known as Keplerian elements.

a - Semi-Major Axis
The Semi-Major Axis is half of the Major Axis, which is the distance greatest distance between two points on the ellipse.
e - Eccentricity
The Eccentricity can be used to define the ratio between the Major Axis and the Minor Axis.
i - Inclination
The inclination of the orbital plane to the reference plane as measured at asscending node.
Ω - Longitude of the Accending Node
The angle of rotation between the accending node and the reference direction along the reference plane.
ω - Argument of Periapsis
The angle of the ellipse measured from the ascending node to the periapsis along the orbial plane.
ν - True Anomaly
The true anomaly defines the position of the orbiting body as an angle between it's current position and the periapsis as seen from the focus.

More on Keplerian elements can be found at Wikipedia - Orbital Elements

Projection Mathmatics

To project the orbital ellipse we will generate a number of points on an appropriately shaped ellipse and applying trasformations to those points to account for all orbital elements.

Getting a point

For a given angle in degrees, x and y can be calculated with the following equations:

x = b · sin(t)
y = a · cos(t) - c

where 
t = angle · (π / 180)
b = a · √(1 - e2)
c = a · e

Notes:

Example:

given a = 1.2, e = 0.2, angle = 45°

t = 45 · (π / 180)
  = π / 4

b = 1.2 · √(1 - 0.22)
= 1.2 · √(0.96)
  = ~1.1757

c = 1.2 · 0.2
  = 0.24

x = ~1.1757 · sin(π / 4)
= ~1.1757 · ~0.7071
  = ~0.8313

y = 1.2 · cos(π / 4) - 0.24
= 1.2 · ~0.7071
  = ~0.8485

The point is (~0.8313, ~0.8485)

Transformations

The order in which the transofrmations are applied is important, because the screen the ellipse is projected onto is an aproximation of the reference plane of the orbit. Some of the orbital elements work relative to the reference plane and other elements work relative to the orbital plane.

The correct order of transformations requires that any adjustments to the orbital plane happen before it is positioned relative to the reference plane.

  1. Argument of Periapsis

    The following is the simplified form of a rotation matrix multiplication:

    x = x · cos(t) + y · sin(t)
    y = x · -sin(t) + y · cos(t)
    
    where
    t = ω · (π / 180)
    

    Notes:

    • The sine in the y equation is negated because orbital elements are typically applied counter clockwise when viewed from above
  2. Inclination

    To compute an appropriate skew we multiply.

    x = x · cos(i · (π / 180))
    

    Notes:

    • Cosine is used because it returns 1 when t is 0
    • x is used rather than y because the inclination is measured relative to the an axis which, when ω = 0, is co-linear to the y axis
  3. Longitude of the Asscending Node

    To apply this rotation we replace ω with Ω in the rotation equations:

    x = x · cos(t) + y · sin(t)
    y = x · -sin(t) + y · cos(t)
    
    where 
    t = Ω · (π / 180)
    

Body Position

The equation we use to get points on the ellipse returns the point at a given angle from the center of the ellipse. This angle is analogous to eccentric anomaly. The true anomaly reperents a given angle from the focus, so to correctly place the orbiting body, it must be converted.

More on True anomaly's relation to Eccentric can be found at Wikipedia - True Anomaly

To get the eccentric anomaly (E) in radians, we apply the following equation:

E = t + 2arctan(βsin(t) / (1 - βcos(t))) + π

where
t = (ν + 180) · (π / 180);
β = e / (1 + √(1 - e2))

Notes:

Drawing to a Canvas

To use the projection mathmatics we have established to plot an ellipse on an HTML canvas, we can loop through angles from 0° to 360° and get transformed points for those angles. If we multiply the generated points by a scaling factor, we can treat them as points on an HTML canvas element draw a path between them.

The fidelity of such a polygon obviously depends on the step size. One point per degree appears smooth at the sizes this application utilizes.

Specific points on the ellipse can be calculated and connected with lines for improving readability of the projection, such as the Major Axis, Minor Axis and the axis which the orbital plane is inclined around (above referred to as the Inclination Axis).

By passing other coordinates through the same transformation functions as the ellipse points, points outside of the ellipse may be plotted. An example of this would the four conrners of the orbital plane.