KeplerTranslation

Inherits Translation

Computes an object’s position from classical Keplerian orbital elements. It is intended for bodies whose motion can be described analytically as an ellipse around a central body, using a compact orbital parameter set rather than sampled trajectory data. The class evaluates orbital motion from the standard elements that define orbit shape, orientation, and phase. From these values, it reconstructs the orbital plane, advances the object along the orbit as time progresses, and returns the corresponding 3D position in space. This makes it a foundational translation type for planets, moons, spacecraft, and other orbiting objects when an idealized two-body style orbit is sufficient.

A key responsibility of KeplerTranslation is converting time into orbital phase. It uses the configured epoch and orbital period to determine the current mean anomaly, solves for the eccentric anomaly, and then computes the position within the orbital plane before rotating that position into the final world-space orientation of the orbit.

The implementation is designed for elliptical or circular orbits and explicitly excludes hyperbolic Keplerian trajectories. It also supports epoch input in either absolute time form (ISO 8601, for example 2025-04-01 18:00:00) or J2000 seconds, making it flexible for authored assets and external data sources.

Because the orbital plane and orbital position are handled separately, the class can efficiently respond to changes in either the orbit’s geometry or the object’s phase along that orbit. This makes it suitable both for static asset definitions and for interactive or programmatic updates to orbital parameters.

Members

Name

Documentation

Type

Description

Optional

ArgumentOfPeriapsis

This value determines the argument of periapsis in degrees, that is the position on the orbit that is closest to the orbiting body.

Double

In range: ( -360, 360)

No

AscendingNode

This value determines the right ascension of the ascending node in degrees, that is the location of position along the orbit where the inclined plane and the horizonal reference plane intersect.

Double

In range: ( -360, 360)

No

Eccentricity

This value determines the eccentricity, that is the deviation from a perfect sphere, for this orbit. Currently, hyperbolic orbits using Keplerian elements are not supported.

Double

In range: ( 0, 1)

No

Epoch

This value determines the epoch for which the initial location is defined in. This is specified either in the form of a date (YYYY MM DD HH:mm:ss) or in the number of seconds past the J2000 epoch.

String, or Double

Value of type ‘String’, or Value of type ‘Double’

No

Inclination

This value determines the degrees of inclination, or the angle of the orbital plane, relative to the reference plane, on which the object orbits around the central body.

Double

In range: ( -360, 360)

No

MeanAnomaly

This value determines the mean anomaly at the epoch in degrees, which determines the initial location of the object along the orbit at epoch.

Double

In range: ( -360, 360)

No

Period

Specifies the orbital period (in seconds).

Double

Greater than: 0

No

SemiMajorAxis

This value determines the semi-major axis, that is the distance of the object from the central body in kilometers (semi-major axis = average of periapsis and apoapsis).

Double

Value of type ‘Double’

No

Type

The type of translation that is described in this element. The available types of translations depend on the configuration of the application and can be written to disk on application startup into the FactoryDocumentation.

String

Must name a valid Translation type

No

TimeFrame

The time frame in which this Translation is applied. If the in-game time is outside this range, no translation will be applied.

Table

TimeFrame

Yes

Inherited members from Translation

Name

Documentation

Type

Description

Optional

Type

The type of translation that is described in this element. The available types of translations depend on the configuration of the application and can be written to disk on application startup into the FactoryDocumentation.

String

Must name a valid Translation type

No

TimeFrame

The time frame in which this Translation is applied. If the in-game time is outside this range, no translation will be applied.

Table

TimeFrame

Yes

Asset Examples

 1-- Rotation Following One Moving Object
 2-- This asset creates a rotation that places coordinate axes orbiting close to a sphere
 3-- with the z axis always pointing towards the sphere as it orbits around the sphere. The
 4-- coordinate axes are translated away from the sphere to make that orientation more
 5-- obvious.
 6--
 7-- Making the `YAxis` { 0.0, 1.0, 0.0 } and actually using the orthogonal projection of
 8-- that direction means that the y axis of the new coordinate system will point in the
 9-- hemisphere in which the old y-axis was pointing, albeit being orthogonal to the other
10-- specified axis. That axis is pointing towards the scene graph node holding the sphere.
11local Sphere = {
12  Identifier = "FixedRotation_Example_Moving_Sphere",
13  Transform = {
14    Translation = {
15      Type = "KeplerTranslation",
16      Eccentricity = 0.5,
17      SemiMajorAxis = 0.0025,
18      Inclination = 0.0,
19      AscendingNode = 0.0,
20      ArgumentOfPeriapsis = 0.0,
21      MeanAnomaly = 0.0,
22      Epoch = "2000 JAN 01 12:00:00",
23      Period = 10.0
24    }
25  },
26  Renderable = {
27    Type = "RenderableSphericalGrid"
28  },
29  GUI = {
30    Name = "FixedRotation - Moving (Sphere)",
31    Path = "/Examples"
32  }
33}
34
35local Node = {
36  Identifier = "FixedRotation_Example_Moving",
37  Transform = {
38    Rotation = {
39      Type = "FixedRotation",
40      Attached = "FixedRotation_Example_Moving",
41      YAxis = { 0.0, 1.0, 0.0 },
42      YAxisOrthogonal = true,
43      ZAxis = Sphere.Identifier
44    }
45  },
46  Renderable = {
47    Type = "RenderableCartesianAxes"
48  },
49  GUI = {
50    Name = "FixedRotation - Moving",
51    Path = "/Examples"
52  }
53}
54
55
56asset.onInitialize(function()
57  openspace.addSceneGraphNode(Sphere)
58  openspace.addSceneGraphNode(Node)
59end)
60
61asset.onDeinitialize(function()
62  openspace.removeSceneGraphNode(Node)
63  openspace.removeSceneGraphNode(Sphere)
64end)