示例#1
0
文件: Latitude.cpp 项目: jlaura/isis3
  /**
   * Create and initialize a Latitude value using the mapping group's latitude
   * units and radii.
   *
   * @see ErrorChecking
   * @see CoordinateType
   * @param latitude The latitude value this instance will represent,
   *     in the mapping group's units
   * @param mapping A mapping group
   * @param latitudeUnits The angular units of the latitude value (degs, rads)
   * @param errors Error checking conditions
   */
  Latitude::Latitude(Angle latitude, PvlGroup mapping,
            ErrorChecking errors) : Angle(latitude) {
    m_equatorialRadius = NULL;
    m_polarRadius = NULL;

    if (mapping.hasKeyword("EquatorialRadius") && mapping.hasKeyword("PolarRadius")) {
      m_equatorialRadius = new Distance(toDouble(mapping["EquatorialRadius"][0]),
          Distance::Meters);
      m_polarRadius = new Distance(toDouble(mapping["PolarRadius"][0]),
          Distance::Meters);
    }
    else {
      PvlGroup radiiGrp = TProjection::TargetRadii(mapping["TargetName"]);

      m_equatorialRadius = new Distance(toDouble(radiiGrp["EquatorialRadius"][0]),
          Distance::Meters);
      m_polarRadius = new Distance(toDouble(radiiGrp["PolarRadius"][0]),
          Distance::Meters);
    }

    m_errors = errors;

    if(mapping["LatitudeType"][0] == "Planetographic") {
      setPlanetographic(latitude.radians(), Radians);
    }
    else if(mapping["LatitudeType"][0] == "Planetocentric") {
      setPlanetocentric(latitude.radians(), Radians);
    }
    else {
      QString msg = "Latitude type [" + mapping["LatitudeType"][0] +
        "] is not recognized";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
  }
示例#2
0
文件: phocube.cpp 项目: jlaura/isis3
// Computes the special MORPHOLOGY and ALBEDO planes
MosData *getMosaicIndicies(Camera &camera, MosData &md) {
  const double Epsilon(1.0E-8);
  Angle myphase;
  Angle myincidence;
  Angle myemission;
  bool mysuccess;
  camera.LocalPhotometricAngles(myphase, myincidence, myemission, mysuccess);
  if (!mysuccess) {
    myemission.setDegrees(camera.EmissionAngle());
    myincidence.setDegrees(camera.IncidenceAngle());
  }
  double res = camera.PixelResolution();
  if (fabs(res) < Epsilon) res = Epsilon;

  md = MosData();  // Nullifies the data
  if (myemission.isValid()) {
    // Compute MORPHOLOGY
    double cose = cos(myemission.radians());
    if (fabs(cose) < Epsilon) cose = Epsilon;
    // Convert resolution to units of KM
    md.m_morph = (res / 1000.0) / cose;

    if (myincidence.isValid()) {
      // Compute ALBEDO
      double cosi = cos(myincidence.radians());
      if (fabs(cosi) < Epsilon) cosi = Epsilon;
      //  Convert resolution to KM
      md.m_albedo = (res / 1000.0 ) * ( (1.0 / cose) + (1.0 / cosi) );
    }
  }

  return (&md);
}
示例#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);
}
示例#4
0
文件: Latitude.cpp 项目: jlaura/isis3
  /**
   * Create and initialize a Latitude value in the planetocentric domain within
   * the given angle.
   *
   * @param latitude The latitude value this instance will represent
   * @param errors Error checking conditions
   */
  Latitude::Latitude(Angle latitude, ErrorChecking errors) : Angle() {
    m_equatorialRadius = NULL;
    m_polarRadius = NULL;

    m_errors = errors;

    setPlanetocentric(latitude.radians(), Radians);
  }
示例#5
0
文件: Latitude.cpp 项目: jlaura/isis3
  /**
    * Adds another latitude to this one. Handles planetographic latitudes.
    *
    * @param angleToAdd the latitude being added to this one
    * @param equatorialRadius
    * @param polarRadius
    * @param latType
    * @return The result
    */
  Latitude Latitude::add(Angle angleToAdd, Distance equatorialRadius, Distance polarRadius,
                         CoordinateType latType) {
    Latitude result;
    
    switch (latType) {
      case Planetocentric:
        result = Latitude(planetocentric() + angleToAdd.radians(), equatorialRadius, polarRadius,
                          latType, Radians, m_errors);
        break;

      case Planetographic:
        result = Latitude(planetographic() + angleToAdd.radians(), equatorialRadius, polarRadius,
                          latType, Radians, m_errors);
        break;
    }
    
    return result;
  }
double	tan(const Angle& a) { return ::tan(a.radians()); }
double	sin(const Angle& a) { return ::sin(a.radians()); }
double	cos(const Angle& a) { return ::cos(a.radians()); }
uint32_t	CelestronMount::angle32(const Angle& a) {
	uint32_t	result = 4294967296 * a.radians() / (2 * M_PI);
	return result;
}
uint16_t	CelestronMount::angle16(const Angle& a) {
	uint16_t	result = 65536 * a.radians() / (2 * M_PI);
	return result;
}
示例#11
0
文件: unitTest.cpp 项目: corburn/ISIS
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();
  }
}