Commit 40898dd2 authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Removed GSL and changed natural cubic spline to cubic poly interp (#342)

* Added Lagrange interpolation

* Changed interpolation to lagrange and cleaned up

* Removed using from ale.h

* Removed GSL

* Updated error message
parent 33caa804
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ include(GNUInstallDirs)
set(CMAKE_CXX_STANDARD 11)

# Third Party Dependencies
find_package(GSL           REQUIRED)
find_package(Eigen3 3.3    REQUIRED NO_MODULE)
find_package(nlohmann_json REQUIRED)

@@ -56,8 +55,6 @@ target_include_directories(ale

target_link_libraries(ale
                      PRIVATE
                      GSL::gsl
                      GSL::gslcblas
                      Eigen3::Eigen
                      Python::Python
                      nlohmann_json::nlohmann_json)
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ dependencies:
  - cmake>=3.10
  - pytest
  - eigen
  - gsl
  - jupyter
  - nlohmann_json
  - numpy
+1 −2
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@

#include<vector>
#include <stdexcept>
#include <gsl/gsl_interp.h>
#include <ale.h>

#include "Util.h"
@@ -55,7 +54,7 @@ class States {
   * 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 gsl interpolation will be done.
   * If not, a standard lagrange interpolation will be done.
   *
   * @param time Time to get a value at
   * @param interp Interpolation type to use. Will be ignored if cache is minimized.
+9 −92
Original line number Diff line number Diff line
@@ -4,12 +4,9 @@
#include <string>
#include <vector>

#include <gsl/gsl_interp.h>

#include "InterpUtils.h"

#include <nlohmann/json.hpp>
using json = nlohmann::json;

namespace ale {

@@ -17,13 +14,15 @@ namespace ale {
  enum interpolation {
    /// Interpolate using linear interpolation
    LINEAR = 0,
    /// Interpolate using spline interpolation
    /// Interpolate using a cubic spline
    SPLINE = 1,
    /// Interpolate using Lagrange polynomials up to 8th order
    LAGRANGE = 2,
  };


  // Temporarily moved interpolation and associated helper functions over from States. Will be
  // moved to interpUtils in the future.
  // move to interpUtils in the future.

  /** The following helper functions are used to calculate the reduced states cache and cubic hermite
  to interpolate over it. They were migrated, with minor modifications, from
@@ -37,92 +36,10 @@ namespace ale {
  double evaluateCubicHermiteFirstDeriv(const double interpTime, const std::vector<double>& deriv,
                                       const std::vector<double>& times, const std::vector<double>& y);

  /**
   *@brief Get the position of the spacecraft at a given time based on a set of coordinates, and their associated times
   *@param coords A vector of double vectors of coordinates
   *@param times A double vector of times
   *@param time Time to observe the spacecraft's position at
   *@param interp Interpolation type
   *@return A vector double of the spacecrafts position
   */
  std::vector<double> getPosition(std::vector<std::vector<double>> coords,
                                  std::vector<double> times,
                                  double time, interpolation interp);
  /**
   *@brief Get the velocity of the spacecraft at a given time based on a set of coordinates, and their associated times
   *@param coords A vector of double vectors of coordinates
   *@param times A double vector of times
   *@param time Time to observe the spacecraft's velocity at
   *@param interp Interpolation type
   *@return A vector double of the spacecrafts velocity
   */
  std::vector<double> getVelocity(std::vector<std::vector<double>> coords,
                                  std::vector<double> times,
                                  double time, const interpolation interp);
  /**
   *@brief Get the position of the spacecraft at a given time based on a derived function from a set of coeffcients
   *@param coeffs A vector of double vector of coeffcients
   *@param time Time to observe the spacecraft's position at
   *@return A vector double of the spacecrafts position
   */
  std::vector<double> getPosition(std::vector<std::vector<double>> coeffs, double time);

  /**
   *@brief Get the velocity of the spacecraft at a given time based on a derived function from a set of coeffcients
   *@param coeffs A vector of double vector of coeffcients
   *@param time Time to observe the spacecraft's velocity at
   *@return A vector double of the spacecrafts velocity
   */
  std::vector<double> getVelocity(std::vector<std::vector<double>> coeffs, double time);

  /**
   *@brief Get the rotation of the spacecraft at a given time based on a set of rotations, and their associated times
   *@param rotations A vector of double vector of rotations
   *@param times A double vector of times
   *@param time Time to observe the spacecraft's rotation at
   *@param interp Interpolation type
   *@return A vector double of the spacecrafts rotation
   */
  std::vector<double> getRotation(std::vector<std::vector<double>> rotations,
                                  std::vector<double> times,
                                  double time, interpolation interp);

  /**
   *@brief Get the angular velocity of the spacecraft at a given time based on a set of rotations, and their associated times
   *@param rotations A vector of double vector of rotations
   *@param times A double vector of times
   *@param time Time to observe the spacecraft's angular velocity at
   *@param interp Interpolation type
   *@return A vector double of the spacecrafts angular velocity
   */
  std::vector<double> getAngularVelocity(std::vector<std::vector<double>> rotations,
                                         std::vector<double> times,
                                         double time, interpolation interp);

   /**
    *@brief Get the rotation of the spacecraft at a given time based on a derived function from a set of coeffcients
    *@param coeffs A vector of double vector of coeffcients
    *@param time Time to observe the spacecraft's rotation at
    *@return A vector double of the spacecrafts rotation
    */
  std::vector<double> getRotation(std::vector<std::vector<double>> coeffs, double time);

  /**
   *@brief Get the angular velocity of the spacecraft at a given time based on a derived function from a set of coeffcients
   *@param coeffs A vector of double vector of coeffcients
   *@param time Time to observe the spacecraft's angular velocity at
   *@return A vector double of the spacecrafts angular velocity
   */
  std::vector<double> getAngularVelocity(std::vector<std::vector<double>> coeffs, double time);

  /**
   *@brief Generates a derivatives in respect to time from a polynomial constructed using the given coeffcients, time, and derivation number
   *@param coeffs A double vector of coefficients can be any number of coefficients
   *@param time Time to use when deriving
   *@param d The order of the derivative to generate (Currently supports 0, 1, and 2)
   *@return Evalutation of the given polynomial as a double
   */
  double evaluatePolynomial(std::vector<double> coeffs, double time, int d);
  double lagrangeInterpolate(const std::vector<double>& times, const std::vector<double>& values,
                             double time, int order=8);
  double lagrangeInterpolateDerivative(const std::vector<double>& times, const std::vector<double>& values,
                                       double time, int order=8);

  /**
   *@brief Interpolates the spacecrafts position along a path generated from a set of points,
@@ -138,7 +55,7 @@ namespace ale {
  double interpolate(std::vector<double> points, std::vector<double> times, double time, interpolation interp, int d);
  std::string loads(std::string filename, std::string props="", std::string formatter="usgscsm", bool verbose=true);

  json load(std::string filename, std::string props="", std::string formatter="usgscsm", bool verbose=true);
  nlohmann::json load(std::string filename, std::string props="", std::string formatter="usgscsm", bool verbose=true);


}
+0 −2
Original line number Diff line number Diff line
@@ -26,10 +26,8 @@ requirements:
  build:
  - cmake>=3.10
  - eigen
  - gsl
  run:
  - eigen
  - gsl
  - networkx
  - numpy
  - openblas
Loading