Custom Asteroids  1.1.0
A mod for Kerbal Space Program that lets users control where asteroids appear
 All Classes Namespaces Files Functions Variables Enumerations Properties Pages
Population Class Reference

Represents a set of asteroids with similar orbits. More...

Classes

class  PeriRange
 Specialization of ValueRange for position of periapsis. More...
 
class  PhaseRange
 Specialization of ValueRange for orbital phase parameter. More...
 
class  SizeRange
 Specialization of ValueRange for orbital size parameter. More...
 
class  ValueRange
 Represents the set of values an orbital element may assume. More...
 

Public Member Functions

override string ToString ()
 Returns a string that represents the current object. More...
 

Package Functions

 Population ()
 Creates a dummy population. More...
 
Orbit drawOrbit ()
 Generates a random orbit consistent with the population properties. More...
 
double getSpawnRate ()
 Returns the rate at which asteroids are discovered in the population. More...
 
string getName ()
 Returns the name of the population. More...
 
string getAsteroidName ()
 Returns the name of asteroids within the population. More...
 

Static Private Member Functions

static double anomalyToLong (double anom, double i, double aPe, double lAn)
 Converts an anomaly to an orbital longitude. More...
 
static double longToAnomaly (double longitude, double i, double aPe, double lAn)
 Converts an orbital longitude to an anomaly. More...
 
static CelestialBody getPlanetByName (string name)
 Searches KSP for a celestial body. More...
 
static double getStartUt ()
 Returns the time at the start of the game. More...
 

Private Attributes

string name
 A unique name for the population.
 
string title
 The name of asteroids belonging to this population.
 
string centralBody
 The name of the celestial object orbited by the asteroids.
 
double spawnRate
 The rate, in asteroids per Earth day, at which asteroids are discovered.
 
SizeRange orbitSize
 The size (range) of orbits in this population.
 
ValueRange eccentricity
 The eccentricity (range) of orbits in this population.
 
ValueRange inclination
 The inclination (range) of orbits in this population.
 
PeriRange periapsis
 The argument/longitude of periapsis (range) of orbits in this population.
 
ValueRange ascNode
 The longitude of ascending node (range) of orbits in this population.
 
PhaseRange orbitPhase
 The range of positions along the orbit for asteroids in this population.
 

Detailed Description

Represents a set of asteroids with similar orbits.

Warning
Population objects are typically initialized using an external traversal, rather than a constructor. Therefore, traditional validity guarantees cannot be enforced. Instead, the Population class makes heavier than usual use of defensive programming.
Note
To avoid breaking the persistence code, Population may not have subclasses

Constructor & Destructor Documentation

Population ( )
package

Creates a dummy population.

Postcondition
The object is initialized to a state in which it will not be expected to generate orbits. Any orbits that are generated will be located inside the Sun, causing the game to immediately delete the object with the orbit.
Exception Safety
Does not throw exceptions.
Note
Required by interface of ConfigNode.LoadObjectFromConfig()

Member Function Documentation

static double anomalyToLong ( double  anom,
double  i,
double  aPe,
double  lAn 
)
staticprivate

Converts an anomaly to an orbital longitude.

Parameters
[in]anomThe angle between the periapsis point and a position in the planet's orbital plane. May be mean, eccentric, or true anomaly.
[in]iThe inclination of the planet's orbital plane
[in]aPeThe argument of periapsis of the planet's orbit
[in]lAnThe longitude of ascending node of this planet's orbital plane
Returns
The angle between the reference direction (coordinate x-axis) and the projection of a position onto the x-y plane. Will be mean, eccentric, or true longitude, corresponding to the type of anomaly provided.
Exception Safety
Does not throw exceptions
Orbit drawOrbit ( )
package

Generates a random orbit consistent with the population properties.

Returns
The orbit of a randomly selected member of the population
Exceptions
System.InvalidOperationExceptionThrown if population's parameter values cannot produce valid orbits.
Exception Safety
The program is in a consistent state in the event of an exception
Todo:
Break up this function
string getAsteroidName ( )
package

Returns the name of asteroids within the population.

Returns
A human-readable string that can be used as an asteroid prefix.
Exception Safety
Does not throw exceptions.
string getName ( )
package

Returns the name of the population.

Returns
A human-readable string identifying the population.
Exception Safety
Does not throw exceptions.
static CelestialBody getPlanetByName ( string  name)
staticprivate

Searches KSP for a celestial body.

Parameters
[in]nameThe exact, case-sensitive name of the celestial body to recover
Returns
The celestial body named name
Precondition
All loaded celestial bodies have unique names
Exceptions
ArgumentExceptionThrown if no celestial body named name exists
Exception Safety
This method is atomic
double getSpawnRate ( )
package

Returns the rate at which asteroids are discovered in the population.

Returns
The number of asteroids discovered per Earth day.
Exception Safety
Does not throw exceptions.
static double getStartUt ( )
staticprivate

Returns the time at the start of the game.

Returns
If playing stock KSP, returns 0 UT. If playing Real Solar System, returns RealSolarSystem.cfg/REALSOLARSYSTEM.Epoch
Exception Safety
Does not throw exceptions
static double longToAnomaly ( double  longitude,
double  i,
double  aPe,
double  lAn 
)
staticprivate

Converts an orbital longitude to an anomaly.

Parameters
[in]longitudeThe angle between the reference direction (coordinate x-axis) and the projection of a position onto the x-y plane, in degrees. May be mean, eccentric, or true longitude.
[in]iThe inclination of the planet's orbital plane
[in]aPeThe argument of periapsis of the planet's orbit
[in]lAnThe longitude of ascending node of this planet's orbital plane
Returns
The angle between the periapsis point and a position in the planet's orbital plane, in degrees. Will be mean, eccentric, or true anomaly, corresponding to the type of longitude provided.
Exception Safety
Does not throw exceptions
override string ToString ( )

Returns a string that represents the current object.

Returns
A simple string identifying the object
See Also
Object.ToString()

The documentation for this class was generated from the following file: