Commit 5152770e authored by Marjorie Hahn's avatar Marjorie Hahn
Browse files

Added a new signature for Evalute() in BasisFunction. Updated...

Added a new signature for Evalute() in BasisFunction. Updated LineScanCameraRotation, PixelOffset, SpicePosition, and SpiceRotation to utilize the new signature. Fixes #1679

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@6788 41f8697f-d340-4b68-9986-7bafba869bb8
parent 806ba31d
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -214,18 +214,17 @@ namespace Isis {

    double CI[3][3];
    double IJ[3][3];
    std::vector<double> rtime;
    double rtime;
    SpiceRotation *prot = p_spi->bodyRotation();
    std::vector<double> CJ;
    CJ.resize(9);

    for(std::vector<double>::size_type pos = 0; pos < p_cacheTime.size(); pos++) {
      double et = p_cacheTime.at(pos);
      rtime.push_back((et - GetBaseTime()) / GetTimeScale());
      rtime = (et - GetBaseTime()) / GetTimeScale();
      double angle1 = function1.Evaluate(rtime);
      double angle2 = function2.Evaluate(rtime);
      double angle3 = function3.Evaluate(rtime);
      rtime.clear();

// Get the first angle back into the range Naif expects [180.,180.]
      if(angle1 < -1 * pi_c()) {
+2 −2
Original line number Diff line number Diff line
@@ -290,8 +290,8 @@ namespace Isis {
    function2.SetCoefficients(p_ang2Coefficients);

    // Compute polynomial approximations to angles, pangle1 and pangle2
    std::vector<double> rtime;
    rtime.push_back((et - p_baseTime) / p_timeScale);
    double rtime;
    rtime = (et - p_baseTime) / p_timeScale;
    double pangle1 = p_sampOff + p_sampScale * function1.Evaluate(rtime);
    double pangle2 = p_lineOff + p_lineScale * function2.Evaluate(rtime);

+25 −0
Original line number Diff line number Diff line
@@ -43,26 +43,31 @@ namespace Isis {
   * has three coefficients: C1, C2 & C3.
   */
  BasisFunction::BasisFunction(const QString &name, int numVars, int numCoefs) {
    
    p_name = name;
    p_numVars = numVars;
    p_numCoefs = numCoefs;
  }

  
  /**
   * Set the coefficients for the equation.
   *
   * @param coefs A vector of coefficients for the equation.
   */
  void BasisFunction::SetCoefficients(const std::vector<double> &coefs) {
    
    if ( (int)coefs.size() != p_numCoefs ) {
      QString msg = "Unable to set coefficients vector. The size of the given vector [" 
                    + toString((int)coefs.size()) + "] does not match number of coefficients "
                    "in the basis equation [" + toString(p_numCoefs) + "]";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
    
    p_coefs = coefs;
  }

  
  /**
   * Compute the equation using the input variables.
   *
@@ -73,6 +78,7 @@ namespace Isis {
   * @return The output value.
   */
  double BasisFunction::Evaluate(const std::vector<double> &vars) {
    
    if ( (int)vars.size() != p_numVars ) {
      QString msg = "Unable to evaluate function for the given vector of values. "
                    "The size of the given vector [" 
@@ -82,6 +88,7 @@ namespace Isis {
    }

    Expand(vars);
    
    if ( (int)p_terms.size() != p_numCoefs ) {
      QString msg = "Unable to evaluate function for the given vector of values. "
                    "The number of terms in the expansion [" 
@@ -91,12 +98,30 @@ namespace Isis {
    }

    double result = 0.0;
    
    for (int i = 0; i < p_numCoefs; i++) {
      result += p_coefs[i] * p_terms[i];
    }
    
    return result;
  }
  
  
  /**
   * Compute the equation using the input variable.
   *
   * @param var A single double value to use for the equation.
   *
   * @return The output double value resulting from the equation.
   */
  double BasisFunction::Evaluate(const double &var) {
    
    std::vector<double> vars;
    vars.push_back(var);
    return BasisFunction::Evaluate(vars);
  }

  
  /**
   * This is the function you should replace depending on your needs. It will
   * expand the variables into the terms of the equation. For example,
+3 −0
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@ namespace Isis {
   *   @todo Add coded example
   *   @history 2005-03-16 Leah Dahmer - modified file to support Doxygen documentation.
   *   @history 2015-02-20 Jeannie Backer - Improved error messages.
   *   @history 2016-06-10 Marjorie Hahn - Added new signature for Evaluate() that only takes in a 
   *                           single value. Fixes #1679
   * 
   */
  class BasisFunction {
@@ -67,6 +69,7 @@ namespace Isis {

      void SetCoefficients(const std::vector<double> &coefs);
      double Evaluate(const std::vector<double> &vars);
      double Evaluate(const double &var);
      virtual void Expand(const std::vector<double> &vars);

      /**
+7 −0
Original line number Diff line number Diff line
@@ -11,3 +11,10 @@ Vars = 2
-0.5
1
2
---
Name   = Basis1
Ncoefs = 1
Vars   = 1
5
---
10
Loading