Commit f0a7209b authored by Tyler Wilson's avatar Tyler Wilson
Browse files

PROG: Updated documentation and truth data for EllipsoidShapeClass. References #1028

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@7698 41f8697f-d340-4b68-9986-7bafba869bb8
parent ee627387
Loading
Loading
Loading
Loading
+17 −9
Original line number Diff line number Diff line
#include "EllipsoidShape.h"

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


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

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


@@ -66,9 +63,7 @@ namespace Isis {
   *
   */
  void EllipsoidShape::calculateSurfaceNormal()  {

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

@@ -86,10 +81,23 @@ namespace Isis {


  /**
   * @brief EllipsoidShape::calculateLocalNormal
   * @param cornerNeighborPoints
   * Calculates the unit normal to an ellipsoid at the point of intersection.  
   * In the event that the three axial radii of the body are equal, this 
   * method returns the normal vector for a sphere.
   *
   * The implicit equation for an ellipsoid is:
   * U(x,y,z) = x^2/a^2 + y^2/b^2 + z^2/c^2 -1 =0
   *
   *
   * Calculates the normal vector to an ellipsoid.
   * The normal to U(x,y,z) is given by:
   *
   *  n = grad(U)/norm(U)
   *
   * i.e. as:
   *
   * n = <ux,uy,uz>/sqrt(ux^2,+uy^2+uz^2)
   *
   * @param cornerNeighborPoints
   */
  void EllipsoidShape::calculateLocalNormal(QVector<double *> cornerNeighborPoints)  {

+7 −6
Original line number Diff line number Diff line
Radii=[3396.19,3396.19,3376.2]
Begin testing Ellipsoid Shape Model class....

  Testing constructors...
@@ -16,23 +17,23 @@ Testing method intersectSurface...
    Do we have an intersection? 0
   Set a pixel in the image and check again.
    Do we have an intersection? 1
     surface point = (-2105.83, -2380.77, 1189.41
     surface point = (-2105.830811, -2380.77411, 1189.409824)

  Testing class method calculateLocalNormal...
    local normal = (-0.6196, -0.700497, 0.354117
    local normal = (-0.6196003462, -0.7004971413, 0.3541174467

  Testing class method calculateSurfaceNormal...
    surface normal = (-0.6196, -0.700497, 0.354117
    surface normal = (-0.6196003462, -0.7004971413, 0.3541174467

  Testing class method calculateDefaultNormal...
    default normal = (-0.6196, -0.700497, 0.354117
    default normal = (-0.6196003462, -0.7004971413, 0.3541174467

  Testing localRadius method ...
    Local radius = 3393.71
    Local radius = 3393.711719

  Testing setHasIntersection method
    Do we have an intersection? 0

  Testing setSurfacePoint method ...
     Do we have an intersection? 1
     surface point = (-2105.83, -2380.77, 1189.41
     surface point = (-2105.830811, -2380.77411, 1189.409824
+21 −13
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
 *   and related material nor shall the fact of distribution constitute any such
 *   warranty, and no responsibility is assumed by the USGS in connection
 *   therewith.
 *
 *i
 *   For additional information, launch
 *   $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see
 *   the Privacy &amp; Disclaimers page on the Isis website,
@@ -26,6 +26,7 @@
#include "Camera.h"
#include "CameraFactory.h"
#include "Cube.h"
#include "Distance.h"
#include "EllipsoidShape.h"
#include "IException.h"
#include "Latitude.h"
@@ -51,12 +52,19 @@ using namespace Isis;
  */
int main() {
  try {





    Preference::Preferences(true);
    QString inputFile = "$mgs/testData/ab102401.cub";
    Cube cube;
    cube.open(inputFile);
    Camera *c = cube.camera();
    std::vector<Distance> radii = c->target()->radii();
    vector<Distance> radii = c->target()->radii();
    cout <<  setprecision(10)<< "Radii=["<<radii[0].kilometers() << ","
          <<radii[1].kilometers() << "," << radii[2].kilometers() << "]" << endl;
    Pvl &pvl = *cube.label();
    Spice spi(cube);
    Target targ(&spi, pvl);
@@ -102,14 +110,7 @@ int main() {
    std::vector<double> uB(3);
    c->sunPosition((double *) &uB[0]);
    c->SpacecraftSurfaceVector((double *) &lookB[0]);
    /*
  Sample/Line = 534/453
  surface normal = -0.623384, -0.698838, 0.350738
  Local normal = -0.581842, -0.703663, 0.407823
    Phase                      = 40.787328112158
    Incidence                  = 85.341094499768
    Emission                   = 46.966269013795
    */

    if (!shape.intersectSurface(sB, lookB)) {
        cout << "    ...  intersectSurface method failed" << endl;
        return -1;
@@ -117,7 +118,7 @@ int main() {
    cout << "    Do we have an intersection? " << shape.hasIntersection() << endl;
    SurfacePoint *sp = shape.surfaceIntersection();
    cout << "     surface point = (" << sp->GetX().kilometers() << ", " <<
      sp->GetY().kilometers() << ", " << sp->GetZ().kilometers() << endl;
      sp->GetY().kilometers() << ", " << sp->GetZ().kilometers() << ")" << endl;

    cout << endl << "  Testing class method calculateLocalNormal..." << endl;
    QVector<double *>  notUsed(4);
@@ -128,11 +129,18 @@ int main() {
    shape.calculateLocalNormal(notUsed);
    vector<double> myNormal(3);
    myNormal = shape.normal();

    //Hand-calculated truth value:  [-0.6196003462957385, -0.7004971412244801, 0.3541174466282787]


    cout << "    local normal = (" << myNormal[0] << ", " << myNormal[1] << ", " << myNormal[2] << endl;

    cout << endl << "  Testing class method calculateSurfaceNormal..." << endl;
    shape.calculateSurfaceNormal();
    myNormal = shape.normal();



    cout << "    surface normal = (" << myNormal[0] << ", " << myNormal[1] << ", " << myNormal[2] << endl;

    cout << endl << "  Testing class method calculateDefaultNormal..." << endl;
@@ -143,7 +151,7 @@ int main() {
    cout << endl << "  Testing localRadius method ..." << endl;
    cout  << "    Local radius = " << shape.localRadius(Latitude(20.532461495381, Angle::Degrees),
                                                    Longitude(228.26609149754, Angle::Degrees)).kilometers() << endl;
    // Mars radii = 3397.      3397.         3375.


    cout << endl << "  Testing setHasIntersection method" << endl;
    shape.setHasIntersection(false);