This program generates an orthographic projection of an orbital ellipse from Keplerian orbital elements.
Unique orbits may be defined using the following orbital elements variables, known as Keplerian elements.
More on Keplerian elements can be found at Wikipedia - Orbital Elements
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.
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)
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.
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:
Inclination
To compute an appropriate skew we multiply.
x = x · cos(i · (π / 180))
Notes:
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)
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:
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.