KSP API
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Properties | List of all members
Orbit Class Reference

More...

Public Types

enum  EncounterSolutionLevel {
  EncounterSolutionLevel.NONE = 0, EncounterSolutionLevel.ESCAPE = 1, EncounterSolutionLevel.ORBIT_INTERSECT = 2, EncounterSolutionLevel.SOI_INTERSECT_2 = 3,
  EncounterSolutionLevel.SOI_INTERSECT_1 = 4
}
 
enum  ObjectType {
  ObjectType.VESSEL = 0, ObjectType.SPACE_DEBRIS = 1, ObjectType.CELESTIAL_BODIES = 2, ObjectType.UNKNOWN_MISC = 3,
  ObjectType.KERBAL = 4
}
 
enum  PatchTransitionType {
  PatchTransitionType.INITIAL = 0, PatchTransitionType.FINAL = 1, PatchTransitionType.ENCOUNTER = 2, PatchTransitionType.ESCAPE = 3,
  PatchTransitionType.MANEUVER = 4
}
 

Public Member Functions

 Orbit ()
 
 Orbit (double inc, double e, double sma, double lan, double w, double mEp, double t, CelestialBody body)
 
void DrawOrbit ()
 
Vector3d GetANVector ()
 
double GetDTforTrueAnomaly (double tA, double wrapAfterSeconds)
 
double GetEccentricAnomaly (double tA)
 
Vector3d GetEccVector ()
 
Vector3d GetFrameVel ()
 The velocity of the orbiting object, {AliceWorld, Sun}. More...
 
Vector3d GetFrameVelAtUT (double UT)
 
double GetMeanAnomaly (double E, double tA)
 
double getObTAtMeanAnomaly (double M)
 
double getObtAtUT (double UT)
 
double getOrbitalSpeedAt (double time)
 
double getOrbitalSpeedAtDistance (double d)
 
double getOrbitalSpeedAtPos (Vector3d pos)
 
double getOrbitalSpeedAtRelativePos (Vector3d relPos)
 
Vector3d getOrbitalVelocityAtObT (double ObT)
 
Vector3d getOrbitalVelocityAtUT (double UT)
 
Vector3d GetOrbitNormal ()
 A unit vector normal to the plane of the orbit. NOTE: All Vector3d's returned by Orbit class functions have their y and z axes flipped. You have to flip these back to get the vectors in world coordinates. More...
 
Trajectory GetPatchTrajectory (int sampleCount)
 
Vector3d getPositionAtT (double T)
 
Vector3d getPositionAtUT (double UT)
 
Vector3d getPositionFromEccAnomaly (double E)
 
Vector3d getPositionFromMeanAnomaly (double M)
 
Vector3d getPositionFromTrueAnomaly (double tA)
 
Vector3d getRelativePositionAtT (double T)
 Gets the predicted displacement of the orbiting object from the center of the main body at a given time since perigee passage. NOTE: All Vector3d's returned by Orbit class functions have their y and z axes flipped. You have to flip these back to get the vectors in world coordinates. More...
 
Vector3d getRelativePositionAtUT (double UT)
 Gets the predicted displacement of the orbiting object from the center of the main body at a given universal time. NOTE: All Vector3d's returned by Orbit class functions have their y and z axes flipped. You have to flip these back to get the vectors in world coordinates. More...
 
Vector3d getRelativePositionFromEccAnomaly (double E)
 
Vector3d getRelativePositionFromMeanAnomaly (double M)
 
Vector3d getRelativePositionFromTrueAnomaly (double tA)
 
Vector3d GetRelativeVel ()
 The velocity of the orbiting object, {World, Primary}. More...
 
Vector3d GetRotFrameVel (CelestialBody refBody)
 The velocity of a hypothetical object, located where the orbiting object is, and at rest in the ConditionallyRotating[refBody] frame, {AliceWorld, BodyCentre[refBody]}. In other words, velocity of the ConditionallyRotating[refBody] frame in the BodyCentre[refBody] frame at the position of the orbiting object (AliceWorld axes). Note: this only depends on the orbital position, not on the orbital velocity. More...
 
double getTrueAnomaly (double E)
 
double GetTrueAnomalyOfZupVector (Vector3d vector)
 
Vector3d getTruePositionAtUT (double UT)
 
double GetUTforTrueAnomaly (double tA, double wrapAfterSeconds)
 
Vector3d GetVel ()
 The velocity of the orbiting object, {World, ActiveVesselPrimary}. More...
 
Vector3d GetWorldSpaceVel ()
 The velocity of the orbiting object, {World, ActiveVesselPrimaryConditionallyRotating}. More...
 
void Init ()
 
double RadiusAtTrueAnomaly (double tA)
 The distance the orbiting object will be from the center of the main body when it reaches the given true anomaly. More...
 
double solveEccentricAnomaly (double M, double ecc, double maxError, int maxIterations)
 
double TrueAnomalyAtRadius (double R)
 The true anomaly at which the orbiting object will achieve the given distance from the center of the main body. More...
 
double TrueAnomalyAtT (double T)
 
double TrueAnomalyAtUT (double UT)
 
void UpdateFromOrbitAtUT (Orbit orbit, double UT, CelestialBody toBody)
 
void UpdateFromStateVectors (Vector3d pos, Vector3d vel, CelestialBody refBody, double UT)
 Updates this orbit to reflect the orbit that will be taken around the given body by an object with the given position and velocity at the given universal time. More...
 
void UpdateFromUT (double UT)
 

Static Public Member Functions

static void FindClosestPoints (Orbit p, Orbit s, ref double CD, ref double CCD, ref double FFp, ref double FFs, ref double SFp, ref double SFs, double epsilon, int maxIterations, ref int iterationCount)
 
static bool PeApIntersects (Orbit primary, Orbit secondary, double threshold)
 
static double SolveClosestApproach (Orbit p, Orbit s, ref double UT, double dT, double threshold, double MinUT, double MaxUT, double epsilon, int maxIterations, ref int iterationCount)
 
static bool SolveSOI_BSP (Orbit p, Orbit s, ref double UT, double dT, double Rsoi, double MinUT, double MaxUT, double epsilon, int maxIterations, ref int iterationCount)
 

Public Attributes

bool activePatch
 Whether this patch actually represents a real orbit patch in the projected flight path. Often Orbit.nextPatch for the last real will not be null, but will be some sort of bogus Orbit object. You can recognize these because activePatch will be false. More...
 
double altitude
 
Vector3d an
 
double argumentOfPeriapsis
 The angle between the ascending node and the periapsis, in degrees. More...
 
double ClAppr
 
double ClEctr1
 
double ClEctr2
 
CelestialBody closestEncounterBody
 
Orbit.EncounterSolutionLevel closestEncounterLevel
 
Orbit closestEncounterPatch
 
double closestTgtApprUT
 
double CrAppr
 
bool debug_returnFullEllipseTrajectory
 
Vector3 debugAN
 
Vector3 debugEccVec
 
Vector3 debugH
 
Vector3 debugPos
 
Vector3 debugVel
 
double E
 
double eccentricAnomaly
 A quantity used in the math describing Keplerian orbits; Google it. More...
 
double eccentricity
 The eccentricity of the orbit. More...
 
Vector3d eccVec
 A vector that points toward periapsis, with mangitude equal to the eccentricity. NOTE: All Vector3d's returned by Orbit class functions have their y and z axes flipped. You have to flip these back to get the vectors in world coordinates. More...
 
double EndUT
 The universal time at which this patch ends. More...
 
double epoch
 A special UT at which the parameters of the Orbit are defined. See meanAnomalyAtEpoch. More...
 
double FEVp
 
double FEVs
 
double fromE
 
double fromV
 
Vector3d h
 The specific orbital angular momentum More...
 
double inclination
 The inclination of this orbit with respect to the equator of the central body in degrees More...
 
double LAN
 The longitude of the ascending node of the orbit, in degrees. The LAN is the angle between the ascending node and Planetarium.right, as viewed along Planetarium.up. More...
 
double mag
 
double meanAnomaly
 Mean anomaly is the fraction of the orbit that has been completed, measured starting from the periapsis, multiplied by 2π. Look it up. More...
 
double meanAnomalyAtEpoch
 The mean anomaly of the orbit at the special UT given by Orbit.epoch. More...
 
double nearestTT
 
Orbit nextPatch
 
double nextTT
 
Orbit.ObjectType objectType
 
double ObT
 Time since periapsis, in seconds. More...
 
double ObTAtEpoch
 The value of ObT at the universal time given by epoch. More...
 
double orbitalEnergy
 
double orbitalSpeed
 
double orbitPercent
 Equal to More...
 
Orbit.PatchTransitionType patchEndTransition
 How the next patch follows onto this one, or FINAL if there is no patch after this one. More...
 
Orbit.PatchTransitionType patchStartTransition
 
double period
 The period of the orbit, in seconds. More...
 
Vector3d pos
 The position of the orbiting object, {AliceWorld, Primary}. More...
 
Orbit previousPatch
 
double radius
 
CelestialBody referenceBody
 The body orbited. More...
 
double sampleInterval
 
Vector3d secondaryPosAtTransition1
 
Vector3d secondaryPosAtTransition2
 
double semiMajorAxis
 The semi-major axis of the orbit, in meters. Equal to (PeR + ApR)/2 More...
 
double SEVp
 
double SEVs
 
double StartUT
 
double timeToAp
 The time until the object will reach apoapsis, in seconds. More...
 
double timeToPe
 The time unti lthe object will reach periapsis, in seconds. More...
 
double timeToTransition1
 
double timeToTransition2
 
double toE
 
double toV
 
double trueAnomaly
 
double UTappr
 
double UTsoi
 
double V
 
Vector3d vel
 The velocity of the orbiting object, {AliceWorld, Primary}. More...
 

Properties

double ApA [get]
 The apoapsis of the orbit in meters, measured from sea level. More...
 
double ApR [get]
 The apoapsis of the orbit in meters, measured from the center of the main body. More...
 
double PeA [get]
 The periapsis of the orbit in meters, measured from sea level. More...
 
double PeR [get]
 The periapsis of the orbit in meters, measured from the center of the main body. More...
 
double semiLatusRectum [get]
 A property of ellipses, parabolas and hyperbolas; Google it. More...
 
double semiMinorAxis [get]
 A property of ellipses; Google it. More...
 

Detailed Description

An Orbit class represents a Keplerian orbit. Each Vessel and each CelestialBody has an Orbit. CelestialBodies and on-rails Vessels follow their Orbits exactly. Off-rails vessels (the active vessel and any nearby vessels) do not follow their orbits exactly; instead their motion is computed frame-by-frame from the forces acting on them.

A patched consics trajectory consists of a series of Orbits, called patches.

This class uses multiple axes and reference frames to describe positions and velocities.

We call the choices of axes

We call the reference frames used

We use the concise notation {Axes, Frame} for describing the reference frame and axes used.

Member Enumeration Documentation

Enumerator
NONE 
ESCAPE 
ORBIT_INTERSECT 
SOI_INTERSECT_2 
SOI_INTERSECT_1 
Enumerator
VESSEL 
SPACE_DEBRIS 
CELESTIAL_BODIES 
UNKNOWN_MISC 
KERBAL 
Enumerator
INITIAL 
FINAL 
ENCOUNTER 
ESCAPE 
MANEUVER 

Constructor & Destructor Documentation

Orbit.Orbit ( )
Orbit.Orbit ( double  inc,
double  e,
double  sma,
double  lan,
double  w,
double  mEp,
double  t,
CelestialBody  body 
)

Member Function Documentation

void Orbit.DrawOrbit ( )
static void Orbit.FindClosestPoints ( Orbit  p,
Orbit  s,
ref double  CD,
ref double  CCD,
ref double  FFp,
ref double  FFs,
ref double  SFp,
ref double  SFs,
double  epsilon,
int  maxIterations,
ref int  iterationCount 
)
static
Vector3d Orbit.GetANVector ( )
double Orbit.GetDTforTrueAnomaly ( double  tA,
double  wrapAfterSeconds 
)
double Orbit.GetEccentricAnomaly ( double  tA)
Vector3d Orbit.GetEccVector ( )
Vector3d Orbit.GetFrameVel ( )

The velocity of the orbiting object, {AliceWorld, Sun}.

Vector3d Orbit.GetFrameVelAtUT ( double  UT)
double Orbit.GetMeanAnomaly ( double  E,
double  tA 
)
double Orbit.getObTAtMeanAnomaly ( double  M)
double Orbit.getObtAtUT ( double  UT)
double Orbit.getOrbitalSpeedAt ( double  time)
double Orbit.getOrbitalSpeedAtDistance ( double  d)
double Orbit.getOrbitalSpeedAtPos ( Vector3d  pos)
double Orbit.getOrbitalSpeedAtRelativePos ( Vector3d  relPos)
Vector3d Orbit.getOrbitalVelocityAtObT ( double  ObT)
Vector3d Orbit.getOrbitalVelocityAtUT ( double  UT)
Vector3d Orbit.GetOrbitNormal ( )

A unit vector normal to the plane of the orbit. NOTE: All Vector3d's returned by Orbit class functions have their y and z axes flipped. You have to flip these back to get the vectors in world coordinates.

Returns
A unit normal vector.
Trajectory Orbit.GetPatchTrajectory ( int  sampleCount)
Vector3d Orbit.getPositionAtT ( double  T)
Vector3d Orbit.getPositionAtUT ( double  UT)
Vector3d Orbit.getPositionFromEccAnomaly ( double  E)
Vector3d Orbit.getPositionFromMeanAnomaly ( double  M)
Vector3d Orbit.getPositionFromTrueAnomaly ( double  tA)
Vector3d Orbit.getRelativePositionAtT ( double  T)

Gets the predicted displacement of the orbiting object from the center of the main body at a given time since perigee passage. NOTE: All Vector3d's returned by Orbit class functions have their y and z axes flipped. You have to flip these back to get the vectors in world coordinates.

Parameters
TTime since perigee passage (seconds)
Returns
Position relative to the main body (YZ flipped)
Vector3d Orbit.getRelativePositionAtUT ( double  UT)

Gets the predicted displacement of the orbiting object from the center of the main body at a given universal time. NOTE: All Vector3d's returned by Orbit class functions have their y and z axes flipped. You have to flip these back to get the vectors in world coordinates.

Parameters
UTA univeral time.
Returns
Position relative to the main body (YZ flipped)
Vector3d Orbit.getRelativePositionFromEccAnomaly ( double  E)
Vector3d Orbit.getRelativePositionFromMeanAnomaly ( double  M)
Vector3d Orbit.getRelativePositionFromTrueAnomaly ( double  tA)
Vector3d Orbit.GetRelativeVel ( )

The velocity of the orbiting object, {World, Primary}.

Vector3d Orbit.GetRotFrameVel ( CelestialBody  refBody)

The velocity of a hypothetical object, located where the orbiting object is, and at rest in the ConditionallyRotating[refBody] frame, {AliceWorld, BodyCentre[refBody]}. In other words, velocity of the ConditionallyRotating[refBody] frame in the BodyCentre[refBody] frame at the position of the orbiting object (AliceWorld axes). Note: this only depends on the orbital position, not on the orbital velocity.

double Orbit.getTrueAnomaly ( double  E)
double Orbit.GetTrueAnomalyOfZupVector ( Vector3d  vector)
Vector3d Orbit.getTruePositionAtUT ( double  UT)
double Orbit.GetUTforTrueAnomaly ( double  tA,
double  wrapAfterSeconds 
)
Vector3d Orbit.GetVel ( )

The velocity of the orbiting object, {World, ActiveVesselPrimary}.

Vector3d Orbit.GetWorldSpaceVel ( )

The velocity of the orbiting object, {World, ActiveVesselPrimaryConditionallyRotating}.

void Orbit.Init ( )
static bool Orbit.PeApIntersects ( Orbit  primary,
Orbit  secondary,
double  threshold 
)
static
double Orbit.RadiusAtTrueAnomaly ( double  tA)

The distance the orbiting object will be from the center of the main body when it reaches the given true anomaly.

Parameters
tATrue anomaly (in degrees)
Returns
Distance from the main body's center, in meters
static double Orbit.SolveClosestApproach ( Orbit  p,
Orbit  s,
ref double  UT,
double  dT,
double  threshold,
double  MinUT,
double  MaxUT,
double  epsilon,
int  maxIterations,
ref int  iterationCount 
)
static
double Orbit.solveEccentricAnomaly ( double  M,
double  ecc,
double  maxError,
int  maxIterations 
)
static bool Orbit.SolveSOI_BSP ( Orbit  p,
Orbit  s,
ref double  UT,
double  dT,
double  Rsoi,
double  MinUT,
double  MaxUT,
double  epsilon,
int  maxIterations,
ref int  iterationCount 
)
static
double Orbit.TrueAnomalyAtRadius ( double  R)

The true anomaly at which the orbiting object will achieve the given distance from the center of the main body.

Parameters
RDistance from the center of the main body, in meters.
Returns
True anomaly, in radians.
double Orbit.TrueAnomalyAtT ( double  T)
double Orbit.TrueAnomalyAtUT ( double  UT)
void Orbit.UpdateFromOrbitAtUT ( Orbit  orbit,
double  UT,
CelestialBody  toBody 
)
void Orbit.UpdateFromStateVectors ( Vector3d  pos,
Vector3d  vel,
CelestialBody  refBody,
double  UT 
)

Updates this orbit to reflect the orbit that will be taken around the given body by an object with the given position and velocity at the given universal time.

Parameters
posThe initial position of the object RELATIVE TO refBody at UT (YZ flipped)
velThe initial velocity of the object (YZ flipped)
refBodyThe main body
UTThe universal time at which to start the orbit.
void Orbit.UpdateFromUT ( double  UT)

Member Data Documentation

bool Orbit.activePatch

Whether this patch actually represents a real orbit patch in the projected flight path. Often Orbit.nextPatch for the last real will not be null, but will be some sort of bogus Orbit object. You can recognize these because activePatch will be false.

double Orbit.altitude
Vector3d Orbit.an
double Orbit.argumentOfPeriapsis

The angle between the ascending node and the periapsis, in degrees.

double Orbit.ClAppr
double Orbit.ClEctr1
double Orbit.ClEctr2
CelestialBody Orbit.closestEncounterBody
Orbit.EncounterSolutionLevel Orbit.closestEncounterLevel
Orbit Orbit.closestEncounterPatch
double Orbit.closestTgtApprUT
double Orbit.CrAppr
bool Orbit.debug_returnFullEllipseTrajectory
Vector3 Orbit.debugAN
Vector3 Orbit.debugEccVec
Vector3 Orbit.debugH
Vector3 Orbit.debugPos
Vector3 Orbit.debugVel
double Orbit.E
double Orbit.eccentricAnomaly

A quantity used in the math describing Keplerian orbits; Google it.

double Orbit.eccentricity

The eccentricity of the orbit.

Vector3d Orbit.eccVec

A vector that points toward periapsis, with mangitude equal to the eccentricity. NOTE: All Vector3d's returned by Orbit class functions have their y and z axes flipped. You have to flip these back to get the vectors in world coordinates.

double Orbit.EndUT

The universal time at which this patch ends.

double Orbit.epoch

A special UT at which the parameters of the Orbit are defined. See meanAnomalyAtEpoch.

double Orbit.FEVp
double Orbit.FEVs
double Orbit.fromE
double Orbit.fromV
Vector3d Orbit.h

The specific orbital angular momentum

double Orbit.inclination

The inclination of this orbit with respect to the equator of the central body in degrees

double Orbit.LAN

The longitude of the ascending node of the orbit, in degrees. The LAN is the angle between the ascending node and Planetarium.right, as viewed along Planetarium.up.

double Orbit.mag
double Orbit.meanAnomaly

Mean anomaly is the fraction of the orbit that has been completed, measured starting from the periapsis, multiplied by 2π. Look it up.

double Orbit.meanAnomalyAtEpoch

The mean anomaly of the orbit at the special UT given by Orbit.epoch.

double Orbit.nearestTT
Orbit Orbit.nextPatch
double Orbit.nextTT
Orbit.ObjectType Orbit.objectType
double Orbit.ObT

Time since periapsis, in seconds.

double Orbit.ObTAtEpoch

The value of ObT at the universal time given by epoch.

double Orbit.orbitalEnergy
double Orbit.orbitalSpeed
double Orbit.orbitPercent

Equal to

>ObT / period

Orbit.PatchTransitionType Orbit.patchEndTransition

How the next patch follows onto this one, or FINAL if there is no patch after this one.

Orbit.PatchTransitionType Orbit.patchStartTransition
double Orbit.period

The period of the orbit, in seconds.

Vector3d Orbit.pos

The position of the orbiting object, {AliceWorld, Primary}.

Orbit Orbit.previousPatch
double Orbit.radius
CelestialBody Orbit.referenceBody

The body orbited.

double Orbit.sampleInterval
Vector3d Orbit.secondaryPosAtTransition1
Vector3d Orbit.secondaryPosAtTransition2
double Orbit.semiMajorAxis

The semi-major axis of the orbit, in meters. Equal to (PeR + ApR)/2

double Orbit.SEVp
double Orbit.SEVs
double Orbit.StartUT
double Orbit.timeToAp

The time until the object will reach apoapsis, in seconds.

double Orbit.timeToPe

The time unti lthe object will reach periapsis, in seconds.

double Orbit.timeToTransition1
double Orbit.timeToTransition2
double Orbit.toE
double Orbit.toV
double Orbit.trueAnomaly
double Orbit.UTappr
double Orbit.UTsoi
double Orbit.V
Vector3d Orbit.vel

The velocity of the orbiting object, {AliceWorld, Primary}.

Property Documentation

double Orbit.ApA
get

The apoapsis of the orbit in meters, measured from sea level.

double Orbit.ApR
get

The apoapsis of the orbit in meters, measured from the center of the main body.

double Orbit.PeA
get

The periapsis of the orbit in meters, measured from sea level.

double Orbit.PeR
get

The periapsis of the orbit in meters, measured from the center of the main body.

double Orbit.semiLatusRectum
get

A property of ellipses, parabolas and hyperbolas; Google it.

double Orbit.semiMinorAxis
get

A property of ellipses; Google it.


The documentation for this class was generated from the following file: