// 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); }
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(); } }