Difference between revisions of "API:CelestialBody"
From Kerbal Space Program Wiki
Line 4: | Line 4: | ||
<table border="1"> | <table border="1"> | ||
+ | |||
+ | <tr> | ||
+ | <td><code>double GetAltitude(Vector3d worldPos)</code></td> | ||
+ | <td> The altitude above sea level of a given world position, in meters.</td> | ||
+ | </tr> | ||
+ | |||
+ | <tr> | ||
+ | <td><code>double GetLatitude(Vector3d worldPos)</code> </td> | ||
+ | <td>The latitude of a given world position, in degrees.</td> | ||
+ | </tr> | ||
+ | |||
<tr> | <tr> | ||
− | <td><code>double | + | <td><code>double GetLongitude(Vector3d worldPos)</code> </td> |
+ | <td>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. Probably you'll want to do some modulo arithmetic to force this into a certain range like -180 to 180 or 0 to 360.</td> | ||
</tr> | </tr> | ||
+ | |||
<tr> | <tr> | ||
− | <td> | + | <td><code>Vector3d GetRFrmVel(Vector3d worldPos)</code> </td> |
− | <code> | + | <td>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). </td> |
− | </td> | ||
− | <td> | ||
− | The | ||
− | </td> | ||
</tr> | </tr> | ||
− | |||
− | |||
− | Vector3d | + | <tr> |
+ | <td><code>Vector3d GetSurfaceNVector(double lat, double lon)</code> </td> | ||
+ | <td>Returns a unit vector that is normal to the sphere of the planet at the given latitude and longitude.</td> | ||
+ | </tr> | ||
− | Vector3d | + | <tr> |
+ | <td><code>Vector3d GetWorldSurfacePosition(double lat, double lon, double alt)</code> </td> | ||
+ | <td>Probably this returns the world position corresponding to a given latitude, longitude, and altitude above sea level?</td> | ||
+ | </tr> | ||
− | + | <tr> | |
+ | <td><code>string name { get; }</code> </td> | ||
+ | <td>The name of the body, as it appears in e.g. the map view.</td> | ||
+ | </tr> | ||
− | + | <tr> | |
+ | <td><code>Vector3d position { get; set; } </code> </td> | ||
+ | <td>The position of the center of the body in world space.</td> | ||
+ | </tr> | ||
− | + | <tr> | |
+ | <td><code>double Mass</code> </td> | ||
+ | <td>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.</td> | ||
+ | </tr> | ||
− | double | + | <tr> |
+ | <td><code>double gravParamter</code> </td> | ||
+ | <td>This is probably equal to G * Mass?</td> | ||
+ | </tr> | ||
− | double | + | <tr> |
+ | <td><code>double maxAtmosphereAltitude</code> </td> | ||
+ | <td>The height above sea level at which the atmosphere ends, in meters.</td> | ||
+ | </tr> | ||
− | + | <tr> | |
+ | <td><code>Orbit orbit</code> </td> | ||
+ | <td>Contains all information about the body's orbit around whatever other body it is orbiting.</td> | ||
+ | </tr> | ||
− | + | <tr> | |
+ | <td><code>List<CelestialBody> orbitingBodies</code> </td> | ||
+ | <td>A list of all the bodies that orbit this one (e.g., the moons of a planet)</td> | ||
+ | </tr> | ||
− | + | <tr> | |
+ | <td><code>double Radius</code> </td> | ||
+ | <td>The radius of the planet in meters. This defines sea level.</td> | ||
+ | </tr> | ||
− | + | </table> | |
The above lists only the members that someone has figured out how to use and written an explanation for. For completeness, here's a list of the remaining members of the CelestialBody class. If you figure out what they do, add an explanation above! | The above lists only the members that someone has figured out how to use and written an explanation for. For completeness, here's a list of the remaining members of the CelestialBody class. If you figure out what they do, add an explanation above! | ||
− | Bounds getBounds() | + | *Bounds getBounds() |
− | Vector3d GetFrameVel() | + | *Vector3d GetFrameVel() |
− | Vector3d GetRelSurfacePosition(double lat, double lon, double alt) | + | *Vector3d GetRelSurfacePosition(double lat, double lon, double alt) |
− | float altitudeMultiplier | + | *float altitudeMultiplier |
− | float altitudeOffset | + | *float altitudeOffset |
− | double angularV | + | *double angularV |
− | Vector3d angularVelocity | + | *Vector3d angularVelocity |
− | float atmosphereTemperatureMultiplier | + | *float atmosphereTemperatureMultiplier |
− | bool atmosphere | + | *bool atmosphere |
− | double atmosphereScaleHeight | + | *double atmosphereScaleHeight |
− | Color atmosphericAmbientColor | + | *Color atmosphericAmbientColor |
− | double defaultSOI | + | *double defaultSOI |
− | double directRotAngle | + | *double directRotAngle |
− | double GeeASL | + | *double GeeASL |
− | double gMagnitudeAtCenter | + | *double gMagnitudeAtCenter |
− | double hillSphere | + | *double hillSphere |
− | double initialRotation | + | *double initialRotation |
− | double inverseRotation | + | *double inverseRotation |
− | double inverseRotThresholdAltitude | + | *double inverseRotThresholdAltitude |
− | bool ocean | + | *bool ocean |
− | PQS pqsController | + | *PQS pqsController |
− | AnimationCurve pressureCurve | + | *AnimationCurve pressureCurve |
− | float pressureMultiplier | + | *float pressureMultiplier |
− | bool rotates | + | *bool rotates |
− | QuaternionD rotation | + | *QuaternionD rotation |
− | double rotationAngle | + | *double rotationAngle |
− | double rotationPeriod | + | *double rotationPeriod |
− | double sphereOfInfluence | + | *double sphereOfInfluence |
− | double staticPressureASL | + | *double staticPressureASL |
− | AnimationCurve temperatureCurve | + | *AnimationCurve temperatureCurve |
− | PlanetQuadTreeController terrainController | + | *PlanetQuadTreeController terrainController |
− | bool tidallyLocked | + | *bool tidallyLocked |
− | bool use_The_InName | + | *bool use_The_InName |
− | bool useLegacyAtmsophere | + | *bool useLegacyAtmsophere |
− | Vector3d zUpAngularVelocity | + | *Vector3d zUpAngularVelocity |
Revision as of 19:47, 6 April 2012
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.
Useful members:
double GetAltitude(Vector3d worldPos) |
The altitude above sea level of a given world position, in meters. |
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. Probably you'll want to do some modulo arithmetic to force this into a certain range like -180 to 180 or 0 to 360. |
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 GetSurfaceNVector(double lat, double lon) |
Returns a unit vector that is normal to the sphere of the planet at the given latitude and longitude. |
Vector3d GetWorldSurfacePosition(double lat, double lon, double alt) |
Probably this returns the world position corresponding to a given latitude, longitude, and altitude above sea level? |
string name { get; } |
The name of the body, as it appears in e.g. the map view. |
Vector3d position { get; set; } |
The position of the center of the body in world space. |
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 gravParamter |
This is probably equal to G * Mass? |
double maxAtmosphereAltitude |
The height above sea level at which the atmosphere ends, in meters. |
Orbit orbit |
Contains all information about the body's orbit around whatever other body it is orbiting. |
List<CelestialBody> orbitingBodies |
A list of all the bodies that orbit this one (e.g., the moons of a planet) |
double Radius |
The radius of the planet in meters. This defines sea level. |
The above lists only the members that someone has figured out how to use and written an explanation for. For completeness, here's a list of the remaining members of the CelestialBody class. If you figure out what they do, add an explanation above!
- Bounds getBounds()
- Vector3d GetFrameVel()
- Vector3d GetRelSurfacePosition(double lat, double lon, double alt)
- float altitudeMultiplier
- float altitudeOffset
- double angularV
- Vector3d angularVelocity
- float atmosphereTemperatureMultiplier
- bool atmosphere
- double atmosphereScaleHeight
- Color atmosphericAmbientColor
- double defaultSOI
- double directRotAngle
- double GeeASL
- double gMagnitudeAtCenter
- double hillSphere
- double initialRotation
- double inverseRotation
- double inverseRotThresholdAltitude
- bool ocean
- PQS pqsController
- AnimationCurve pressureCurve
- float pressureMultiplier
- bool rotates
- QuaternionD rotation
- double rotationAngle
- double rotationPeriod
- double sphereOfInfluence
- double staticPressureASL
- AnimationCurve temperatureCurve
- PlanetQuadTreeController terrainController
- bool tidallyLocked
- bool use_The_InName
- bool useLegacyAtmsophere
- Vector3d zUpAngularVelocity