PlanetInfo.cs - MitchOSully/Visualising-the-DFN-Dataset GitHub Wiki
Summary
Stores information about a particular planet, most importantly its orbital elements. Also conducts calculations that convert orbital elements to a Cartesian (x,y,z) position.
List of Functions
void Start()
void setConstants()
Vector3 getPositionAt(double JDay)
double calculateE(double e, double M)
void setInfoText()
double toRadians(double degree)
double toDegrees(double radian)
Public Global Variables
double[] elements = new double[6]
The planet's 6 orbital elements at J2000.
double M0
The planet's mean anomaly at J2000.
double A, B, C, a, b, c
Constants of a planetary orbit. Calculated from three of the orbital elements.
float plotScale
The scale of the Unity scene (1 AU = ? metres). Need this for calculating worldspace positions.
float autoSize
Default scale of this particular planet.
float realSize
Scale of this planet that agrees with the distances between the planets.
Vector3[] positions
An array of every position this planet will every occupy for the duration of the game at one-day increments.
Material lineMaterial
Coloured material to give to the orbit lines.
int trailLength
Number of points in the planet's trail.
string infoText
A (very long) string that contains all information about this planet, to be displayed in the 'info panel' in ScreenMaster
.
float radius
For infoText
. The radius of the planet in kilometres.
float mass
For infoText
. The mass of the planet in kilograms.
float gravity
For infoText
. The strength of gravity on this planet in metres per second squared.
float period
For infoText
. The time it takes for this planet to complete one orbit around the sun (a year) in days.
void Start()
One job: multiplies autoSize
by 0.4. This decreases the planets' sizes by a respectable amount.
Params
None
Returns
None
Calls
None
Called By
- Unity System
void setConstants()
Initialises the constants A
, B
, C
, a
, b
& c
, which are characteristic of a planet's orbit shape. This is executed once before the program begins.
Params
None (uses orbital elements in elements
)
Returns
None
Calls
Called By
Vector3 getPositionAt(double JDay)
Calculates the position of the planet at the imported Julian Day (JD) based on orbital elements and the constants A
, B
, C
, a
, b
& c
.
Method used is from Astronomical Algorithms 2nd ed. by Jean Meeus (p227).
Params
Name | Type | Description |
---|---|---|
JDay |
double |
The date (in JD) that we must calculate the position at. |
Returns
Name | Type | Description |
---|---|---|
position |
Vector3 |
The position of the planet in Cartesian (x,y,z) format. |
Calls
Called By
BodyPlotter.makePlanets()
BodyPlotter.updatePlanets()
BodyPlotter.createLine(GameObject body, string type)
BodyPlotter.skipToDay(double newJD)
double calculateE(double e, double M)
Calculates the eccentric anomaly (E) based on a planet's eccentricity (e) and mean anomaly (M).
Params
Name | Type | Description |
---|---|---|
e |
double |
Eccentricity (unitless). |
M |
double |
Mean anomaly (degrees). |
Returns
Name | Type | Description |
---|---|---|
E |
double |
Eccentric anomaly (degrees). |
Calls
Called By
void setInfoText()
Uses values already stored in the script to construct the infoText
string.
TO DO: include picture of a planet's info panel.
Params
None
Returns
None
Calls
None
Called By
double toRadians(double degree)
Converts an imported angle (degrees) to radians.
Params
Name | Type | Description |
---|---|---|
degree |
double |
Angle to convert (degrees). |
Returns
Name | Type | Description |
---|---|---|
NA | double |
Converted angle (radians). |
Calls
None
Called By
double toDegrees(double radian)
Converts an imported angle (radians) to degrees.
Params
Name | Type | Description |
---|---|---|
radian |
double |
Angle to convert (radians). |
Returns
Name | Type | Description |
---|---|---|
NA | double |
Converted angle (degrees). |
Calls
None