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

LicenseCC0
Maintainerfrosch03@frosch03.de
Stabilityexperimental
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.KSP.Datatypes

Description

 

Synopsis

Documentation

data Object Source

An Object is something named.

Constructors

Object 

Fields

name :: String
 

Instances

Eq Object 
Show Object

Make Object an instance of Show

data Celestial Source

The Celestial type defines a celestial object within this library. Every celestial object has

  • r [m] the radius (from the bodys center) in meter
  • m [kg] the mass of the object in kilo gramms
  • soi [m] the sphere of influence of the object in meter
  • system empty or a system of surronding objects.

Constructors

Celestial 

Fields

r :: Double
 
m :: Double
 
soi :: Double
 
system :: System Body Body
 

data Body Source

The Body type is the central data type within the KSP library. It could be either Railed or Movable

  • Railed is everything withing ksp that is a star, a planet or a moon. They are static in their orbits and are therefore called railed.
  • Movable is every other part in ksp, that is physical. Here they include deltaV counter, but are also modelled as celestial objects. Actually in ksp orbits around movable parts arent possible. Anyhow, within this data type such constructs are doable.

Constructors

Railed 
Movable 

Fields

object :: Object
 
celestial :: Celestial
 
deltaV :: DeltaV
 

Instances

Eq Body

Make Body an instance of Equalty

Show Body

Make Body an instance of Show

data Orbit a Source

The 'Orbit a' data type defines an orbit around a central body centerBody.

  • centerBody is the body the orbit is around
  • apoapsis is the height of the heighest point of the orbit
  • periapsis is the height of the lowest point of the orbit
  • inclination is the angle that the orbit is inclined against the aquatorial plane
  • omega_big is the longitude of the ascending node
  • omega_small is the argument of the periapsis

Instances

Eq a => Eq (Orbit a) 
Show a => Show (Orbit a)

An orbit is only showable if the type of the centerBody is also showable. As a should normaly be a Body that should be not a problem.

mkOrbit :: a -> Height -> Height -> Orbit a Source

mkOrbit takes a body as well as apoapsis and periapsis and of that creates an orbit.

mkCircOrbit :: a -> Height -> Orbit a Source

mkCircOrbit is similar to mkOrbit with the difference that it creates a circular orbit.

type Height = Double Source

The Height is the height above ground level.

data System b a Source

The System module contains the type definition of a System.

Constructors

Empty 
System [(Orbit b, a)] 

Instances

Functor (System b)

Making 'System b' a member of class functor. With this instance, one could use map over 'System b'.

(Eq b, Eq a) => Eq (System b a) 
(Show a, Show b) => Show (System b a)

A System could be shown, if both type parameters are also filled with types, that are showable.

type GravConst = Double Source

GravConst is the type of the gravitation constant, which is obious a double.

type KSystem = System Body Source

KSystem creates a data constructor, that binds the System to a System of Orbits around Bodys.

getNextUp :: KSystem Body -> Body -> Maybe Body Source

getNextUp takes a KSystem system and a Body. It returns the body that the supplied body orbits. Nothing is returned if the supplied body is not found within the system.

getPathUp :: KSystem Body -> Body -> [Body] Source

getPathUp takes a KSystem system and a Body. It returns the chain of body's that are orbiting each other.

getDivid :: KSystem Body -> Body -> Body -> (Int, Body) Source

getDivid takes a KSystem system and a from Body and a to Body. For both bodys, the path up is calculated by getPathUp and the position, where they reach the same body is returned (as Position and with the actual body).

sOrbitInSystem :: Body -> KSystem Body -> Maybe (Orbit Body) Source

sOrbitInSystem takes a body, a KSystem system and maybe returns the orbit of the body.

pathOBetween :: KSystem Body -> Body -> Body -> [(Body, Orbit Body)] Source

pathOBetween takes a KSystem system and a from Body and a to Body. If one want's to reach the to body from from body the bodys between and their orbit around their centerBody are returnd.

pathOBetween' :: KSystem Body -> Body -> Body -> ([(Body, Orbit Body)], (Body, Orbit Body), [(Body, Orbit Body)]) Source

pathOBetween' takes a KSystem system and a from Body and a to Body. If one want's to reach the to body from from body the bodys between and their orbit around their centerBody are returnd. They are returnd as triple, with the overlapping body in the center of the triple and the path of the from body in the first element of the triple. The path of the to body in the last element of the triple.

pathBetween_ :: KSystem Body -> Body -> Body -> [Body] Source

pathBetween_ takes a KSystem system and a from Body and a to Body. If one want's to reach the to body from from body the bodys between are returnd, without the common body.

pathBetween' :: KSystem Body -> Body -> Body -> ([Body], Body, [Body]) Source

pathBetween takes a KSystem system and from Body and a to Body. If one want's to reach the to body from from body the bodys between and their orbit around their centerBody are returnd. They are returnd as triple, with the overlapping body in the center of the triple and the path of the from body in the first element of the triple. The path of the to body in the last element of the triple.

pathSpeeds :: [(Body, Orbit Body)] -> [Speed] Source

pathSpeeds takes the result of pathOBetween and calculates the corresponding orbital speeds.

orbitalSpeed :: Orbit Body -> Speed Source

orbitalSpeed returns the orbital velocity of the given orbit.