Exemplo n.º 1
0
 QMatrix4x4 EulerAngles::matrix(Angle _yaw, Angle _pitch, Angle _roll)
 {
   QMatrix4x4 _matrix;
   // Rotate ZYX
   _matrix.rotate(_yaw.degrees(),QVector3D(0.0,0.0,1.0));
   _matrix.rotate(_pitch.degrees(),QVector3D(0.0,1.0,0.0));
   _matrix.rotate(_roll.degrees(),QVector3D(1.0,0.0,0.0));
   return _matrix;
 }
void	HipparcosTest::testWindow() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testWindow() begin");
	RaDec	center(0, 0);
	center.ra().hours(6.75247702777777777777);
	center.dec().degrees(-16.71611583333333333333);
	Angle	width; width.hours(1);
	Angle	height; height.degrees(15);
	SkyWindow	window(center, width, height);
	Catalog::starsetptr	stars = catalog->find(window,
					MagnitudeRange(-30, 4.5));
	debug(LOG_DEBUG, DEBUG_LOG, 0, "%d stars", stars->size());
	CPPUNIT_ASSERT(stars->size() == 10);
	Catalog::starset::const_iterator	s;
	for (s = stars->begin(); s != stars->end(); s++) {
		debug(LOG_DEBUG, DEBUG_LOG, 0, "%s", s->toString().c_str());
	}
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testWindow() end");
}
Exemplo n.º 3
0
void AngleTest::testAngle()
{
	Angle a = Angle::fromDegrees(0);
	assert (a.degrees() == 0);
	assert (a.radians() == 0);

	a = Angle::fromDegrees(90);
	assert (a.degrees() == 90);
	assertEqualDelta (Angle::PI/2, a.radians(), 0.01);

	a = Angle::fromDegrees(180);
	assert (a.degrees() == 180);
	assertEqualDelta (Angle::PI, a.radians(), 0.01);
	
	a = Angle::fromDegrees(360);
	assert (a.normalized().degrees() == 0);

	a = Angle::fromDegrees(-10);
	assert (a.normalized().degrees() == 350);

	a = Angle::fromDegrees(370);
	assert (a.normalized().degrees() == 10);

	a = Angle::fromDegrees(40);
	assert (a.normalizedLatitude().degrees() == 40);

	a = Angle::fromDegrees(90);
	assert (a.normalizedLatitude().degrees() == 90);

	a = Angle::fromDegrees(100);
	assert (a.normalizedLatitude().degrees() == 80);

	a = Angle::fromDegrees(100);
	assert (a.normalizedLongitude().degrees() == 100);

	a = Angle::fromDegrees(180);
	assert (a.normalizedLongitude().degrees() == 180);

	a = Angle::fromDegrees(190);
	assert (a.normalizedLongitude().degrees() == -170);
	
	a = Angle::fromDegrees(10);
	a = a + Angle::fromDegrees(10);
	assert (a.degrees() == 20);
	
	a = a - Angle::fromDegrees(10);
	assert (a.degrees() == 10);
	
	a = a*2;
	assert (a.degrees() == 20);
}
void	HipparcosTest::testWindowIterator() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testWindowIterator() begin");
	RaDec	center(0, 0);
	center.ra().hours(6.75247702777777777777);
	center.dec().degrees(-16.71611583333333333333);
	Angle	width; width.hours(1);
	Angle	height; height.degrees(15);
	SkyWindow	window(center, width, height);
	CatalogIterator	i = catalog->findIter(window,
					MagnitudeRange(-30, 4.5));
	unsigned long long	counter = 0;
	for (; !i.isEnd(); ++i) {
		counter++;
		Star	s = *i;
		debug(LOG_DEBUG, DEBUG_LOG, 0, "%s", s.toString().c_str());
	}
	CPPUNIT_ASSERT(counter == 10);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testWindowIterator() end");
}
Exemplo n.º 5
0
int Car::steering_for_curvature(Angle theta_per_meter) {
  static const LookupTable t(
  {
    {-85.1, 1929},
    {-71.9, 1839},
    {-58.2, 1794},
    {-44.1,1759},
    {-29.6, 1678},
    {-14.8, 1599},
    {0, 1521},
    {14.8, 1461},
    {29.6,1339},
    {44.0,1306},
    {58.2,1260},
    {71.9,1175},
    {85.1,1071}

  });
  return (int) t.lookup(theta_per_meter.degrees());
}
Exemplo n.º 6
0
int Car::steering_for_angle(Angle theta)
{
  static const LookupTable t(
  {
    {-30, 1929},
    {-25, 1839},
    {-20, 1794},
    {-15,1759},
    {-10, 1678},
    {-5, 1599},
    {0, 1521},
    {5, 1461},
    {10,1339},
    {15,1306},
    {20,1260},
    {25,1175},
    {30,1071}

  });
  return (int) t.lookup(theta.degrees());
}
Exemplo n.º 7
0
//  Computes all the geometric properties for the output buffer.  Certain
//  knowledge of the buffers size is assumed below, so ensure the buffer
//  is still of the expected size.
void phocube(Buffer &out) {


  // If the DN option is selected, it is already added by the phocubeDN
  // function.  We must compute the offset to start at the second band.
  int skipDN = (dn) ? 64 * 64   :  0;

  for(int i = 0; i < 64; i++) {
    for(int j = 0; j < 64; j++) {

      MosData mosd, *p_mosd(0);  // For special mosaic angles

      int index = i * 64 + j + skipDN;
      double samp = out.Sample(index);
      double line = out.Line(index);
      if (noCamera) {
        proj->SetWorld(samp, line);
      }
      else {
        cam->SetImage(samp, line);
      }

      bool isGood=false;
      if (noCamera) {
        if (proj->IsGood()) {
          isGood = true;
        }
      }
      else {
        if (cam->HasSurfaceIntersection()) {
          isGood = true;
        }
      }
      if (isGood) {
        if(phase) {
          out[index] = cam->PhaseAngle();
          index += 64 * 64;
        }
        if(emission) {
          out[index] = cam->EmissionAngle();
          index += 64 * 64;
        }
        if(incidence) {
          out[index] = cam->IncidenceAngle();
          index += 64 * 64;
        }
        if(localEmission || localIncidence) {
          Angle phase;
          Angle incidence;
          Angle emission;
          bool success;
          cam->LocalPhotometricAngles(phase, incidence, emission, success);

          if (localEmission) {
            out[index] = emission.degrees();
            index += 64 * 64;
          }

          if (localIncidence) {
            out[index] = incidence.degrees();
            index += 64 * 64;
          }
        }
        if(latitude) {
          if(noCamera) {
            out[index] = proj->UniversalLatitude();
          }
          else {
            out[index] = cam->UniversalLatitude();
          }
          index += 64 * 64;
        }
        if(longitude) {
          if(noCamera) {
            out[index] = proj->UniversalLongitude();
          }
          else {
            out[index] = cam->UniversalLongitude();
          }
          index += 64 * 64;
        }
        if(pixelResolution) {
          if(noCamera) {
            out[index] = proj->Resolution();
          }
          else {
            out[index] = cam->PixelResolution();
          }
          index += 64 * 64;
        }
        if(lineResolution) {
          out[index] = cam->LineResolution();
          index += 64 * 64;
        }
        if(sampleResolution) {
          out[index] = cam->SampleResolution();
          index += 64 * 64;
        }
        if(detectorResolution) {
          out[index] = cam->DetectorResolution();
          index += 64 * 64;
        }
        if(northAzimuth) {
          out[index] = cam->NorthAzimuth();
          index += 64 * 64;
        }
        if(sunAzimuth) {
          out[index] = cam->SunAzimuth();
          index += 64 * 64;
        }
        if(spacecraftAzimuth) {
          out[index] = cam->SpacecraftAzimuth();
          index += 64 * 64;
        }
        if(offnadirAngle) {
          out[index] = cam->OffNadirAngle();
          index += 64 * 64;
        }
        if(subSpacecraftGroundAzimuth) {
          double ssplat, ssplon;
          ssplat = ssplon = 0.0;
          cam->subSpacecraftPoint(ssplat, ssplon);
          out[index] = cam->GroundAzimuth(cam->UniversalLatitude(),
              cam->UniversalLongitude(), ssplat, ssplon);
          index += 64 * 64;
        }
        if(subSolarGroundAzimuth) {
          double sslat, sslon;
          sslat = sslon = 0.0;
          cam->subSolarPoint(sslat,sslon);
          out[index] = cam->GroundAzimuth(cam->UniversalLatitude(),
              cam->UniversalLongitude(), sslat, sslon);
          index += 64 * 64;
        }

        // Special Mosaic indexes
        if (morphology) {
          if (!p_mosd) { p_mosd = getMosaicIndicies(*cam, mosd); }
          out[index] = mosd.m_morph;
          index += 64 * 64;
        }

        if (albedo) {
          if (!p_mosd) { p_mosd = getMosaicIndicies(*cam, mosd); }
          out[index] = mosd.m_albedo;
          index += 64 * 64;
        }

      }
      // Trim outerspace
      else {
        for(int b = (skipDN) ? 1 : 0; b < nbands; b++) {
          out[index] = Isis::NULL8;
          index += 64 * 64;
        }
      }
    }
  }
}
Angle	Angle::dms_to_angle(const std::string& dms) {
	Angle	result;
	result.degrees(angle_parser(dms).value());
	return result;
}
Exemplo n.º 9
0
void LatLon::lon(const Angle& val){
    x = val.degrees();
}
Exemplo n.º 10
0
void LatLon::lat(const Angle& val){
    y = val.degrees();
}
Exemplo n.º 11
0
            ThrowRatio(Angle _angle) {
                proj::Projector _proj;
                _proj.setFov(_angle);
                qDebug() << "FOV: " << _angle.degrees() << "\t ThrowRatio: " << _proj.throwRatio();

            }
Exemplo n.º 12
0
void RenderObject::rotate(const Angle& rotation, const Vector& axis)
{

    Vector rotation_vect = axis * Vector(rotation.degrees(), rotation.degrees(), rotation.degrees()); //Get a rotation vector with rotaton on the specified axis
    rotate(rotation_vect);
}
Exemplo n.º 13
0
int main(int argc, char *argv[]) {
  Isis::Preference::Preferences(true);
  cerr << setprecision(9);

  cerr << "UnitTest for Angle" << endl << endl;
  cerr << "Testing constructors" << endl;

  try {
    Angle angle;
    cerr << "  Default constructor - valid?:  " << angle.isValid() <<
      " values: " << angle.radians() << " and " << angle.degrees() <<
      endl;
    cerr << "  " << angle.toString() << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle(Isis::Null, Angle::Degrees);
    cerr << "  Null input and degree output:  " << angle.degrees() <<
      " degrees" <<endl;
    cerr << "  Valid? " << angle.isValid() << endl;
    cerr << "  " << angle.toString() << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle(30., Angle::Degrees );
    cerr << "  Degree input and radian output:  " << angle.radians() <<
      " radians" << endl;
    cerr << "  Valid? " << angle.isValid() << endl;
    cerr << "  " << angle.toString() << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle(30. * PI / 180., Angle::Radians );
    cerr << "  Radian input and degree output:  " << angle.degrees() <<
      " degrees" <<endl;
    cerr << "  " << angle.toString(false) << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle(30., Angle::Degrees );
    Angle angleCopy(angle);
    cerr <<"  Copy constructor:  " << angleCopy.degrees() << " degrees" <<
        endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  cerr << endl << "Testing mutators" << endl;

  try {
    Angle angle(30., Angle::Degrees );
    angle.setDegrees(180);
    cerr <<"  setDegrees:  " << angle.degrees() << " degrees" <<
        endl;
    angle.setRadians(PI);
    cerr <<"  setRadians:  " << angle.radians() << " radians" <<
        endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  cerr << endl << "Testing operators" << endl;

  try {
    Angle angle(45.0, Angle::Degrees);
    qDebug() << "  QDebug operator:  " << angle;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle(30., Angle::Degrees );
    angle = Angle(45., Angle::Degrees);
    cerr << "  Assignment operator:  " << angle.degrees() << " degrees" <<
        endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    Angle angle2(60., Angle::Degrees );
    angle1 = angle1 + angle2;
    // Begin with 30 degrees and end with 30 degrees
    cerr << "  + and - operators..." << endl;
    cerr << "    angle + angle: " << angle1.degrees() << " degrees" <<endl;
    angle1 += angle2;
    cerr << "    angle += angle: " << angle1.degrees() << " degrees" <<endl;
    angle1 -= angle2;
    cerr << "    angle -= angle: " << angle1.degrees() << " degrees" <<endl;
    angle1 = angle1 - angle2;
    cerr << "    angle - angle: " << angle1.degrees() << " degrees" <<endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle(30., Angle::Degrees );
    // Begin with 30 degrees and end with 30 degrees
    cerr << "  * and / operators..." << endl;
    angle = 2. * angle;
    cerr << "    double * angle: " << angle.degrees() << " degrees" <<endl;
    angle *= 2;
    cerr << "    angle *= double: " << angle.degrees() << " degrees" <<endl;
    angle /= 2;
    cerr << "    angle /= double: " << angle.degrees() << " degrees" <<endl;
    angle = angle / 2;
    cerr << "    angle / double: " << angle.degrees() << " degrees" <<endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  cerr << endl << "Testing logical operators" << endl;

  try {
    Angle angle1(30., Angle::Degrees);
    Angle angle2(45., Angle::Degrees);
    cerr << "  angle1 == angle2?  " << (angle1 == angle2) << endl;
    cerr << "  angle1 == angle2?  " << (Angle() == Angle()) << endl;
    cerr << "  angle1 == angle2?  " << (Angle() == angle2) <<endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    Angle angle2(45., Angle::Degrees);
    cerr << "  angle1 <  angle2?  " << (angle1 < angle2) << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    Angle angle2(45., Angle::Degrees);
    //Angle epsilon((double)numeric_limits<float>::epsilon(), Angle::Degrees);//1.1920929e-07
    Angle epsilon(1.1920929e-12, Angle::Degrees);//1.1920929e-07
    cerr << "  angle1 <  (angle1 + epsilon)?  " << (angle1 < angle1 + epsilon) << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    Angle angle2(45., Angle::Degrees);
    Angle epsilon(1.1920929e-12, Angle::Degrees);
    cerr << "  angle2 >  (angle2 - epsilon)?  " << (angle2 > angle2 - epsilon) << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    Angle angle2(45., Angle::Degrees);
    cerr << "  angle1 <= angle2?  " << (angle1 <= angle2) << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    cerr << "  angle1 <  angle2?  " << (angle1 < Angle());
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    cerr << "  angle1 <  angle2?  " << (Angle() < angle1);
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    cerr << "  angle1 <=  angle2?  " << (Angle() <= angle1);
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    Angle angle2(45., Angle::Degrees);
    cerr << "  angle1 >  angle2?  " << (angle1 > angle2) << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    cerr << "  angle1 >  angle2?  " << (angle1 > Angle()) << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    Angle angle2(45., Angle::Degrees);
    cerr << "  angle1 >= angle2?  " << (angle1 >= angle2) << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    Angle angle1(30., Angle::Degrees );
    cerr << "  angle1 >= angle2?  " << (angle1 >= Angle()) << endl;
  }
  catch(Isis::IException &e) {
    e.print();
  }

  cerr << endl << "Testing protected methods" << endl;

  try {
    MyAngle angle(30., Angle::Degrees);
    angle.TestUnitWrapValue();
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    MyAngle angle(0., Angle::Degrees);
    cerr << "  Degree ";
    angle.setAngle(60., Angle::Degrees);
  }
  catch(Isis::IException &e) {
    e.print();
  }

  try {
    MyAngle angle(0., Angle::Radians);
    cerr << "  Radian ";
    angle.setAngle(.5, Angle::Degrees);
  }
  catch(Isis::IException &e) {
    e.print();
  }
}
Exemplo n.º 14
0
int main() {
  Preference::Preferences(true);
  QString inputFile = "$mgs/testData/ab102401.lev2.cub";
  Cube cube;
  cube.open(inputFile);
  Camera *c = NULL;
  c = cube.camera();
  Pvl pvl = *cube.label();
  MyCamera cam(cube);
  double line = 453.0;
  double sample = 534.0;
  Latitude lat(18.221, Angle::Degrees);
  Longitude lon(226.671, Angle::Degrees);
  double ra = 347.016;
  double dec = -51.2677;

  cout << endl << "Camera* from: " << inputFile << endl;
  QList<QPointF> ifovOffsets = c->PixelIfovOffsets();
  cout << "Pixel Ifov: " << endl;
  foreach (QPointF offset, ifovOffsets) {
    cout << offset.x() << " , " << offset.y() << endl;
  }
  cout << "Line: " << line << ", Sample: " << sample << endl;
  cout << "Lat: " << lat.degrees() << ", Lon: " << lon.degrees() << endl;
  cout << "RightAscension: " << ra << ", Declination: " << dec << endl << endl;

  cout << "SetImage (sample, line): " << c->SetImage(sample, line)
       << endl << endl;

  cout << "NorthAzimuth: " << c->NorthAzimuth() << endl;
  cout << "SunAzimuth: " << c->SunAzimuth() << endl;
  cout << "SpacecraftAzimuth: " << c->SpacecraftAzimuth() << endl;
  cout << "OffNadirAngle: " << c->OffNadirAngle() << endl << endl;

  cout << "GroundAzimuth in North: " << c->GroundAzimuth(18.221, 226.671, 20.0, 230.0) << endl;
  cout << "GroundAzimuth in North: " << c->GroundAzimuth(20.0, 226.671, 20.0, 230.0) << endl;
  cout << "GroundAzimuth in North: " << c->GroundAzimuth(18.221, 355.0, 20.0, 6.671) << endl;
  cout << "GroundAzimuth in North: " << c->GroundAzimuth(18.221, 6.671, 20.0, 355.0) << endl;
  cout << "GroundAzimuth in North: " << c->GroundAzimuth(18.221, 6.671, 20.0, 6.671) << endl;
  cout << "GroundAzimuth in South: " << c->GroundAzimuth(-18.221, 226.671, -20.0, 230.0) << endl;
  cout << "GroundAzimuth in South: " << c->GroundAzimuth(-20.0, 226.671, -20.0, 230.0) << endl;
  cout << "GroundAzimuth in South: " << c->GroundAzimuth(-18.221, 355.0, -20.0, 6.671) << endl;
  cout << "GroundAzimuth in South: " << c->GroundAzimuth(-18.221, 6.671, -20.0, 355.0) << endl;
  cout << "GroundAzimuth in South: " << c->GroundAzimuth(-18.221, 6.671, -20.0, 6.671) << endl << endl;

  cout << "SetUniversalGround(lat, lon): "
       << c->SetGround(lat, lon) << endl;

  cout << "SetRightAscensionDeclination(ra, dec): "
       << c->SetRightAscensionDeclination(ra, dec) << endl;
  cout << "HasProjection: " << c->HasProjection() << endl;
  cam.IsBandIndependent();
  cout << "ReferenceBand: " << c->ReferenceBand() << endl;
  cout << "HasReferenceBand: " << c->HasReferenceBand() << endl;
  cam.SetBand(7);
  cout << "Sample: " << setprecision(3) << c->Sample() << endl;
  cout << "Line: " << setprecision(3) << c->Line() << endl;

  try {
    double lat = 0, lon = 0;
    cout << "GroundRange: "
         << c->GroundRange(lat, lat, lon, lon, pvl) << endl;
    cout << "IntersectsLongitudeDomain: "
         << c->IntersectsLongitudeDomain(pvl) << endl;
  }
  catch(IException &e) {
    cout << "No mapping group found, so GroundRange and " << endl
         << "IntersectsLongitudeDomain cannot run." << endl;
  }

  cout << "PixelResolution: " << c->PixelResolution() << endl;
  cout << "LineResolution: " << c->LineResolution() << endl;
  cout << "SampleResolution: " << c->SampleResolution() << endl;
  cout << "DetectorResolution: " << c->DetectorResolution() << endl;
  cout << "LowestImageResolution: " << setprecision(4)
       << c->LowestImageResolution() << endl;
  cout << "HighestImageResolution: " << setprecision(3)
       << c->HighestImageResolution() << endl;
  cout << "Calling BasicMapping (pvl)..." << endl;
  c->BasicMapping(pvl);

  double pixRes2 = pvl.findGroup("Mapping")["PixelResolution"];
  pixRes2 *= 10000000;
  pixRes2 = round(pixRes2);
  pixRes2 /= 10000000;
  pvl.findGroup("Mapping")["PixelResolution"] = toString(pixRes2);

  cout << "BasicMapping PVL: " << endl << pvl << endl << endl;
  cout << "FocalLength: " << c->FocalLength() << endl;
  cout << "PixelPitch: " << c->PixelPitch() << endl;
  cout << "Samples: " << c->Samples() << endl;
  cout << "Lines: " << c->Lines() << endl;
  cout << "Bands: " << c->Bands() << endl;
  cout << "ParentLines: " << c->ParentLines() << endl;
  cout << "ParentSamples: " << c->ParentSamples() << endl;


  try {
    cout << c->RaDecRange(ra, ra, dec, dec) << endl;
  }
  catch(IException &e) {
    e.print();
  }

  try {
    cout << c->RaDecResolution() << endl;
  }
  catch(IException &e) {
    e.print();
  }

  cout << "Calling Distortion, FocalPlane, ";
  cout << "Detector, Ground, and Sky Map functions... ";
  c->DistortionMap();
  c->FocalPlaneMap();
  c->DetectorMap();
  c->GroundMap();
  c->SkyMap();
  cout << "Done." << endl;

  cout << "Calling IgnoreProjection (false)..." << endl;
  c->IgnoreProjection(false);

  cout << endl << "Testing SetUniversalGround(lat,lon,radius)..." << endl;
  lat.setDegrees(18.221);
  lon.setDegrees(226.671);
  double radius = 3414033.72108798;
  c->SetUniversalGround(lat.degrees(), lon.degrees(), radius);
  c->SetGround(SurfacePoint(lat, lon, Distance(radius, Distance::Meters)));
  cout << "Has intersection " << c->HasSurfaceIntersection() << endl;
  cout << "Latitude = " << c->UniversalLatitude() << endl;
  cout << "Longitude = " << c->UniversalLongitude() << endl;
  cout << "Radius = " << c->LocalRadius().meters() << endl;
  double p[3];
  c->Coordinate(p);
  cout << "Point = " << setprecision(4)
       << p[0] << " " << p[1] << " " << p[2] << endl << endl;

  cout << "Test Forward/Reverse Camera Calculations At Center Of Image..."
       << endl;
  sample = c->Samples() / 2.0;
  line = c->Lines() / 2.0;
  cout << "Sample = " << setprecision(3) << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << c->SetImage(sample, line) << endl;
  cout << "Latitude = " << c->UniversalLatitude() << endl;
  cout << "Longitude = " << c->UniversalLongitude() << endl;
  cout << "Radius = " << c->LocalRadius().meters() << endl;
  c->Coordinate(p);
  cout << "Point = " << setprecision(4)
       << p[0] << " " << p[1] << " " << p[2] << endl;
  cout << "SetUniversalGround (lat, lon, radius): "
       << c->SetUniversalGround(c->UniversalLatitude(), c->UniversalLongitude(),
                                c->LocalRadius().meters())
       << endl;
  cout << "Sample = " << c->Sample() << endl;
  cout << "Line = " << c->Line() << endl << endl;

  cout << endl << "/---------- Test Polar Boundary Conditions" << endl;
  inputFile = "$clementine1/testData/lub5992r.292.lev1.phot.cub";
  cube.close();
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam2 = CameraFactory::Create(cube);
  cube.close();

  cout << endl;
  cout << "Camera* from: " << inputFile << endl;
  ifovOffsets = cam2->PixelIfovOffsets();
  cout << "Pixel Ifov: " << endl;
  foreach (QPointF offset, ifovOffsets) {
    cout << offset.x() << " , " << offset.y() << endl;
  }
  cout << "Basic Mapping: " << endl;
  Pvl camMap;
  cam2->BasicMapping(camMap);

  double minLat = camMap.findGroup("Mapping")["MinimumLatitude"];
  minLat *= 100;
  minLat = round(minLat);
  minLat /= 100;
  camMap.findGroup("Mapping")["MinimumLatitude"] = toString(minLat);

  double pixRes = camMap.findGroup("Mapping")["PixelResolution"];
  pixRes *= 100;
  pixRes = round(pixRes);
  pixRes /= 100;
  camMap.findGroup("Mapping")["PixelResolution"] = toString(pixRes);

  double minLon = camMap.findGroup("Mapping")["MinimumLongitude"];
  minLon *= 100000000000.0;
  minLon = round(minLon);
  minLon /= 100000000000.0;
  camMap.findGroup("Mapping")["MinimumLongitude"] = toString(minLon);

  cout << camMap << endl;

  cout << endl;
  cout << "180 Domain Range: " << endl;
  double minlat, maxlat, minlon, maxlon;
  camMap.findGroup("Mapping")["LongitudeDomain"][0] = "180";
  cam2->GroundRange(minlat, maxlat, minlon, maxlon, camMap);
  cout << "Latitude Range: " << minlat << " to " << maxlat << endl;
  cout << "Longitude Range: " << minlon << " to " << maxlon
            << endl << endl;

  cout << "Test Forward/Reverse Camera Calculations At Center Of Image..."
       << endl;
  sample = cam2->Samples() / 2.0;
  line = cam2->Lines() / 2.0;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam2->SetImage(sample, line) << endl;
  cout << "Latitude = " << cam2->UniversalLatitude() << endl;
  cout << "Longitude = " << cam2->UniversalLongitude() << endl;
  cout << "Radius = " << cam2->LocalRadius().meters() << endl;
  cam2->Coordinate(p);
  cout << "Point = " << p[0] << " " << p[1] << " " << p[2] << endl;
  cout << "SetUniversalGround (cam2->UniversalLatitude(), "
          "cam2->UniversalLongitude()): "
       << cam2->SetUniversalGround(cam2->UniversalLatitude(),
                                   cam2->UniversalLongitude())
       << endl;
  cout << "Sample = " << cam2->Sample() << endl;
  cout << "Line = " << cam2->Line() << endl << endl;

  cube.close();
  delete cam2;

  cube.close();
  cout << endl << "/---------- Test Local Photometric Angles..." << endl << endl;
  cout << "Flat DEM Surface..." << endl;
  inputFile = "$base/testData/f319b18_ideal_flat.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam3 = CameraFactory::Create(cube);
  cube.close();

  sample = cam3->Samples() / 2.0;
  line = cam3->Lines() / 2.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam3->SetImage(sample, line) << endl;
  double normal[3];
  cam3->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  Angle phase;
  Angle incidence;
  Angle emission;
  bool success;
  cam3->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam3;

  cout << endl << "45 Degree DEM Surface Facing Left..." << endl;
  inputFile = "$base/testData/f319b18_ideal_45left.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam4 = CameraFactory::Create(cube);
  cube.close();

  sample = cam4->Samples() / 2.0;
  line = cam4->Lines() / 2.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam4->SetImage(sample, line) << endl;
  cam4->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  cam4->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam4;

  cout << endl << "45 Degree DEM Surface Facing Top..." << endl;
  inputFile = "$base/testData/f319b18_ideal_45top.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam5 = CameraFactory::Create(cube);
  cube.close();

  sample = cam5->Samples() / 2.0;
  line = cam5->Lines() / 2.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam5->SetImage(sample, line) << endl;
  cam5->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  cam5->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam5;

  cout << endl << "45 Degree DEM Surface Facing Right..." << endl;
  inputFile = "$base/testData/f319b18_ideal_45right.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam6 = CameraFactory::Create(cube);
  cube.close();

  sample = cam6->Samples() / 2.0;
  line = cam6->Lines() / 2.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam6->SetImage(sample, line) << endl;
  cam6->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  cam6->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam6;

  cout << endl << "45 Degree DEM Surface Facing Bottom..." << endl;
  inputFile = "$base/testData/f319b18_ideal_45bottom.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam7 = CameraFactory::Create(cube);
  cube.close();

  sample = cam7->Samples() / 2.0;
  line = cam7->Lines() / 2.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam7->SetImage(sample, line) << endl;
  cam7->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  cam7->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam7;

  cout << endl << "80 Degree DEM Surface Facing Left..." << endl;
  inputFile = "$base/testData/f319b18_ideal_80left.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam8 = CameraFactory::Create(cube);
  cube.close();

  sample = cam8->Samples() / 2.0;
  line = cam8->Lines() / 2.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam8->SetImage(sample, line) << endl;
  cam8->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  cam8->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam8;

  cout << endl << "80 Degree DEM Surface Facing Top..." << endl;
  inputFile = "$base/testData/f319b18_ideal_80top.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam9 = CameraFactory::Create(cube);
  cube.close();

  sample = cam9->Samples() / 2.0;
  line = cam9->Lines() / 2.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam9->SetImage(sample, line) << endl;
  cam9->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  cam9->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam9;

  cout << endl << "80 Degree DEM Surface Facing Right..." << endl;
  inputFile = "$base/testData/f319b18_ideal_80right.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam10 = CameraFactory::Create(cube);
  cube.close();

  sample = cam10->Samples() / 2.0;
  line = cam10->Lines() / 2.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam10->SetImage(sample, line) << endl;
  cam10->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  cam10->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam10;

  cout << endl << "80 Degree DEM Surface Facing Bottom..." << endl;
  inputFile = "$base/testData/f319b18_ideal_80bottom.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam11 = CameraFactory::Create(cube);
  cube.close();

  sample = cam11->Samples() / 2.0;
  line = cam11->Lines() / 2.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam11->SetImage(sample, line) << endl;
  cam11->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  cam11->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam11;

  cout << endl << "Point Does Not Intersect DEM..." << endl;
  inputFile = "$base/testData/f319b18_ideal_flat.cub";
  cube.open(inputFile);
  pvl = *cube.label();
  Camera *cam12 = CameraFactory::Create(cube);
  cube.close();

  sample = 1.0;
  line = 1.0;
  cout << "Camera* from: " << inputFile << endl;
  cout << "Sample = " << sample << endl;
  cout << "Line = " << line << endl;
  cout << "SetImage (sample, line): " << cam12->SetImage(sample, line) << endl;
  cam12->GetLocalNormal(normal);
  cout << "Normal = " << normal[0] << ", " << normal[1] << ", " << normal[2] << endl;
  cam12->LocalPhotometricAngles(phase,emission,incidence,success);
  if (success) {
    cout << "Phase = " << phase.degrees() << endl;
    cout << "Emission = " << emission.degrees() << endl;
    cout << "Incidence = " << incidence.degrees() << endl;
  } 
  else {
    cout << "Angles could not be calculated." << endl;
  }
  delete cam12;

  //  Test PixelIfov for Vims which sets the field of view if it in hires mode.  The Ifov is
  //  rectangular instead of square.
  inputFile = "$base/testData/CM_1515945709_1.ir.cub";
  cube.open(inputFile);
  Camera *cam13 = CameraFactory::Create(cube);
  cube.close();

  cout << endl << endl << "Testing non-square pixel Ifov using Hires vims cube" << endl;
  cout << "Camera* from: " << inputFile << endl;
  ifovOffsets = cam13->PixelIfovOffsets();
  cout << "Pixel Ifov: " << endl;
  foreach (QPointF offset, ifovOffsets) {
    cout << offset.x() << " , " << offset.y() << endl;
  }
  delete cam13;
}