Class SpiceLibrary
- Namespace
- NominalSystems.Universe
- Assembly
- NominalSystems.Universe.dll
[Nominal] Interfaces with NASA SPICE library and is able to fetch the current ephemeris and time information from SPICE. All functions involving SPICE are thread-safe and require a lock to make them thread-safe.
public static class SpiceLibrary
- Inheritance
-
SpiceLibrary
Methods
GetCelestialFrame(string, ref string, ref int)
Returns the celestial frame name and code from a particular target. This is required for some basic calculations using the SPICE system.
public static void GetCelestialFrame(string target, ref string frame, ref int code)
Parameters
target
stringThe target name to fetch, if valid
frame
stringThe coordinate frame name of the body
code
intThe coordinate frame code of the body
GetCelestialState(string, double, string, string, string, ref Vector3, ref Vector3, ref Matrix3, ref Matrix3, ref double)
Calculates the celestial state of an object, including the position, velocity, rotation and rotation rate, based on some parameters to pass into the SPICE kernels. This requires a few inputs based on the current time of the simulation and the target object.
public static void GetCelestialState(string target, double time, string zeroBase, string bodyFrame, string coordinateFrame, ref Vector3 position, ref Vector3 velocity, ref Matrix3 j2000, ref Matrix3 j2000dot, ref double lightTime)
Parameters
target
string[-] The target name using the SPICE name that is required
time
double[s] The time since the epoch start
zeroBase
string[-] The name of the zero base used for the coordinate frame
bodyFrame
string[-] The name of the planet frame for this particular body
coordinateFrame
string[-] The name of the coordinate frame used by this simulation
position
Vector3[m] The position of the body relative to the coordinate frame
velocity
Vector3[m/s] The velocity of the body relative to the coordinate frame
j2000
Matrix3[-] The rotation of the body relative to the body frame
j2000dot
Matrix3[r/s] The angular velocity of the body relative to the body frame
lightTime
double[s] The time it takes for light to travel from the coordinate frame to the body
GetEphemerisTime(DateTime, ref double, ref string)
Calculates the ephemeris time and ISO 8601 time string from a particular time in the simulation. This is required for some basic calculations using the SPICE system.
public static void GetEphemerisTime(DateTime time, ref double ephemerisTime, ref string iso8601)
Parameters
time
DateTime[-] The datetime to check
ephemerisTime
double[s] The ephemeris time returned
iso8601
string[-] The datetime string
GetFrameString(CoordinateFrameType, string)
Returns the SPICE frame from a particular coordinate frame. Based on the coordinate frame, this will return the SPICE frame string.
public static string GetFrameString(CoordinateFrameType frame, string zeroBase)
Parameters
frame
CoordinateFrameTypeA coordinate frame to convert
zeroBase
stringThe zero base of the frame
Returns
- string
The SPICE frame string
GetReferenceFrameRotation(double, string, CoordinateFrameType, CoordinateFrameType)
Returns the rotation between one reference frame and a second reference frame.
public static Vector3 GetReferenceFrameRotation(double time, string zeroBase, CoordinateFrameType fromFrame, CoordinateFrameType toFrame)
Parameters
time
double[s] The J2000 time
zeroBase
stringThe central body zero base of the system
fromFrame
CoordinateFrameTypeThe original frame
toFrame
CoordinateFrameTypeThe new target frame
Returns
- Vector3
The rotation [deg]
GetSpicePlanetDataAtTime(SpicePlanetStateMessage, string, string, string, string, double)
Gets the SPICE planet data at a particular time in J2000 time. This will update the planet state message with the correct position, velocity, and rotation data at a particular time.
public static void GetSpicePlanetDataAtTime(SpicePlanetStateMessage message, string baseFrame, string zeroBase, string name, string frame, double j2000)
Parameters
message
SpicePlanetStateMessageThe planet state message
baseFrame
stringThe base coordinate frame to get the planet data in
zeroBase
stringThe zero-base frame
name
stringThe name of the planet
frame
stringThe frame of the planet
j2000
doubleThe rotation matrix of the J2000 coordinate
GetTime(double, ref double, ref string, ref double, ref double, ref double, ref int, ref int)
Calculates the state of the current time and epoch based on the simulation and returns the time in various formats. This includes the Julian Date, UTC time, TAI time, GPS time, and the GPS time in seconds, rollovers, and weeks.
public static void GetTime(double j2000Time, ref double jDate, ref string utcTime, ref double taiTime, ref double gpsTime, ref double gpsSeconds, ref int gpsRollovers, ref int gpsWeeks)
Parameters
j2000Time
double[s] The current J2000 time in seconds
jDate
double[s] The Julian time of the epoch
utcTime
string[-] The UTC time string
taiTime
double[s] The Atomic time of the epoch
gpsTime
double[s] The GPS time of the epoch
gpsSeconds
double[s] The GPS seconds in the week
gpsRollovers
int[-] The number of rollovers in GPS time
gpsWeeks
int[-] The number of weeks since last rollover
LoadKernels()
Loads all kernels required
public static void LoadKernels()
UnloadKernels()
Unloads all kernels required
public static void UnloadKernels()