KSP-0.1: A library with the kerbal space program universe and demo code

System.KSP.KSP

Description

# Simple Calculation

The folowing should show some basic calculations that can be done with this library.

## Orbital Velocity

The orbital velocity of something in an 80k orbit around kerbin could be calculated by:

````>>> ````v_orbKerbin 80e3
```2278.9316462467027
```

The corresponding velocity of a 100k orbit is calculated via:

````>>> ````v_orbKerbin 100e3
```2246.1395532335027
```

## Paths

Paths are always calculated within an existing system. Typically is such a system the one around kerbol.

````>>> ````let ksp_system = (system . celestial \$ kKerbol) :: KSystem Body
````>>> ````:t ksp_system
```ksp_system :: KSystem Body
```

An easy path is the one between mun and minmus, via kerbin. This one is calculated via:

````>>> ````pathBetween ksp_system kMun kMinmus
```[R/Mun,R/Kerbin,R/Minmus]
```

A much wieder path would be the one between kerbins moon minmus and jools moon tylo. The path could be calculated via:

````>>> ````pathBetween ksp_system kMinmus kTylo
```[R/Minmus,R/Kerbin,R/Kerbol,R/Jool,R/Tylo]
```

## Paths with Orbits

The function `pathOBetween` calculates not only the path between two given bodys. It also calculates the orbit, of each body. For the path between mun and minmus, the orbits of mun and minmus (each around kerbin) are also returned.

````>>> ````pathOBetween ksp_system kMun kMinmus
```[(R/Mun,Around R/Kerbin (1.14e7|1.14e7)),(R/Minmus,Around R/Kerbin
(4.64e7|4.64e7))]
```

## Path speeds

To calculate the differences in deltaV between different orbits, do the following. First calculate the `pathOBetween`, then take that result and feed it into `pathSpeeds` to get the orbital speeds along the path.

````>>> ````let pathMunMinmus = pathOBetween ksp_system kMun kMinmus
````>>> ````pathSpeeds pathMunMinmus
```[542.4942415070719,274.11754059162286]
```

The orbital velocity of the Mun is 542.5 m/s, the one around Minmus is 274.1 m/s.

## Hohmann Transfair

To do a hohmann transfair of a low kerbin orbit (100km) to the orbit of Mun (47Mm) the following burns must be done.

````>>> ````let o1 = mkCircOrbit kKerbin 100e3
````>>> ````let o2 = mkCircOrbit kKerbin 47000e3
````>>> ````hohmann o1 o2
```(907.2791882798308,226.01062520890378)
```

Lets save these two speeds:

````>>> ````let (v1, v2) = hohmann o1 o2
``````

To calculate the transfair orbit from orbit o1 to orbit o2, the speed v1 has to be applied within the orbit o1.

````>>> ````burnFromCircOrb o1 v1
```Around R/Kerbin (4.7000000000000596e7|100000.0)
```

Again save that orbit into o12

````>>> ````let o12 = burnFromCircOrb o1 v1
``````

And apply the speed v2 to the transfair orbit o12:

````>>> ````burnAtApoapsis o12 v2
```Around R/Kerbin (4.700000000000125e7|4.7000000000000596e7)
```

Which is the desired, circular orbit, with the height of round 47Mm.

Synopsis

# Documentation

To calculate the orbital velocity of a circular orbit around kerbin, `v_orbKerbin` uses `v_orb` with `kKerbin` as default parameter.

`v_orb` calculates the velocity within an orbit around `Body` b, `Height` h meters above the ground.