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.SizeRange Class Reference

Specialization of ValueRange for orbital size parameter. More...

+ Inheritance diagram for Population.SizeRange:

Protected Member Functions

override void parseAll ()
 Ensures that any abstract entries in the config file are properly interpreted. More...
 

Static Protected Member Functions

static double parseOrbitSize (string rawValue)
 Converts an arbitrary string representation of an orbit size to a specific value. More...
 
- Static Protected Member Functions inherited from Population.ValueRange
static double parseOrbitalElement (string rawValue)
 Converts an arbitrary string representation of an orbital element to a specific value. More...
 
static double getPlanetProperty (string planet, string property)
 Returns the desired property of a known celestial body. More...
 

Package Types

enum  SizeType { SemimajorAxis, Periapsis, Apoapsis }
 Defines the parametrization of orbit size that is used.
 
- Package Types inherited from Population.ValueRange
enum  Distribution {
  Uniform, LogUniform, Gaussian, Normal,
  Rayleigh, Exponential, Isotropic
}
 Defines the type of probability distribution from which the value is drawn.
 

Package Functions

 SizeRange (Distribution dist, SizeType type=SizeType.SemimajorAxis, double min=0.0, double max=1.0, double avg=0.0, double stddev=0.0)
 Assigns situation-specific default values to the ValueRange. More...
 
SizeType getParam ()
 Returns the parametrization used by this ValueRange. More...
 
- Package Functions inherited from Population.ValueRange
 ValueRange (Distribution dist, double min=0.0, double max=1.0, double avg=0.0, double stdDev=0.0)
 Assigns situation-specific default values to the ValueRange. More...
 
double draw ()
 Generates a random number consistent with the distribution. More...
 

Private Attributes

SizeType type
 The type of parameter describing the orbit.
 

Static Private Attributes

static Regex mmrDecl
 Defines the syntax for a Resonance declaration. More...
 

Additional Inherited Members

- Protected Attributes inherited from Population.ValueRange
const string planetFormat = "(?<planet>.+)"
 Parse format for planet names. More...
 
const string propFormat = "(?<prop>rad|soi|sma|per|apo|ecc|inc|(a|l)pe|lan|mn(a|l)0)"
 Parse format for planet properties. More...
 
const string planetProp = planetFormat + "\\s*\\.\\s*" + propFormat
 Parse format for planets, with properties. More...
 
Distribution dist
 The probability distribution from which the value is drawn.
 
string rawMin
 Abstract string representation of min.
 
double min
 The minimum allowed value (not always used)
 
string rawMax
 Abstract string representation of max.
 
double max
 The maximum allowed value (not always used)
 
string rawAvg
 Abstract string representation of avg.
 
double avg
 The average value (not always used)
 
string rawStdDev
 Abstract string representation of stdDev.
 
double stdDev
 The standard deviation of the values (not always used)
 

Detailed Description

Specialization of ValueRange for orbital size parameter.

Todo:
I don't think that SizeRange is a subtype of ValueRange in the Liskov sense... check!

Constructor & Destructor Documentation

SizeRange ( Distribution  dist,
SizeType  type = SizeType.SemimajorAxis,
double  min = 0.0,
double  max = 1.0,
double  avg = 0.0,
double  stddev = 0.0 
)
package

Assigns situation-specific default values to the ValueRange.

Parameters
[in]distThe distribution from which the value will be drawn
[in]typeThe description of orbit size that is used
[in]min,maxThe minimum and maximum values allowed for distributions. May be unused.
[in]avgThe mean value returned. May be unused.
[in]stddevThe standard deviation of values returned. May be unused.
Postcondition
The given values will be used by draw() unless they are specifically overridden by a ConfigNode.
Exception Safety
Does not throw exceptions

Member Function Documentation

SizeType getParam ( )
package

Returns the parametrization used by this ValueRange.

Returns
The orbit size parameter represented by this object.
Exception Safety
Does not throw exceptions.
override void parseAll ( )
protectedvirtual

Ensures that any abstract entries in the config file are properly interpreted.

Precondition
this.rawMin, this.rawMax, this.rawAvg, and this.rawStdDev contain a representation of the desired object value
Warning
Class invariant should not be assumed to hold true prior to calling parseAll()
Exceptions
TypeInitializationExceptionThrown if the ConfigNode could not be interpreted as a set of floating-point values
Exception Safety
The program is in a consistent state in the event of an exception

Reimplemented from Population.ValueRange.

static double parseOrbitSize ( string  rawValue)
staticprotected

Converts an arbitrary string representation of an orbit size to a specific value.

Parameters
[in]rawValueA string representing the value.
Returns
The value represented by rawValue.
Precondition
rawValue has one of the following formats:
  • a string representation of a floating-point number
  • a string of the format "Ratio(<Planet>.<stat>, <value>)", where <Planet> is the name of a loaded celestial body, <stat> is one of (rad, soi, sma, per, apo, ecc, inc, ape, lpe, lan, mna0, mnl0), and <value> is a string representation of a floating-point number
  • a string of the format "Offset(<Planet>.<stat>, <value>)", where <Planet>, <stat>, and <value> are as above.
  • a string of the format "Resonance(<Planet>, <m>:<n>)", where <Planet> is the name of a loaded celestial body, and <m> and <n> are string representations of positive integers. In keeping with standard astronomical convention, m > n means an orbit inside that of <Planet>, while m < n means an exterior orbit
Exceptions
ArgumentExceptionThrown if rawValue could not be interpreted as a floating-point value
Exception Safety
This method is atomic.

Member Data Documentation

Regex mmrDecl
staticprivate
Initial value:
= new Regex(
"Resonance\\(\\s*" + planetFormat + "\\s*,\\s*(?<m>\\d+)\\s*:\\s*(?<n>\\d+)\\s*\\)",
RegexOptions.IgnoreCase)

Defines the syntax for a Resonance declaration.


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