Difference between revisions of "API:FlightGlobals"
(Created page with "The FlightGlobals class contains a number of useful static functions and fields. == Useful members == Note: this is not a complete listing of the class's members. It include...") |
|||
Line 4: | Line 4: | ||
Note: this is not a complete listing of the class's members. It includes only the members that someone has figured out how to use and written an explanation for. If you figure out what the other members that aren't listed here do, you should add them to the list! | Note: this is not a complete listing of the class's members. It includes only the members that someone has figured out how to use and written an explanation for. If you figure out what the other members that aren't listed here do, you should add them to the list! | ||
+ | |||
+ | A number of FlightGlobals functions have two versions: one that takes a CelestialBody as an argument and one that doesn't. Presumably the second version uses the mainBody of the active vessel. Below are listed only the versions that take an explicit CelestialBody argument. | ||
<table border="1"> | <table border="1"> | ||
<tr> | <tr> | ||
− | <td><code>static float GetAltitudeAtPos(Vector3 position)</code></td> | + | <td><code>static float GetAltitudeAtPos(Vector3 position, CelestialBody body)</code></td> |
− | <td>Gives the altitude | + | <td>Gives the altitude of a given world position above body's sea level.</td> |
</tr> | </tr> | ||
<tr> | <tr> | ||
<td><code>static double getAtmDensity(double pressure)</code></td> | <td><code>static double getAtmDensity(double pressure)</code></td> | ||
− | <td>Calculates an atmospheric density in some arbitrary units. Presumably it's meant to take as input the output of FlightGlobals.getStaticPressure. The following code seems to work quite well to compute the drag force on a part and may in fact be | + | <td>Calculates an atmospheric density in some arbitrary units. Presumably it's meant to take as input the output of FlightGlobals.getStaticPressure. The following code seems to work quite well to compute the drag force on a part and may in fact be the game's drag formula: |
− | <code>double rho = FlightGlobals.getAtmDensity(FlightGlobals.getStaticPressure(position, body)) | + | <code>double rho = FlightGlobals.DragMultiplier * FlightGlobals.getAtmDensity(FlightGlobals.getStaticPressure(position, body)); |
Vector3d airVel = vessel.orbit.GetVel() - body.getRFrmVel(position); //the velocity of the vessel relative to the air | Vector3d airVel = vessel.orbit.GetVel() - body.getRFrmVel(position); //the velocity of the vessel relative to the air | ||
Line 22: | Line 24: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <td><code></code></td> | + | <td><code>static Vector3d getGeeForceAtPosition(Vector3d pos)</code></td> |
− | <td> | + | <td>The gravitational acceleration (not force) at the position pos. Does this compute which SOI pos is in or does it assume that pos is in the SOI of the active vessel's mainBody?</td> |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <td><code></code></td> | + | <td><code>static double getStaticPressure(Vector3d position, CelestialBody body)</code></td> |
− | <td></td> | + | <td>The air pressure of body's atmosphere at position, in some arbitrary units.</td> |
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <td><code></code></td> | + | <td><code>static Vessel ActiveVessel { get; }</code></td> |
− | <td></td> | + | <td>The vessel currently being controlled by the player.</td> |
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <td><code></code></td> | + | <td><code>CelestialBody[] Bodies { get; }</code></td> |
− | <td></td> | + | <td>An array containing all the celestial bodies in the universe.</td> |
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <td><code></code></td> | + | <td><code>static float DragMultiplier { get; }</code></td> |
− | <td></td> | + | <td>A proportionality constant that scales the strength of aerodynamic drag forces.</td> |
</tr> | </tr> | ||
<tr> | <tr> | ||
− | <td><code></code></td> | + | <td><code>List<Vessel> Vessels { get; }</code></td> |
− | <td></td> | + | <td>A list of all the Vessels in the universe.</td> |
</tr> | </tr> | ||
</table> | </table> | ||
[[Category:Community API Documentation]] | [[Category:Community API Documentation]] |
Revision as of 22:43, 11 May 2012
The FlightGlobals class contains a number of useful static functions and fields.
Useful members
Note: this is not a complete listing of the class's members. It includes only the members that someone has figured out how to use and written an explanation for. If you figure out what the other members that aren't listed here do, you should add them to the list!
A number of FlightGlobals functions have two versions: one that takes a CelestialBody as an argument and one that doesn't. Presumably the second version uses the mainBody of the active vessel. Below are listed only the versions that take an explicit CelestialBody argument.
static float GetAltitudeAtPos(Vector3 position, CelestialBody body) |
Gives the altitude of a given world position above body's sea level. |
static double getAtmDensity(double pressure) |
Calculates an atmospheric density in some arbitrary units. Presumably it's meant to take as input the output of FlightGlobals.getStaticPressure. The following code seems to work quite well to compute the drag force on a part and may in fact be the game's drag formula:
Vector3d airVel = vessel.orbit.GetVel() - body.getRFrmVel(position); //the velocity of the vessel relative to the air Vector3d dragForce = -0.5 * rho * part.mass * part.maximum_drag * airVel.magnitude * airVel; |
static Vector3d getGeeForceAtPosition(Vector3d pos) |
The gravitational acceleration (not force) at the position pos. Does this compute which SOI pos is in or does it assume that pos is in the SOI of the active vessel's mainBody? |
static double getStaticPressure(Vector3d position, CelestialBody body) |
The air pressure of body's atmosphere at position, in some arbitrary units. |
static Vessel ActiveVessel { get; } |
The vessel currently being controlled by the player. |
CelestialBody[] Bodies { get; } |
An array containing all the celestial bodies in the universe. |
static float DragMultiplier { get; } |
A proportionality constant that scales the strength of aerodynamic drag forces. |
List<Vessel> Vessels { get; } |
A list of all the Vessels in the universe. |