Commit 8bc02d42 authored by Tyler Wilson's avatar Tyler Wilson
Browse files

Corrected the normal calculation for ellipsoidal shapes. Fixes #1028

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@7695 41f8697f-d340-4b68-9986-7bafba869bb8
parent 14d37d23
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ SetImage (sample, line): Yes
NorthAzimuth: 269.544
SunAzimuth: 168.17
SpacecraftAzimuth: 184.591
OffNadirAngle: 44.4225
OffNadirAngle: 44.4012
CelestialNorthClockAngle: 186.19
RaDecResolution: 0.0216226

+30 −2
Original line number Diff line number Diff line
@@ -295,10 +295,38 @@ namespace Isis {
   * This method calculates the default normal (Ellipsoid for backwards
   * compatability) for the DemShape.
   */

  void DemShape::calculateDefaultNormal() {
    calculateEllipsoidalSurfaceNormal();

    if (!surfaceIntersection()->Valid() || !hasIntersection() ) {
      IString msg = "A valid intersection must be defined before computing the surface normal";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    // Get the coordinates of the current surface point
    SpiceDouble pB[3];
    pB[0] = surfaceIntersection()->GetX().kilometers();
    pB[1] = surfaceIntersection()->GetY().kilometers();
    pB[2] = surfaceIntersection()->GetZ().kilometers();

    // Get the radii of the ellipsoid
    vector<Distance> radii = targetRadii();
    double a = radii[0].kilometers();
    double b = radii[1].kilometers();
    double c = radii[2].kilometers();

    vector<double> normal(3,0.);

    NaifStatus::CheckErrors();
    surfnm_c(a, b, c, pB, (SpiceDouble *) &normal[0]);
    NaifStatus::CheckErrors();

    setNormal(normal);
    setHasNormal(true);

  }



  /**
   * Returns the DEM Cube object.
@@ -385,7 +413,7 @@ namespace Isis {
   * point.
   */
  void DemShape::calculateSurfaceNormal() {
    calculateEllipsoidalSurfaceNormal();
    calculateDefaultNormal();
  }


+5 −0
Original line number Diff line number Diff line
@@ -53,6 +53,11 @@ namespace Isis {
   *                           closer to ISIS coding standards. References #1438
   *   @history 2016-06-13 Kelvin Rodriguez - Removed redundant contructor PlaneShape(Target, Pvl).
   *                           References #2214
   *   @history 2017-05-19 Tyler Wilson - calculateDefaultNormal() and calculateSurfaceNormal()
   *                           now return the normal vector to an ellipsoid.  All references
   *                           to ShapeModel::calculateEllipsoidalSurfaceNormal have been
   *                           removed.  References #1028.
   *
   */
  class DemShape : public ShapeModel {
    public:
+2 −2
Original line number Diff line number Diff line
@@ -18,10 +18,10 @@ Begin testing Dem Shape Model class....
    local normal = (-0.58374, -0.701835, 0.408259

  Testing class method calculateSurfaceNormal...
    surface normal = (-0.623384, -0.698838, 0.350738
    surface normal = (-0.62247, -0.697813, 0.354383

  Testing class method calculateDefaultNormal...
    default normal = (-0.623384, -0.698838, 0.350738
    default normal = (-0.62247, -0.697813, 0.354383

  Testing localRadius method with good lat/lon values...
    Local radius = 3406.18
+17 −6
Original line number Diff line number Diff line
#include "EllipsoidShape.h"

#include <QVector>
#include <iomanip>
#include <iostream>

#include <SpiceUsr.h>
#include <SpiceZfc.h>
@@ -53,7 +55,10 @@ namespace Isis {
   *
   */
  void EllipsoidShape::calculateDefaultNormal()  {
    calculateEllipsoidalSurfaceNormal();

    QVector <double *> points;
    calculateLocalNormal(points);
    //calculateEllipsoidalSurfaceNormal();
  }


@@ -61,7 +66,10 @@ namespace Isis {
   *
   */
  void EllipsoidShape::calculateSurfaceNormal()  {
    calculateEllipsoidalSurfaceNormal();

    QVector <double *> points;
    //calculateEllipsoidalSurfaceNormal();
    calculateLocalNormal(points);
  }


@@ -77,8 +85,11 @@ namespace Isis {
  }


  /** Calculate local normal
  /**
   * @brief EllipsoidShape::calculateLocalNormal
   * @param cornerNeighborPoints
   *
   * Calculates the normal vector to an ellipsoid.
   */
  void EllipsoidShape::calculateLocalNormal(QVector<double *> cornerNeighborPoints)  {

@@ -98,8 +109,8 @@ namespace Isis {
    double a = radii[0].kilometers();
    double b = radii[1].kilometers();
    double c = radii[2].kilometers();
    vector<double> normal(3,0.);

    vector<double> normal(3,0.);
    NaifStatus::CheckErrors();
    surfnm_c(a, b, c, pB, (SpiceDouble *) &normal[0]);
    NaifStatus::CheckErrors();
Loading