Orbit#

public class Orbit#

Describes an orbit. For example, the orbit of a vessel, obtained by calling Vessel.getOrbit(), or a celestial body, obtained by calling CelestialBody.getOrbit().

static Orbit createFromPositionAndVelocity(Connection connection, CelestialBody body, org.javatuples.Triplet<Double, Double, Double> position, org.javatuples.Triplet<Double, Double, Double> velocity, double ut, ReferenceFrame referenceFrame)#

Create the orbit that passes through a given position at a given velocity. The orbit coasts freely under the gravity of the body being orbited, so it describes where an object left to fall from that position and velocity would be at any later time.

Parameters:
  • body (CelestialBody) – The celestial body being orbited.

  • position (org.javatuples.Triplet) – The position, as a position vector.

  • velocity (org.javatuples.Triplet) – The velocity, as a vector pointing in the direction of travel, whose magnitude is the speed in meters per second.

  • ut (double) – The universal time, in seconds, at which the object is at position traveling at velocity.

  • referenceFrame (ReferenceFrame) – The reference frame that position and velocity are in. Defaults to CelestialBody.getNonRotatingReferenceFrame() of body.

Note

The orbit is a single conic around body. It never changes sphere of influence, so Orbit.getNextOrbit() is null, and no atmosphere slows it. A vessel held on rails follows its own orbit exactly, while one inside the physics bubble is simulated and drifts from it a little.

Orbit.getRadius(), Orbit.getSpeed(), Orbit.position(ReferenceFrame), Orbit.velocity(ReferenceFrame) and the like describe the orbit at ut and stay there. Use Orbit.radiusAt(double), Orbit.speedAt(double), Orbit.positionAt(double, ReferenceFrame), Orbit.velocityAt(double, ReferenceFrame) and Orbit.trueAnomalyAtUT(double) for another time, and Orbit.getReferenceFrame() and Orbit.getOrbitalReferenceFrame() to follow the orbit as time passes.

The orbit is held until Orbit.remove() is called on it or the client that created it disconnects. Remove each one created by a script that creates them repeatedly, for example once per update.

static Orbit createFromOrbitalElements(Connection connection, CelestialBody body, double semiMajorAxis, double eccentricity, double inclination, double longitudeOfAscendingNode, double argumentOfPeriapsis, double meanAnomalyAtEpoch, double epoch)#

Create the orbit with the given orbital elements around a given body. The orbit coasts freely under the gravity of that body, so it describes where an object on it would be at any time.

Parameters:
  • body (CelestialBody) – The celestial body being orbited.

  • semiMajorAxis (double) – The semi-major axis of the orbit, in meters. Positive for an ellipse and negative for a hyperbola.

  • eccentricity (double) – The eccentricity of the orbit. Below one for an ellipse and above one for a hyperbola.

  • inclination (double) – The inclination of the orbit, in radians.

  • longitudeOfAscendingNode (double) – The longitude of the ascending node, in radians.

  • argumentOfPeriapsis (double) – The argument of periapsis, in radians.

  • meanAnomalyAtEpoch (double) – The mean anomaly at epoch, in radians.

  • epoch (double) – The universal time, in seconds, that meanAnomalyAtEpoch is measured at.

Note

The orbit is a single conic around body. It never changes sphere of influence, so Orbit.getNextOrbit() is null, and no atmosphere slows it.

The angles are measured against the reference plane and direction that Orbit.getInclination(), Orbit.getLongitudeOfAscendingNode() and Orbit.getArgumentOfPeriapsis() report them against. Orbit.referencePlaneNormal(ReferenceFrame) and Orbit.referencePlaneDirection(ReferenceFrame) give these as vectors in a reference frame.

Orbit.getRadius(), Orbit.getSpeed(), Orbit.position(ReferenceFrame), Orbit.velocity(ReferenceFrame) and the like describe the orbit at epoch and stay there. Use Orbit.radiusAt(double), Orbit.speedAt(double), Orbit.positionAt(double, ReferenceFrame), Orbit.velocityAt(double, ReferenceFrame) and Orbit.trueAnomalyAtUT(double) for another time, and Orbit.getReferenceFrame() and Orbit.getOrbitalReferenceFrame() to follow the orbit as time passes.

The orbit is held until Orbit.remove() is called on it or the client that created it disconnects. Remove each one created by a script that creates them repeatedly, for example once per update.

void remove()#

Remove the orbit, releasing the memory the server holds for it.

Note

Only an orbit created by Orbit.createFromPositionAndVelocity(CelestialBody, org.javatuples.Triplet<Double,Double,Double>, org.javatuples.Triplet<Double,Double,Double>, double, ReferenceFrame) or Orbit.createFromOrbitalElements(CelestialBody, double, double, double, double, double, double, double) can be removed. Every other orbit belongs to something in the game, and the server holds one of each.

Any further use of this object throws an exception, as does use of a reference frame defined against it. An orbit belongs to the client that created it, and is removed when that client disconnects.

CelestialBody getBody()#

The celestial body (e.g. planet or moon) around which the object is orbiting.

ReferenceFrame getReferenceFrame()#

The reference frame that moves along the orbit, and is orientated in a fixed direction.

Note

For the orbit of a vessel, the origin is the point the vessel’s orbit has reached rather than the vessel’s own center of mass. The two are a few meters apart, as a vessel inside the physics bubble is simulated rather than being held on its orbit.

ReferenceFrame getOrbitalReferenceFrame()#

The reference frame that moves along the orbit, and is orientated with its prograde/normal/radial directions.

  • The origin is at the point the orbit has reached at the current time.

  • The axes rotate with the orbital prograde/normal/radial directions.

  • The x-axis points in the orbital anti-radial direction.

  • The y-axis points in the orbital prograde direction.

  • The z-axis points in the orbital normal direction.

Note

For the orbit of a vessel, the origin is the point the vessel’s orbit has reached rather than the vessel’s own center of mass, which is what Vessel.getOrbitalReferenceFrame() is centered on.

double getApoapsis()#

Gets the apoapsis of the orbit, in meters, from the center of mass of the body being orbited.

Note

For the apoapsis altitude reported on the in-game map view, use Orbit.getApoapsisAltitude().

double getPeriapsis()#

The periapsis of the orbit, in meters, from the center of mass of the body being orbited.

Note

For the periapsis altitude reported on the in-game map view, use Orbit.getPeriapsisAltitude().

double getApoapsisAltitude()#

The apoapsis of the orbit, in meters, above the sea level of the body being orbited.

Note

This is equal to Orbit.getApoapsis() minus the equatorial radius of the body.

double getPeriapsisAltitude()#

The periapsis of the orbit, in meters, above the sea level of the body being orbited.

Note

This is equal to Orbit.getPeriapsis() minus the equatorial radius of the body.

double getSemiMajorAxis()#

The semi-major axis of the orbit, in meters.

double getSemiMinorAxis()#

The semi-minor axis of the orbit, in meters.

double getSemiLatusRectum()#

The semi-latus rectum of the orbit, in meters.

double getRadius()#

The current radius of the orbit, in meters. This is the distance between the center of mass of the object in orbit, and the center of mass of the body around which it is orbiting.

Note

This value will change over time if the orbit is elliptical.

double getAltitude()#

The current altitude of the object, in meters above the sea level of the body being orbited.

Note

This is equal to Orbit.getRadius() minus the equatorial radius of the body.

double radiusAt(double ut)#

The orbital radius at the given time, in meters.

Parameters:
  • ut (double) – The universal time to measure the radius at.

double radiusAtTrueAnomaly(double trueAnomaly)#

The orbital radius at the point in the orbit given by the true anomaly.

Parameters:
  • trueAnomaly (double) – The true anomaly.

org.javatuples.Triplet<Double, Double, Double> position(ReferenceFrame referenceFrame)#

The position the orbit has reached at the current time, in the given reference frame.

Parameters:
Returns:

The position as a vector.

org.javatuples.Triplet<Double, Double, Double> positionAt(double ut, ReferenceFrame referenceFrame)#

The position at a given time, in the specified reference frame.

Parameters:
Returns:

The position as a vector.

org.javatuples.Triplet<Double, Double, Double> positionAtTrueAnomaly(double trueAnomaly, ReferenceFrame referenceFrame)#

The position at the point in the orbit given by the true anomaly, in the specified reference frame.

Parameters:
Returns:

The position as a vector.

org.javatuples.Triplet<Double, Double, Double> velocity(ReferenceFrame referenceFrame)#

The velocity the orbit has reached at the current time, in the given reference frame.

Parameters:
Returns:

The velocity as a vector. The vector points in the direction of travel, and its magnitude is the speed in meters per second.

org.javatuples.Triplet<Double, Double, Double> velocityAt(double ut, ReferenceFrame referenceFrame)#

The velocity at a given time, in the specified reference frame.

Parameters:
Returns:

The velocity as a vector. The vector points in the direction of travel, and its magnitude is the speed in meters per second.

org.javatuples.Triplet<Double, Double, Double> velocityAtTrueAnomaly(double trueAnomaly, ReferenceFrame referenceFrame)#

The velocity at the point in the orbit given by the true anomaly, in the specified reference frame.

Parameters:
Returns:

The velocity as a vector. The vector points in the direction of travel, and its magnitude is the speed in meters per second.

double getSpeed()#

The current orbital speed of the object in meters per second.

Note

This value will change over time if the orbit is elliptical.

double speedAt(double ut)#

The orbital speed at the given time, in meters per second.

Parameters:
  • ut (double) – The universal time to measure the speed at.

double speedAtRadius(double radius)#

The orbital speed at the given orbital radius, in meters per second.

Parameters:
  • radius (double) – The orbital radius in meters.

Note

This is the vis-viva speed. A radius the orbit never reaches is accepted. On an ellipse the speed is NaN above twice the semi-major axis.

double speedAtTrueAnomaly(double trueAnomaly)#

The orbital speed at the point in the orbit given by the true anomaly, in meters per second.

Parameters:
  • trueAnomaly (double) – The true anomaly.

double getSpecificEnergy()#

The specific orbital energy, in Joules per kilogram (equivalently, meters squared per second squared).

Note

This is the sum of the orbit’s specific kinetic and potential energy, and is negative for a bound (elliptical) orbit.

double getSpecificAngularMomentum()#

The specific relative angular momentum, in meters squared per second.

double getPeriod()#

The orbital period, in seconds.

double getMeanMotion()#

The mean motion, in radians per second.

double getTimeToApoapsis()#

The time until the object reaches apoapsis, in seconds.

double getTimeToPeriapsis()#

The time until the object reaches periapsis, in seconds.

double getEccentricity()#

The eccentricity of the orbit.

double getInclination()#

The inclination of the orbit, in radians.

double getLongitudeOfAscendingNode()#

The longitude of the ascending node, in radians.

Note

For a near-equatorial orbit, the ascending node is ill-defined and this value may vary erratically over time.

double getArgumentOfPeriapsis()#

The argument of periapsis, in radians.

Note

For a near-circular orbit, the periapsis is ill-defined and this value may vary erratically over time.

double getMeanAnomalyAtEpoch()#

The mean anomaly at epoch.

double getEpoch()#

The universal time, in seconds, at which the mean anomaly at epoch is measured.

double getMeanAnomaly()#

The mean anomaly.

double meanAnomalyAtUT(double ut)#

The mean anomaly at the given time.

Parameters:
  • ut (double) – The universal time in seconds.

double getEccentricAnomaly()#

The eccentric anomaly.

double eccentricAnomalyAtUT(double ut)#

The eccentric anomaly at the given universal time.

Parameters:
  • ut (double) – The universal time, in seconds.

double getTrueAnomaly()#

The true anomaly.

double trueAnomalyAtUT(double ut)#

The true anomaly at the given time.

Parameters:
  • ut (double) – The universal time in seconds.

double trueAnomalyAtRadius(double radius)#

The true anomaly at the given orbital radius.

Parameters:
  • radius (double) – The orbital radius in meters.

double uTAtTrueAnomaly(double trueAnomaly)#

The universal time, in seconds, corresponding to the given true anomaly.

Parameters:
  • trueAnomaly (double) – True anomaly.

double trueAnomalyAtAN(Orbit target)#

The true anomaly of the ascending node with the given target orbit.

Parameters:
  • target (Orbit) – Target orbit.

double trueAnomalyAtDN(Orbit target)#

The true anomaly of the descending node with the given target orbit.

Parameters:
  • target (Orbit) – Target orbit.

double getOrbitalSpeed()#

Warning

Deprecated. Use Orbit.getSpeed() instead.

The current orbital speed in meters per second.

double orbitalSpeedAt(double ut)#

Warning

Deprecated. Use Orbit.speedAt(double) instead.

The orbital speed at the given time, in meters per second.

Parameters:
  • ut (double) – The universal time to measure the speed at.

double getOrbitalEnergy()#

Warning

Deprecated. Use Orbit.getSpecificEnergy() instead.

The specific orbital energy of the orbit, in Joules per kilogram.

static org.javatuples.Triplet<Double, Double, Double> referencePlaneNormal(Connection connection, ReferenceFrame referenceFrame)#

The direction that is normal to the orbits reference plane, in the given reference frame. The reference plane is the plane from which the orbits inclination is measured.

Parameters:
  • referenceFrame (ReferenceFrame) – The reference frame that the returned direction is in.

Returns:

The direction as a unit vector.

static org.javatuples.Triplet<Double, Double, Double> referencePlaneDirection(Connection connection, ReferenceFrame referenceFrame)#

The direction from which the orbits longitude of ascending node is measured, in the given reference frame.

Parameters:
  • referenceFrame (ReferenceFrame) – The reference frame that the returned direction is in.

Returns:

The direction as a unit vector.

double relativeInclination(Orbit target)#

Relative inclination of this orbit and the target orbit, in radians.

Parameters:
  • target (Orbit) – Target orbit.

double getTimeToSOIChange()#

The time until the object changes sphere of influence, in seconds. Returns NaN if the object is not going to change sphere of influence.

Orbit getNextOrbit()#

If the object is going to change sphere of influence in the future, returns the new orbit after the change. Otherwise returns null.

ClosestApproach nextClosestApproach(Orbit target)#

The next closest approach to a target orbit.

Parameters:
  • target (Orbit) – Target orbit.

java.util.List<ClosestApproach> closestApproaches(Orbit target, int orbits)#

A list of the closest approaches to a target orbit, one for each of the next orbits orbital periods.

Parameters:
  • target (Orbit) – Target orbit.

  • orbits (int) – The number of future orbits to search.