USGS

Isis 3.0 Object Programmers' Reference

Home

Isis::Angle Class Reference

Defines an angle and provides unit conversions. More...

#include <Angle.h>

Inheritance diagram for Isis::Angle:
Inheritance graph
Collaboration diagram for Isis::Angle:
Collaboration graph

Public Types

enum  Units { Degrees, Radians }
 The set of usable angle measurement units. More...

Public Member Functions

 Angle ()
 Constructs a blank angle object which needs a value to be set in order to do any calculations.
 Angle (double angle, Units unit)
 Constructs an angle object with the entered value and unit.
 Angle (const Angle &angle)
 Constructs an angle object from another Angle object.
 Angle (QString angle)
 Constructs an angle object with units of Angle::Degrees from a QString of the general form "dd mm ss.ss" (there can be more than 2 digits per piece.)
virtual ~Angle ()
 Destroys the angle object.
bool isValid () const
 This indicates whether we have a legitimate angle stored or are in an unset, or invalid, state.
Angleoperator= (const Angle &angle2)
 Assign angle object equal to another.
Angle operator+ (const Angle &angle2) const
 Add angle value to another.
Angle operator- (const Angle &angle2) const
 Subtract angle value from another and return the resulting angle.
Angle operator* (double value) const
 Multiply this angle by a double and return the resulting angle.
Angle operator/ (double value) const
 Divide this angle by a double.
double operator/ (Angle value) const
 Divide this angle by another angle and return the ratio.
bool operator< (const Angle &angle2) const
 Test if the other angle is less than the current angle.
bool operator> (const Angle &angle2) const
 Test if the other angle is greater than the current angle.
void operator+= (const Angle &angle2)
 Add angle value to another as double and replace original.
void operator-= (const Angle &angle2)
 Subtract angle value from another and set this instance to the resulting angle.
Angle operator* (int value) const
 Multiply this angle by an integer and return the resulting angle.
void operator*= (double value)
 Multiply this angle by a double and set this instance to the resulting angle.
Angle operator/ (int value) const
 Divide this angle by an integer and return the resulting angle.
void operator/= (double value)
 Divide this angle by a double and return the resulting angle.
bool operator== (const Angle &angle2) const
 Test if another angle is equal to this angle.
bool operator!= (const Angle &angle2) const
 Test if another angle is not equal to this angle.
bool operator<= (const Angle &angle2) const
 Test if the other angle is less than or equal to the current angle.
bool operator>= (const Angle &angle2) const
 Test if the other angle is greater than or equal to the current angle.
double radians () const
 Convert an angle to a double.
double degrees () const
 Get the angle in units of Degrees.
void setRadians (double radians)
 Set the angle in units of Radians.
void setDegrees (double degrees)
 Set the angle in units of Degrees.
virtual QString toString (bool includeUnits=true) const
 Get the angle in human-readable form.

Static Public Member Functions

static Angle fullRotation ()
 Makes an angle to represent a full rotation (0-360 or 0-2pi).

Protected Member Functions

double unitWrapValue (const Units &unit) const
 Return wrap value in desired units.
virtual double angle (const Units &unit) const
 Return angle value in desired units.
virtual void setAngle (const double &angle, const Units &unit)
 Set angle value in desired units.

Private Attributes

double m_radians
 The angle measure, always stored in radians.

Friends

Angle operator* (double mult, Angle angle)
 Multiply this angle by a double and return the resulting angle.

Detailed Description

Defines an angle and provides unit conversions.

Author
2010-10-09 Debbie A. Cook
History:
2010-11-01 Steven Lambright - Added methods setRadians and SetDegrees
History:
2012-02-16 Steven Lambright - Brought up to method and member naming standards.
History:
2012-03-22 Steven Lambright - Renamed text() to toString().
History:
2012-06-29 Steven Lambright and Kimberly Oyama - Removed duplicate code from the constructor. Added the fullRotation() method which creates an angle of 360 degrees and modified the unit test to exercise this. References #958.
History:
2012-07-26 Steven Lambright and Kimberly Oyama - Modified the < and > operators to make sure they do not return true if the two operands are the same. Updated the unitTest to exercise this change. References #604.
History:
2013-02-01 Steven Lambright - Added QDebug() printout capabilities. References #1060.
History:
2014-07-28 Kristin Berry - Added a constructor which accepts a Qstring of the form: "dd mm ss.ss" for angles provided in this format.
History:
2014-08-21 Jeannie Backer - Modified isValid to utilize the IsValidPixel() method in the SpecialPixel header. References #1659.

Definition at line 58 of file Angle.h.

Member Enumeration Documentation

The set of usable angle measurement units.

Enumerator:
Degrees 

Degrees are generally considered more human readable, 0-360 is one circle, however most math does not use this unit.

Use these for displaying to the user and accepting input from the user.

Radians 

Radians are generally used in mathematical equations, 0-2*PI is one circle, however these are more difficult for users to understand when displayed since they have PI in them.

This is the default unit and is necessary for most math library calls.

Definition at line 62 of file Angle.h.

Constructor & Destructor Documentation

Isis::Angle::Angle ( )

Constructs a blank angle object which needs a value to be set in order to do any calculations.

Definition at line 38 of file Angle.cpp.

References m_radians, and Isis::Null.

Referenced by Isis::Longitude::force180Domain(), fullRotation(), operator*(), operator+(), operator-(), operator/(), Isis::Latitude::planetographic(), Isis::Latitude::setAngle(), and Isis::Latitude::setPlanetographic().

Isis::Angle::Angle ( double  angle,
Units  unit 
)

Constructs an angle object with the entered value and unit.

Parameters
angleThe initial angle value in units of the unit parameter
unitThe unit of the initial angle (see Angle::Units)

Definition at line 48 of file Angle.cpp.

References setAngle().

Isis::Angle::Angle ( const Angle fromAngle)

Constructs an angle object from another Angle object.

Parameters
fromAngleThe angle object to copy on initialization

Definition at line 58 of file Angle.cpp.

References m_radians.

Isis::Angle::Angle ( QString  angle)

Constructs an angle object with units of Angle::Degrees from a QString of the general form "dd mm ss.ss" (there can be more than 2 digits per piece.)

Parameters
angleThe value of the angle in degrees, as a QString of the form: "dd mm ss.ss"

Definition at line 69 of file Angle.cpp.

References _FILEINFO_, Degrees, degrees(), Isis::IException::Programmer, and setAngle().

Isis::Angle::~Angle ( )
virtual

Destroys the angle object.

Definition at line 98 of file Angle.cpp.

References m_radians, and Isis::Null.

Member Function Documentation

double Isis::Angle::angle ( const Units unit) const
protectedvirtual

Return angle value in desired units.

Parameters
unitDesired units of the angle (see Angle::Units)
Returns
angle value in specified units

Definition at line 302 of file Angle.cpp.

References _FILEINFO_, Degrees, m_radians, Isis::Null, Isis::IException::Programmer, Isis::RAD2DEG(), and Radians.

Referenced by degrees(), Isis::Longitude::force360Domain(), operator<(), operator==(), operator>(), Isis::Latitude::planetocentric(), Isis::Longitude::positiveEast(), Isis::Longitude::positiveWest(), radians(), and setAngle().

double Isis::Angle::degrees ( ) const
inline

Get the angle in units of Degrees.

Returns
A double-value representing this angle. Null if not valid.

Definition at line 245 of file Angle.h.

References angle(), and Degrees.

Referenced by Angle(), Isis::BundleAdjust::applyParameterCorrections_CHOLMOD(), Isis::BundleAdjust::applyParameterCorrections_SPECIALK(), Isis::MosaicGridTool::autoGrid(), Isis::MosaicGridTool::drawGrid(), Isis::QnetTool::findPointLocation(), Isis::Longitude::force180Domain(), Isis::Longitude::force360Domain(), Isis::ImageTreeWidgetItem::ImageTreeWidgetItem(), Isis::Latitude::inRange(), Isis::DemShape::localRadius(), operator<<(), Isis::BundleAdjust::OutputNoErrorPropagation(), Isis::BundleAdjust::OutputPointsCSV(), Isis::BundleAdjust::OutputWithErrorPropagation(), Isis::Latitude::planetographic(), Isis::ControlNetFilter::PointLatLonFilter(), Isis::MosaicGridToolConfigDialog::readSettings(), Isis::MosaicGridToolConfigDialog::refreshWidgetStates(), Isis::FeatureNomenclature::runQuery(), Isis::Latitude::setAngle(), Isis::CameraGroundMap::SetGround(), Isis::VimsGroundMap::SetGround(), Isis::UniversalGroundMap::SetGround(), Isis::Camera::SetGround(), Isis::RingPlaneProjection::To180Domain(), Isis::RingPlaneProjection::To360Domain(), Isis::ControlNetFileV0002::toPvl(), Isis::MosaicGridTool::toPvl(), toString(), Isis::Sensor::UniversalLatitude(), Isis::Sensor::UniversalLongitude(), Isis::BundleAdjust::Update(), Isis::MeasureTool::updateDist(), Isis::SunShadowTool::updateRow(), Isis::AdvancedTrackTool::updateRow(), and Isis::QnetTool::updateSurfacePointInfo().

Angle Isis::Angle::fullRotation ( )
static

Makes an angle to represent a full rotation (0-360 or 0-2pi).

Returns
the angle of 1 full rotation

Definition at line 121 of file Angle.cpp.

References Angle(), and Degrees.

Referenced by Isis::Hillshade::shadedValue(), and Isis::Longitude::to360Range().

bool Isis::Angle::operator!= ( const Angle angle2) const
inline

Test if another angle is not equal to this angle.

Takes the negated result of the '==' operator.

Parameters
angle2The comparison angle (on right-hand-side of != operator)
Returns
true if the angle does not equal the comparision angle

Definition at line 199 of file Angle.h.

Angle Isis::Angle::operator* ( double  value) const

Multiply this angle by a double and return the resulting angle.

If this is an invalid angle, then the result will be an invalid angle.

Parameters
valueThe value to multiply to this angle
Returns
Multiplied angle

Definition at line 169 of file Angle.cpp.

References Angle(), isValid(), Radians, and radians().

Angle Isis::Angle::operator* ( int  value) const
inline

Multiply this angle by an integer and return the resulting angle.

Parameters
valueThe integer value to multiply with this angle
Returns
Product of the angles

Definition at line 139 of file Angle.h.

void Isis::Angle::operator*= ( double  value)
inline

Multiply this angle by a double and set this instance to the resulting angle.

Parameters
valueThe double value to multiply with this angle

Definition at line 150 of file Angle.h.

Angle Isis::Angle::operator+ ( const Angle angle2) const

Add angle value to another.

If either of these are invalid angles, then the result will be an invalid angle.

Parameters
angle2The angle to add to this angle
Returns
sum angle

Definition at line 133 of file Angle.cpp.

References Angle(), isValid(), Radians, and radians().

void Isis::Angle::operator+= ( const Angle angle2)
inline

Add angle value to another as double and replace original.

Parameters
angle2The angle to add to this angle
Returns
sum angle, replaces original

Definition at line 117 of file Angle.h.

Angle Isis::Angle::operator- ( const Angle angle2) const

Subtract angle value from another and return the resulting angle.

If either of these are invalid angles, then the result will be an invalid angle.

Parameters
angle2The angle to subtract from this angle
Returns
difference angle

Definition at line 151 of file Angle.cpp.

References Angle(), isValid(), Radians, and radians().

void Isis::Angle::operator-= ( const Angle angle2)
inline

Subtract angle value from another and set this instance to the resulting angle.

Parameters
angle2The angle to subtract from this angle

Definition at line 128 of file Angle.h.

Angle Isis::Angle::operator/ ( double  value) const

Divide this angle by a double.

Parameters
valueThe double value to use as the divisor
Returns
Quotient of the angles

Definition at line 196 of file Angle.cpp.

References Angle(), isValid(), Radians, and radians().

double Isis::Angle::operator/ ( Angle  value) const

Divide this angle by another angle and return the ratio.

Parameters
valueThe ratio, Null if invalid
Returns
Quotient of the angles

Definition at line 209 of file Angle.cpp.

References isValid(), Isis::Null, and radians().

Angle Isis::Angle::operator/ ( int  value) const
inline

Divide this angle by an integer and return the resulting angle.

Parameters
valueThe double value to use as the divisor
Returns
Quotient of the angles

Definition at line 161 of file Angle.h.

void Isis::Angle::operator/= ( double  value)
inline

Divide this angle by a double and return the resulting angle.

Parameters
valueThe double value to use as the divisor

Definition at line 171 of file Angle.h.

bool Isis::Angle::operator< ( const Angle angle2) const

Test if the other angle is less than the current angle.

If either is invalid, then an exception will be thrown.

Parameters
angle2The comparison angle (on right-hand-side of < operator)
Returns
True if the angle is less than the comparision angle

Definition at line 223 of file Angle.cpp.

References _FILEINFO_, angle(), isValid(), Isis::IException::Programmer, and Radians.

bool Isis::Angle::operator<= ( const Angle angle2) const
inline

Test if the other angle is less than or equal to the current angle.

Parameters
angle2The comparison angle (on right-hand-side of < operator)
Returns
true if the angle is less than or equal to the comparision angle

Definition at line 210 of file Angle.h.

Angle& Isis::Angle::operator= ( const Angle angle2)
inline

Assign angle object equal to another.

Parameters
angle2The angle value to copy
Returns
The new angle value

Definition at line 96 of file Angle.h.

References Radians, radians(), and setAngle().

bool Isis::Angle::operator== ( const Angle angle2) const
inline

Test if another angle is equal to this angle.

This does not compensate for going around a circle: Angle(360, Angle::Degrees) does not equal Angle(0, Angle::Degrees)

Invalid angles are equal to each other.

Parameters
angle2The comparison angle (on right-hand-side of == operator)
Returns
true if the angle equals the comparision angle

Definition at line 187 of file Angle.h.

References angle(), and Radians.

bool Isis::Angle::operator> ( const Angle angle2) const

Test if the other angle is greater than the current angle.

If either is invalid, then an exception will be thrown.

Parameters
angle2The comparison angle (on right-hand-side of > operator)
Returns
True if the angle is greater than the comparision angle

Definition at line 240 of file Angle.cpp.

References _FILEINFO_, angle(), isValid(), Isis::IException::Programmer, and Radians.

bool Isis::Angle::operator>= ( const Angle angle2) const
inline

Test if the other angle is greater than or equal to the current angle.

Parameters
angle2The comparison angle (on right-hand-side of < operator)
Returns
true if the angle is greater than or equal to the comparision angle

Definition at line 222 of file Angle.h.

void Isis::Angle::setAngle ( const double &  angle,
const Units unit 
)
protectedvirtual

Set angle value in desired units.

Parameters
angleThe angle value in units of the unit parameter
unitDesired units of the angle (see Angle::Units)

Definition at line 336 of file Angle.cpp.

References _FILEINFO_, angle(), Isis::DEG2RAD(), Degrees, Isis::IsSpecial(), m_radians, Isis::Null, Isis::IException::Programmer, and Radians.

Referenced by Angle(), operator=(), setDegrees(), Isis::Longitude::setPositiveEast(), Isis::Longitude::setPositiveWest(), and setRadians().

void Isis::Angle::setDegrees ( double  degrees)
inline

Set the angle in units of Degrees.

Parameters
degreesThe new angle value, Null for invalid angle

Definition at line 259 of file Angle.h.

References Degrees, and setAngle().

void Isis::Angle::setRadians ( double  radians)
inline

Set the angle in units of Radians.

Parameters
radiansThe new angle value, Null for invalid angle

Definition at line 252 of file Angle.h.

References Radians, and setAngle().

QString Isis::Angle::toString ( bool  includeUnits = true) const
virtual

Get the angle in human-readable form.

Parameters
includeUnitsInclude the angle's units in the text.
Returns
A user-displayable angle string.

Definition at line 256 of file Angle.cpp.

References degrees(), and isValid().

Referenced by Isis::operator<<(), and Isis::Hillshade::shadedValue().

double Isis::Angle::unitWrapValue ( const Units unit) const
protected

Return wrap value in desired units.

The 'wrap' value is the value where one circle occurs - angles greater than this are conceptually 'wrapping' back to zero. For example, this is 2*PI in radians because 2*PI == 0 on a circle. Please keep in mind we still differentiate those two angles.

Parameters
unitDesired units of the Angle wrap constant (see Angle::Units)
Returns
Wrap value in specified units

Definition at line 279 of file Angle.cpp.

References _FILEINFO_, Degrees, Isis::PI(), Isis::IException::Programmer, and Radians.

Referenced by Isis::Longitude::positiveWest(), and Isis::Longitude::setPositiveWest().

Friends And Related Function Documentation

Angle operator* ( double  mult,
Angle  angle 
)
friend

Multiply this angle by a double and return the resulting angle.

If this is an invalid angle, then the result will be an invalid angle.

Parameters
multThe value to multiply to this angle
angleThe angle being multiplied by mult
Returns
Multiplied angle

Definition at line 185 of file Angle.cpp.

Member Data Documentation

double Isis::Angle::m_radians
private

The angle measure, always stored in radians.

If degrees are requested then a conversion is done on the fly.

Definition at line 273 of file Angle.h.

Referenced by Angle(), angle(), isValid(), setAngle(), and ~Angle().


The documentation for this class was generated from the following files: