Commit 9dbd8917 authored by Jesse Mapel's avatar Jesse Mapel
Browse files

PROG: Fixed Bullet and Embree shapemodel unitTests to avoid precision errors.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@7988 41f8697f-d340-4b68-9986-7bafba869bb8
parent ed65f343
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -20,9 +20,9 @@

#include <QDebug>

#include "IException.h"

#include "BulletDskShape.h"
#include "IException.h"
#include "Preference.h"

using namespace Isis;

@@ -31,6 +31,8 @@ using namespace Isis;
 */
int main(int argc, char *argv[]) {
  try {
    Preference::Preferences(true);

    qDebug() << "Testing BulletDskShape";
    qDebug() << endl;

+10 −10
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ Intersection inputs:
Intersecting Embree shape model
Embree shape model status:
Model has intersection?  true
  Surface Point: ( 0.2908 ,  -0.001977 ,  0.0005978 )
  Surface Point: ( 0.2908 ,  -0.0019 ,  0.0005 )
Model has normal?  true
  Surface Normal: ( 0.847198 ,  -0.194495 ,  0.494395 )

@@ -71,7 +71,7 @@ Intersection inputs:
Intersecting Embree shape model
Embree shape model status:
Model has intersection?  true
  Surface Point: ( 0.008773 ,  0.08864 ,  0.08789 )
  Surface Point: ( 0.0087 ,  0.0886 ,  0.0878 )
Model has normal?  true
  Surface Normal: ( -0.04559 ,  0.672259 ,  0.738911 )

@@ -92,7 +92,7 @@ Model has normal? false
Intersecting Embree shape model without occlusion
Embree shape model status:
Model has intersection?  true
  Surface Point: ( 0.02551 ,  -0.1384 ,  -0.000125 )
  Surface Point: ( 0.0255 ,  -0.1383 ,  -0.0001 )
Model has normal?  true
  Surface Normal: ( 0.397582 ,  -0.895341 ,  -0.200733 )

@@ -106,7 +106,7 @@ Intersection inputs:
  Intersecting Embree shape model
Embree shape model status:
Model has intersection?  true
  Surface Point: ( -0.2166 ,  -0.07786 ,  6.623e-05 )
  Surface Point: ( -0.2165 ,  -0.0778 ,  0 )
Model has normal?  true
  Surface Normal: ( -0.73405 ,  -0.654923 ,  0.17957 )

@@ -125,7 +125,7 @@ Model has normal? false
Intersecting Embree shape model without occlusion
Embree shape model status:
Model has intersection?  true
  Surface Point: ( 0.01057 ,  0.06397 ,  -0.065 )
  Surface Point: ( 0.0105 ,  0.0639 ,  -0.065 )
Model has normal?  true
  Surface Normal: ( 0.250858 ,  0.57346 ,  -0.779881 )

@@ -140,7 +140,7 @@ Radius: 0.123904
Checking that shape model status did not change
Embree shape model status:
Model has intersection?  true
  Surface Point: ( 0.01057 ,  0.06397 ,  -0.065 )
  Surface Point: ( 0.0105 ,  0.0639 ,  -0.065 )
Model has normal?  true
  Surface Normal: ( 0.250858 ,  0.57346 ,  -0.779881 )

@@ -150,7 +150,7 @@ Testing visibility check
Intersecting Embree shape model
Embree shape model status:
Model has intersection?  true
  Surface Point: ( 0.2908 ,  -0.001977 ,  0.0005978 )
  Surface Point: ( 0.2908 ,  -0.0019 ,  0.0005 )
Model has normal?  true
  Surface Normal: ( 0.847198 ,  -0.194495 ,  0.494395 )

@@ -165,14 +165,14 @@ Testing default ellipsoid normal
Starting model status
Embree shape model status:
Model has intersection?  true
  Surface Point: ( 0.2908 ,  -0.001977 ,  0.0005978 )
  Surface Point: ( 0.2908 ,  -0.0019 ,  0.0005 )
Model has normal?  true
  Surface Normal: ( 0.847198 ,  -0.194495 ,  0.494395 )

Model status after recalculating
Embree shape model status:
Model has intersection?  true
  Surface Point: ( 0.2908 ,  -0.001977 ,  0.0005978 )
  Surface Point: ( 0.2908 ,  -0.0019 ,  0.0005 )
Model has normal?  true
  Surface Normal: ( 0.999747 ,  -0.0209697 ,  0.00810027 )

@@ -181,7 +181,7 @@ Testing photometric angles

Embree shape model status:
Model has intersection?  true
  Surface Point: ( 0.2908 ,  -0.001977 ,  0.0005978 )
  Surface Point: ( 0.2908 ,  -0.0019 ,  0.0005 )
Model has normal?  true
  Surface Normal: ( 0.999747 ,  -0.0209697 ,  0.00810027 )

+11 −3
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */
#include <cmath>

#include <QDebug>

#include "Angle.h"
@@ -40,6 +42,8 @@ using namespace Isis;

void outputModelStatus(EmbreeShapeModel &embreeModel);

double roundToPrecision(double value, double precision);

/** 
 * Unit test for Embree Ray Tracing Kernels
 *
@@ -331,9 +335,9 @@ void outputModelStatus(EmbreeShapeModel &embreeModel) {
    embreeIntersection = embreeModel.surfaceIntersection();
    qDebug() << qSetRealNumberPrecision(4)
              << "  Surface Point: ("
              << embreeIntersection->GetX().kilometers() << ", "
              << embreeIntersection->GetY().kilometers() << ", "
              << embreeIntersection->GetZ().kilometers() << ")";
              << roundToPrecision(embreeIntersection->GetX().kilometers(), 0.0001) << ", "
              << roundToPrecision(embreeIntersection->GetY().kilometers(), 0.0001) << ", "
              << roundToPrecision(embreeIntersection->GetZ().kilometers(), 0.0001) << ")";
  }
  qDebug() << "Model has normal? " << embreeModel.hasNormal();
  std::vector<double> embreeNormal;
@@ -346,3 +350,7 @@ void outputModelStatus(EmbreeShapeModel &embreeModel) {
  }
  qDebug() << "";
}

double roundToPrecision(double value, double precision) {
  return value - fmod(value, precision);
}
+20 −20
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ Ray Hit Information
Creating ray hit information from intersection, normal, and primitive ID
Ray Hit Information
  Primitive ID:  -10
  Intersection: ( -3.1 , 1.75 , 10.3 )
  Intersection: ( -3.0999 , 1.7499 , 10.3 )
  Surface Normal: ( -3.1 , 1.75 , 10.3 )


@@ -154,11 +154,11 @@ Number of intersections: 2

Intersection 1 information:
  Primitive ID:   36673
  Intersection:   ( 0.291 , -0.00198 , 0.000598 )
  Intersection:   ( 0.2908 , -0.0019 , 0.0005 )
  Surface normal: ( 0.847198 , -0.194495 , 0.494395 )
Intersection 2 information:
  Primitive ID:   20415
  Intersection:   ( -0.248 , -0.00559 , -0.000434 )
  Intersection:   ( -0.248 , -0.0055 , -0.0004 )
  Surface normal: ( -0.956828 , -0.0521767 , 0.285934 )


@@ -172,11 +172,11 @@ Number of intersections: 2

Intersection 1 information:
  Primitive ID:   28608
  Intersection:   ( -0.00319 , 0.12 , 0.000823 )
  Intersection:   ( -0.0031 , 0.1201 , 0.0008 )
  Surface normal: ( 0.342908 , 0.918061 , -0.198944 )
Intersection 2 information:
  Primitive ID:   12223
  Intersection:   ( -0.000281 , -0.143 , -9.91e-06 )
  Intersection:   ( -0.0002 , -0.143 , 0 )
  Surface normal: ( -0.182673 , -0.830412 , 0.526353 )


@@ -190,11 +190,11 @@ Number of intersections: 2

Intersection 1 information:
  Primitive ID:   4160
  Intersection:   ( -6.96e-05 , -0.00227 , 0.123 )
  Intersection:   ( 0 , -0.0022 , 0.1232 )
  Surface normal: ( 0.104179 , -0.0405076 , 0.993733 )
Intersection 2 information:
  Primitive ID:   45120
  Intersection:   ( -0.000154 , 0.00041 , -0.0929 )
  Intersection:   ( -0.0001 , 0.0004 , -0.0928 )
  Surface normal: ( 0.241681 , 0.0950179 , -0.965692 )


@@ -211,11 +211,11 @@ Number of intersections: 2

Intersection 1 information:
  Primitive ID:   38210
  Intersection:   ( 0.277 , 0.0499 , 0.00147 )
  Intersection:   ( 0.2773 , 0.0499 , 0.0014 )
  Surface normal: ( 0.816205 , 0.553018 , 0.167273 )
Intersection 2 information:
  Primitive ID:   19265
  Intersection:   ( -0.252 , 0.0491 , -5.5e-05 )
  Intersection:   ( -0.2517 , 0.049 , 0 )
  Surface normal: ( -0.961791 , -0.214961 , 0.169558 )


@@ -229,11 +229,11 @@ Number of intersections: 2

Intersection 1 information:
  Primitive ID:   28318
  Intersection:   ( 2.69e-05 , 0.117 , 0.0508 )
  Intersection:   ( 0 , 0.117 , 0.0508 )
  Surface normal: ( 0.0742258 , 0.96402 , 0.255258 )
Intersection 2 information:
  Primitive ID:   12316
  Intersection:   ( 0.00106 , -0.118 , 0.0507 )
  Intersection:   ( 0.001 , -0.118 , 0.0507 )
  Surface normal: ( 0.0143037 , -0.865789 , 0.500205 )


@@ -247,11 +247,11 @@ Number of intersections: 2

Intersection 1 information:
  Primitive ID:   5696
  Intersection:   ( 0.0496 , -0.000278 , 0.116 )
  Intersection:   ( 0.0495 , -0.0002 , 0.1157 )
  Surface normal: ( 0.12578 , -0.0974701 , 0.987258 )
Intersection 2 information:
  Primitive ID:   46401
  Intersection:   ( 0.049 , 2.29e-05 , -0.0804 )
  Intersection:   ( 0.049 , 0 , -0.0804 )
  Surface normal: ( 0.21604 , 0.0581458 , -0.974652 )


@@ -268,11 +268,11 @@ Number of intersections: 2

Intersection 1 information:
  Primitive ID:   27463
  Intersection:   ( 0.0489 , 0.1 , -9.83e-05 )
  Intersection:   ( 0.0488 , 0.1 , 0 )
  Surface normal: ( 0.34363 , 0.810661 , -0.474075 )
Intersection 2 information:
  Primitive ID:   24256
  Intersection:   ( -0.166 , -0.117 , 0.00164 )
  Intersection:   ( -0.1658 , -0.1173 , 0.0016 )
  Surface normal: ( -0.338107 , -0.939824 , 0.0491477 )


@@ -286,11 +286,11 @@ Number of intersections: 2

Intersection 1 information:
  Primitive ID:   4248
  Intersection:   ( -0.00278 , 0.0563 , 0.109 )
  Intersection:   ( -0.0027 , 0.0562 , 0.109 )
  Surface normal: ( 0.0953376 , 0.424919 , 0.900197 )
Intersection 2 information:
  Primitive ID:   12525
  Intersection:   ( 0.000594 , -0.112 , -0.062 )
  Intersection:   ( 0.0005 , -0.112 , -0.0619 )
  Surface normal: ( -0.0444398 , -0.514889 , -0.856104 )


@@ -304,11 +304,11 @@ Number of intersections: 2

Intersection 1 information:
  Primitive ID:   36743
  Intersection:   ( 0.151 , -0.000182 , 0.101 )
  Intersection:   ( 0.1512 , -0.0001 , 0.1012 )
  Surface normal: ( 0.428961 , 0.332558 , 0.83988 )
Intersection 2 information:
  Primitive ID:   43584
  Intersection:   ( -0.0527 , -0.000478 , -0.103 )
  Intersection:   ( -0.0526 , -0.0004 , -0.1027 )
  Surface normal: ( 0.0693243 , 0.0789593 , -0.994464 )


@@ -326,7 +326,7 @@ Intersection 1 information:
  Surface normal: ( 0.303069 , 0.626162 , 0.71838 )
Intersection 2 information:
  Primitive ID:   42754
  Intersection:   ( -0.0835 , -0.0822 , -0.0841 )
  Intersection:   ( -0.0834 , -0.0821 , -0.084 )
  Surface normal: ( -0.161737 , -0.39984 , -0.902202 )


+15 −9
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
 *   http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on
 *   http://www.usgs.gov/privacy.html.
 */
#include <cmath>

#include <QDebug>
#include <QVector>

@@ -54,6 +56,8 @@ void outputOcclusion(EmbreeTargetShape &embreeShape,
                     LinearAlgebra::Vector &lookDirection,
                     unsigned ignorePrimID = RTC_INVALID_GEOMETRY_ID);

double roundToPrecision(double value, double precision);

/** 
 * Unit test for Embree Ray Tracing Kernels
 *
@@ -313,11 +317,10 @@ void outputIntersection(EmbreeTargetShape &embreeShape,
    RayHitInformation intersectionInfo = embreeShape.getHitInformation(ray, i);
    qDebug() << "Intersection" << (i + 1) << "information:";
    qDebug() << "  Primitive ID:  " << intersectionInfo.primID;
    qDebug() << qSetRealNumberPrecision(3)
            << "  Intersection:   ("
            << intersectionInfo.intersection[0] << ","
            << intersectionInfo.intersection[1] << ","
            << intersectionInfo.intersection[2] << ")";
    qDebug() << "  Intersection:   ("
            << roundToPrecision(intersectionInfo.intersection[0], 0.0001) << ","
            << roundToPrecision(intersectionInfo.intersection[1], 0.0001) << ","
            << roundToPrecision(intersectionInfo.intersection[2], 0.0001) << ")";
    qDebug() << "  Surface normal: ("
            << intersectionInfo.surfaceNormal[0] << ","
            << intersectionInfo.surfaceNormal[1] << ","
@@ -385,11 +388,14 @@ void outputOcclusionRay(RTCOcclusionRay &ray) {
void outputRayHitInformation(RayHitInformation &hit) {
  qDebug() << "Ray Hit Information";
  qDebug() << "  Primitive ID: " << hit.primID;
  qDebug() << qSetRealNumberPrecision(3)
           << "  Intersection: (" << hit.intersection[0] << ","
                                  << hit.intersection[1] << "," 
                                  << hit.intersection[2] << ")";
  qDebug() << "  Intersection: (" << roundToPrecision(hit.intersection[0], 0.0001) << ","
                                  << roundToPrecision(hit.intersection[1], 0.0001) << "," 
                                  << roundToPrecision(hit.intersection[2], 0.0001) << ")";
  qDebug() << "  Surface Normal: (" << hit.intersection[0] << ","
                                    << hit.intersection[1] << "," 
                                    << hit.intersection[2] << ")";
}

double roundToPrecision(double value, double precision) {
  return value - fmod(value, precision);
}
 No newline at end of file