Unverified Commit acf88f5e authored by Stuart Sides's avatar Stuart Sides Committed by GitHub
Browse files

Added intersectSurface to NaifDskShape so the intercept point would b… (#4997)



* Added intersectSurface to NaifDskShape so the intercept point would be calculated correctly

* Called correct function

* Fixed changelog

Co-authored-by: default avatarJesse Mapel <jam826@nau.edu>
parent 5e3f64f2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ release.
- Fixed CNetCombinePt logging functionality such that only merged points are included in the log. [#4973](https://github.com/USGS-Astrogeology/ISIS3/issues/4973)
- Removed SpkCenterId functions in Cassini camera models due to spkwriter writing positions of Cassini relative to Titan but labeling
it in the kernel as the position relative to the Saturn Barycenter. [#4942](https://github.com/USGS-Astrogeology/ISIS3/issues/4942)
- Corrected issue where footprintinit would fail with a segmentation error. [4943](https://github.com/USGS-Astrogeology/ISIS3/issues/4943)


## [7.0.0] - 2022-02-11
+39 −2
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ namespace Isis {
    setName("DSK");
  }


  /**
   * @brief Constructor provided for instantiation from an ISIS cube
   *
@@ -85,6 +86,7 @@ namespace Isis {

  }


  /**
   * @brief Constructor for creating new shape model from the same DSK file
   *
@@ -144,6 +146,37 @@ namespace Isis {
    return ( success );
  }


  /**
  * @brief Compute surface intersection with optional occlusion check
  *
  * This method sets the surface point at the given latitude, longitude. The
  * derived model is called to get the radius at that location to complete the
  * accuracy of the surface point, them the derived method is called to complete
  * the intersection.
  *
  * @author 2022-07-14 Stuart Sides, Jesse Mapel
  *
  * @param surfpt       Absolute point on the surface to check
  * @param observerPos  Position of the observer
  * @param backCheck    Flag to indicate occlusion check
  *
  * @return bool        True if the intersection point is valid (visable)
  */
  bool NaifDskShape::intersectSurface(const SurfacePoint &surfpt,
                                    const std::vector<double> &observerPos,
                                    const bool &backCheck) {

    std::vector<double> look(3);
    look[0] = surfpt.GetX().kilometers() - observerPos[0];
    look[1] = surfpt.GetY().kilometers() - observerPos[1];
    look[2] = surfpt.GetZ().kilometers() - observerPos[2];

    return intersectSurface(observerPos, look);

  }


  /**
   * @brief Determine DEM radius at a given lat/lon grid point
   *
@@ -167,6 +200,7 @@ namespace Isis {
    return (Distance());
  }


  /**
   * @brief Set the normal vector to the intercept point normal
   *
@@ -229,7 +263,6 @@ namespace Isis {
   * @param neighborPoints Input body-fixed points to compute normal for
   */
  void NaifDskShape::calculateLocalNormal(QVector<double *> neighborPoints) {

    // Sanity check
    if ( !hasIntersection() ) { // hasIntersection()  <==>  !m_intercept.isNull()
      QString mess = "Intercept point does not exist - cannot provide normal vector";
@@ -247,6 +280,7 @@ namespace Isis {
     calculateSurfaceNormal();
  }


  /** Return the surface normal of the ellipsi=oud */
  void NaifDskShape::calculateSurfaceNormal() {
    // ShapeModel (parent class) throws error if no intersection
@@ -254,6 +288,7 @@ namespace Isis {
    return;
  }


  /**
   * @brief Compute the true surface normal vector of an ellipsoid
   *
@@ -300,11 +335,13 @@ namespace Isis {
    return (norm);
  }


  /** Returns a direct reference to the DSK plate model file interface */
  const NaifDskPlateModel &NaifDskShape::model() const {
    return (m_model);
  }


  /**
   * @brief Returns a pointer to the current intercept
   *
+5 −0
Original line number Diff line number Diff line
@@ -56,6 +56,10 @@ namespace Isis {
      bool intersectSurface(std::vector<double> observerPos,
                            std::vector<double> lookDirection);

      bool intersectSurface(const SurfacePoint &surfpt,
                            const std::vector<double> &observerPos,
                            const bool &backCheck=true);

      // Calculate the default normal of the current intersection point
      void calculateDefaultNormal();

@@ -73,6 +77,7 @@ namespace Isis {
      const NaifDskPlateModel &model() const;
      const Intercept *intercept() const;


    private:
      // Disallow copying because ShapeModel is not copyable
      NaifDskShape(const NaifDskShape &model);
+5 −1
Original line number Diff line number Diff line
@@ -11,6 +11,11 @@ Intersection successful? "No"
Construct NaifDskShape object from cube labels with ShapeModel=DSK file.
Try to intersect surface at obsPos (0,0,1000) and lookDir (0,-1,-1)
Intersection successful?      "No"
Try to intersect surface at obsPos (1000,0,0) and lookDir (-1,0,0)
Intercept X =  0.28911
Intercept Y =  0
Intercept Z =  0
Intersection successful?      "Yes"

Construct NaifDskShape object from cube labels with ElevationModel=DSK file.
Try to intersect surface at obsPos (1000,0,0) and lookDir (-1,0,0)
@@ -49,7 +54,6 @@ Construct NaifDskShape object from cube labels with ShapeModel=Null.
**USER ERROR** NAIF DSK file [Null] does not exist.

Thrown by setLocalNormalFromIntercept() - Failed to find intercept. 
**PROGRAMMER ERROR** Intercept point does not exist - cannot provide normal vector.

Thrown by calculateLocalNormal() - Failed to find intercept for normal vector. 
**PROGRAMMER ERROR** Intercept point does not exist - cannot provide normal vector.
+16 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ find files of those names at the top level of this repository. **/

#include "Angle.h"
#include "Cube.h"
#include "Displacement.h"
#include "Distance.h"
#include "FileName.h"
#include "IException.h"
@@ -80,6 +81,21 @@ int main(int argc, char *argv[]) {
    success = shapeModelFromPvlShape.intersectSurface(obsPos, lookDir);
    qDebug() << "Intersection successful?     " << toString(success);

    qDebug() << "Try to intersect surface at obsPos (1000,0,0) and ground point (1,0,0)";
    Displacement x(1.0, Displacement::Meters);
    Displacement y(0.0, Displacement::Meters);
    Displacement z(0.0, Displacement::Meters);
    SurfacePoint SurfPt(x, y, z);
    obsPos[0]  = 1000.0;  obsPos[1]  = 0.0;   obsPos[2]  = 0.0;
    success = shapeModelFromPvlShape.intersectSurface(SurfPt, obsPos);
    if (success) {
      SurfacePoint *point = shapeModelFromPvlShape.surfaceIntersection();
      qDebug() << "Intercept X = " << point->DisplacementToDouble(point->GetX(), SurfacePoint::Kilometers);
      qDebug() << "Intercept Y = " << point->DisplacementToDouble(point->GetY(), SurfacePoint::Kilometers);
      qDebug() << "Intercept Z = " << point->DisplacementToDouble(point->GetZ(), SurfacePoint::Kilometers);
    }
    qDebug() << "Intersection successful?     " << toString(success);

    qDebug() << "";
    qDebug() << "Construct NaifDskShape object from cube labels with ElevationModel=DSK file.";    
    Pvl pvlWithElevation("./st_2530292409_v_DskElevationModel.lbl");
@@ -161,7 +177,6 @@ int main(int argc, char *argv[]) {
             << QVector<double>::fromStdVector(shapeModelFromPvlElevation.normal());
    qDebug() << "";


    qDebug() << "================================= Error Throws ==================================";
    qDebug() << "Construct NaifDskShape object from cube labels with ShapeModel=Null.";    
    try {