states — ALE States Classes & Functions

namespace ale
struct State
#include <States.h>

A state vector with position and velocity

Public Functions

inline State(const std::vector<double> &vec)
inline State(Vec3d position)
inline State(Vec3d position, Vec3d velocity)
inline State()
inline bool hasVelocity() const

Public Members

Vec3d position
Vec3d velocity
class States
#include <States.h>

Public Functions

States()

Creates an empty States object

States(const std::vector<double> &ephemTimes, const std::vector<Vec3d> &positions, int refFrame = 1)

Creates a States object from a set of times and positions

States(const std::vector<double> &ephemTimes, const std::vector<std::vector<double>> &positions, int refFrame = 1)

Creates a States object from a set of times and positions

States(const std::vector<double> &ephemTimes, const std::vector<Vec3d> &positions, const std::vector<Vec3d> &velocities, int refFrame = 1)

Creates a States object from a set of times, positions, and velocities

States(const std::vector<double> &ephemTimes, const std::vector<State> &states, int refFrame = 1)

Creates a States object from a set of times, states

~States()
std::vector<State> getStates() const

Returns state vectors (6-element positions&velocities)

std::vector<Vec3d> getPositions() const

Returns the current positions.

std::vector<Vec3d> getVelocities() const

Returns the current velocities.

std::vector<double> getTimes() const

Returns the current times.

int getReferenceFrame() const

Returns reference frame as NAIF ID.

bool hasVelocity() const

Returns true if any velocities have been provided.

State getState(double time, PositionInterpolation interp = LINEAR) const

Returns a single state by interpolating state. If the Cache has been minimized, a cubic hermite is used to interpolate the position and velocity over the reduced cache. If not, a standard lagrange interpolation will be done.

Parameters:
  • time – Time to get a value at

  • interp – Interpolation type to use. Will be ignored if cache is minimized.

Returns:

The interpolated state

Vec3d getPosition(double time, PositionInterpolation interp = LINEAR) const

Gets a position at a single time. Operates the same way as getState()

Vec3d getVelocity(double time, PositionInterpolation interp = LINEAR) const

Gets a velocity at a single time. Operates the same way as getState()

double getStartTime()

Returns the first ephemeris time

double getStopTime()

Returns the last ephemeris time

States minimizeCache(double tolerance = 0.01)

Perform a cache reduction. After running this, getStates(), getPositions(), and getVelocities() will return vectors of reduced size, and getState(), getPosition(), and getVelocity() will returns values interpolated over the reduced cache using a cubic hermite spline

Adapted from Isis::SpicePosition::reduceCache().

Parameters:

tolerance – Maximum error between hermite approximation and original value.

Returns:

A new set of states that has been downsized.

Private Functions

std::vector<int> hermiteIndices(double tolerance, std::vector<int> indexList, double baseTime, double timeScale)

Calculates the points (indicies) which need to be kept for the hermite spline to interpolate between to mantain a maximum error of tolerance.

Adapted from Isis::SpicePosition::HermiteIndices.

Parameters:
  • tolerance – Maximum error between hermite approximation and original value.

  • indexList – The list of indicies that need to be kept.

  • baseTime – Scaled base time for fit

  • timeScale – Time scale for fit.

Returns:

The indices that should be kept to downsize the set of States

Private Members

std::vector<State> m_states

The internal states cache.

std::vector<double> m_ephemTimes

The times for the states cache.

int m_refFrame

Naif ID for the reference frame the states are in.