Difference between revisions of "API:CelestialBody"

From Kerbal Space Program Wiki
Jump to: navigation, search
(added public fields)
(added the methods I can figure out; there are still several remaining to do)
Line 63: Line 63:
 
{{Field|type=float|name=altitudeOffset}}
 
{{Field|type=float|name=altitudeOffset}}
  
{{Field|type=double|name=angularV}}
+
{{Field|type=double|name=angularV|desc=The magnitude of <code>angularVelocity</code>}}
 
{{Field|type=Vector3d|name=angularVelocity}}
 
{{Field|type=Vector3d|name=angularVelocity}}
 
{{Field|type=float|name=atmosphereTemperatureMultiplier}}
 
{{Field|type=float|name=atmosphereTemperatureMultiplier}}
Line 88: Line 88:
 
{{Field|type=double|name=GeeASL|desc=Force of gravity at sea level?}}
 
{{Field|type=double|name=GeeASL|desc=Force of gravity at sea level?}}
  
{{Field|type=double|name=gMagnitudeAtCenter}}
+
{{Field|type=double|name=gMagnitudeAtCenter|desc=Equal to <code>GeeASL</code> * 9.81 * <code>Radius</code>^2}}
  
 
{{Field
 
{{Field
Line 145: Line 145:
 
{{Field|type=QuaternionD|name=rotation}}
 
{{Field|type=QuaternionD|name=rotation}}
  
{{Field|type=double|name=rotationAngle}}
+
{{Field|type=double|name=rotationAngle|desc=The current angle of the body's rotation}}
  
 
{{Field
 
{{Field
Line 184: Line 184:
 
|args={{arg|Vector3d|worldPos}}
 
|args={{arg|Vector3d|worldPos}}
 
|desc=The altitude above sea level of a given world position, in meters.
 
|desc=The altitude above sea level of a given world position, in meters.
 +
}}
 +
{{Method
 +
|returntype=Bounds
 +
|returndesc=
 +
|name=getBounds
 +
|desc=Looks like a sphere for detecting potential collisions. Has a radius substantially larger than the body's radius&mdash;presumably to account for terrain and atmospheric height plus a safety margin.
 
}}
 
}}
 
{{Method
 
{{Method
Line 198: Line 204:
 
|args={{arg|Vector3d|worldPos}}
 
|args={{arg|Vector3d|worldPos}}
 
|desc=The longitude of a given world position, in degrees.  The returned value doesn't seem to stay in any particular range.  It may be > 360 or < 0.  You'll probably want to do some modulo arithmetic to force this into a certain range like -180 to 180 or 0 to 360.
 
|desc=The longitude of a given world position, in degrees.  The returned value doesn't seem to stay in any particular range.  It may be > 360 or < 0.  You'll probably want to do some modulo arithmetic to force this into a certain range like -180 to 180 or 0 to 360.
 +
}}
 +
{{Method
 +
|returntype=string
 +
|returndesc=
 +
|name=GetName
 +
|desc=Same as <code>name</code> property.
 +
}}
 +
{{Method
 +
|returntype=Vector3
 +
|name=GetObtVelocity
 +
|desc=Infinite loop? (version 0.23.5)
 +
}}
 +
{{Method
 +
|returntype=Orbit
 +
|name=GetOrbit
 +
|desc=Same as <code>orbit</code>.
 +
}}
 +
{{Method
 +
|returntype=OrbitDriver
 +
|name=GetOrbitDriver
 +
|desc=Same as <code>orbitDriver</code>.
 
}}
 
}}
 
{{Method
 
{{Method
 
|returntype=Vector3d
 
|returntype=Vector3d
 
|returndesc=
 
|returndesc=
|name=GetRFrmVel
+
|name=GetRelSurfacePosition
 +
|args={{arg|Vector3d|worldPosition}}
 +
|desc=Converts a world position into a body-relative position?
 +
}}
 +
{{Method
 +
|returntype=Vector3d
 +
|name=GetRelSurfacePosition
 +
|args={{arg|double|lat}}, {{arg|double|lon}}, {{arg|double|alt}}
 +
|desc=Returns position in body-relative coordinates for a given longitude/latitude/altitude. Same as GetSurfaceNVector * (body radius + alt).
 +
}}
 +
{{Method
 +
|returntype=Vector3d
 +
|returndesc=
 +
|name=getRFrmVel
 
|args={{arg|Vector3d|worldPos}}
 
|args={{arg|Vector3d|worldPos}}
|desc=The reference frame of the planet's surface rotates with respect to an inertial reference frame. For example, a ship landed on the planet's surface is actually moving with respect to an inertial frame, because the planet is rotating. This function gives the difference between a velocity in the rotating frame and the same velocity in the inertial frame. You can use it to convert an inertial frame velocity (like the one returned by Orbit.GetVel()) to a rotating frame velocity by (rotating frame velocity) = (inertial frame velocity) - body.GetRFrmVel(position).
+
|desc=The reference frame of the planet's surface rotates with respect to an inertial reference frame. For example, a ship landed on the planet's surface is actually moving with respect to an inertial frame, because the planet is rotating. This function gives the difference between a velocity in the rotating frame and the same velocity in the inertial frame. You can use it to convert an inertial frame velocity (like the one returned by <code>Orbit.GetVel()</code>) to a rotating frame velocity by (rotating frame velocity) = (inertial frame velocity) - <code>body.GetRFrmVel(position)</code>.
 +
}}
 +
{{Method
 +
|returntype=Vector3d
 +
|name=GetSrfVelocity
 +
|desc=Always returns a zero vector. (as of version 0.23.5)
 
}}
 
}}
 
{{Method
 
{{Method
Line 211: Line 256:
 
|name=GetSurfaceNVector
 
|name=GetSurfaceNVector
 
|args={{arg|double|lat}}, {{arg|double|lon}}
 
|args={{arg|double|lat}}, {{arg|double|lon}}
|desc=Returns a unit vector that is normal to the sphere of the planet at the given latitude and longitude.
+
|desc=Returns a unit vector that is normal to the sphere of the planet at the given latitude and longitude. (Tells you which way is "up" at a given point on the planet.)
 
}}
 
}}
 +
{{Method|returntype=Transform|name=GetTransform|desc=Same as <code>bodyTransform</code> field}}
 
{{Method
 
{{Method
 
|returntype=Vector3d
 
|returntype=Vector3d
Line 218: Line 264:
 
|name=GetWorldSurfacePosition
 
|name=GetWorldSurfacePosition
 
|args={{arg|double|lat}}, {{arg|double|lon}}, {{arg|double|alt}}
 
|args={{arg|double|lat}}, {{arg|double|lon}}, {{arg|double|alt}}
|desc=Probably this returns the world position corresponding to a given latitude, longitude, and altitude above sea level?
+
|desc=Returns the world position corresponding to a given latitude, longitude, and altitude above sea level.
 
}}
 
}}
 +
{{Method|returntype=bool|name=HasChild|args={{arg|CelestialBody|body}}|desc=True if the given body orbits this one. Doesn't seem to need to be a <i>direct</i> orbit&mdash;can be something that orbits something that orbits this. Inverse of <code>HasParent</code>.}}
 +
{{Method|returntype=bool|name=HasParent|args={{arg|CelestialBody|body}}|desc=True if the given body orbits is orbited by this one. Doesn't seem to need to be a <i>direct</i> orbit&mdash;can be something that's orbited by something that's orbited by this. Inverse of <code>HasChild</code>.}}
 
{{MethodsEnd}}
 
{{MethodsEnd}}
  
 
[[Category:Community API Documentation]]
 
[[Category:Community API Documentation]]

Revision as of 03:02, 13 June 2014

CelestialBody Class

Inherits Implements
UnityEngine.MonoBehaviour ITargetable, IDiscoverable

A CelestialBody represents a planet, moon, or star that acts as a source of gravity and has some sphere of influence. You can find the CelestialBody whose sphere of influence you are currently in with the vessel.mainBody field.

Properties

The following are public properties available in CelestialBody.

Signature Description
DiscoveryInfo DiscoveryInfo { get; } ?
int flightsGlobalIndex { get; set; } ?
string name { get; } The name of the body, as it appears in e.g. the map view. Same as bodyName field.
Orbit orbit { get; } Contains all information about the body's orbit around whatever other body it is orbiting.
Vector3d position { get; set; } The position of the center of the body in world space.
CelestialBody referenceBody { get; } (not confirmed) The celestial body that this one orbits.
Texture2D ResourceMap { get; } ?
PResource Resources { get; } ?
string theName { get; } (not confirmed) Same as name except prefixed with "the " (if appropriate)

Fields

The following is a list of publically-accessible fields in CelestialBody. This includes protected items, which can be accessed by subclasses.

Signature Description
float altitudeMultiplier ?
float altitudeOffset ?
double angularV The magnitude of angularVelocity
Vector3d angularVelocity ?
float atmosphereTemperatureMultiplier ?
bool atmosphere ?
bool atmosphereContainsOxygen ?
float atmosphereMultiplier ?
double atmosphereScaleHeight ?
Color atmosphericAmbientColor ?
CBAttributeMap BiomeMap ?
string bodyName Same as the name property
Transform bodyTransition ?
CelestialBodyType bodyType ?
double directRotAngle ?
double GeeASL Force of gravity at sea level?
double gMagnitudeAtCenter Equal to GeeASL * 9.81 * Radius^2
double gravParamter This is probably equal to G * Mass?
double hillSphere ?
double initialRotation ?
bool inverseRotation ?
float inverseRotThresholdAltitude ?
double Mass the mass of the body, in KSP's arbitrary mass units. For calculating gravity, KSP seems to use a gravitational constant of G = 6.674E-11 (SI units), which is the same as the real one rounded to 3 decimal places.
double maxAtmosphereAltitude The height above sea level at which the atmosphere ends, in meters.
bool ocean ?
OrbitDriver orbitDriver ?
List<CelestialBody> orbitingBodies A list of all the bodies that orbit this one (e.g., the moons of a planet)
PQS pqsController An object that can give you information about the planet's terrain height as a function of position. See the documentation on the PQS class to see how to use it.
AnimationCurve pressureCurve ?
float pressureMultiplier ?
double Radius The radius of the planet in meters. This defines sea level.
bool rotates ?
QuaternionD rotation ?
double rotationAngle The current angle of the body's rotation
double rotationPeriod How long it takes the planet to revolve once about its axis, in seconds.
CelestialBodyScienceParams scienceValues ?
double sphereOfInfluence The radius of the body's sphere of influence, in meters, measured from the center of the planet (not sea level).
double staticPressureASL ?
AnimationCurve temperatureCurve ?
PlanetQuadTreeController terrainController ?
bool tidallyLocked ?
array of float timeWarpAltitudeLimits ?
bool useLegacyAtmosphere ?
bool use_The_InName ?
Vector3d zUpAngularVelocity ?

Methods

The following are methods included in CelestialBody.

Signature Description
double GetAltitude(Vector3d worldPos) The altitude above sea level of a given world position, in meters.
Bounds getBounds() Looks like a sphere for detecting potential collisions. Has a radius substantially larger than the body's radius—presumably to account for terrain and atmospheric height plus a safety margin.
double GetLatitude(Vector3d worldPos) The latitude of a given world position, in degrees.
double GetLongitude(Vector3d worldPos) The longitude of a given world position, in degrees. The returned value doesn't seem to stay in any particular range. It may be > 360 or < 0. You'll probably want to do some modulo arithmetic to force this into a certain range like -180 to 180 or 0 to 360.
string GetName() Same as name property.
Vector3 GetObtVelocity() Infinite loop? (version 0.23.5)
Orbit GetOrbit() Same as orbit.
OrbitDriver GetOrbitDriver() Same as orbitDriver.
Vector3d GetRelSurfacePosition(Vector3d worldPosition) Converts a world position into a body-relative position?
Vector3d GetRelSurfacePosition(double lat, double lon, double alt) Returns position in body-relative coordinates for a given longitude/latitude/altitude. Same as GetSurfaceNVector * (body radius + alt).
Vector3d getRFrmVel(Vector3d worldPos) The reference frame of the planet's surface rotates with respect to an inertial reference frame. For example, a ship landed on the planet's surface is actually moving with respect to an inertial frame, because the planet is rotating. This function gives the difference between a velocity in the rotating frame and the same velocity in the inertial frame. You can use it to convert an inertial frame velocity (like the one returned by Orbit.GetVel()) to a rotating frame velocity by (rotating frame velocity) = (inertial frame velocity) - body.GetRFrmVel(position).
Vector3d GetSrfVelocity() Always returns a zero vector. (as of version 0.23.5)
Vector3d GetSurfaceNVector(double lat, double lon) Returns a unit vector that is normal to the sphere of the planet at the given latitude and longitude. (Tells you which way is "up" at a given point on the planet.)
Transform GetTransform() Same as bodyTransform field
Vector3d GetWorldSurfacePosition(double lat, double lon, double alt) Returns the world position corresponding to a given latitude, longitude, and altitude above sea level.
bool HasChild(CelestialBody body) True if the given body orbits this one. Doesn't seem to need to be a direct orbit—can be something that orbits something that orbits this. Inverse of HasParent.
bool HasParent(CelestialBody body) True if the given body orbits is orbited by this one. Doesn't seem to need to be a direct orbit—can be something that's orbited by something that's orbited by this. Inverse of HasChild.