Isis 3 Programmer Reference
Isis::Longitude Class Reference

This class is designed to encapsulate the concept of a Longitude. More...

#include <Longitude.h>

Inheritance diagram for Isis::Longitude:
Inheritance graph
Collaboration diagram for Isis::Longitude:
Collaboration graph

Public Types

enum  Direction { PositiveEast , PositiveWest }
 Possible longitude directions: Is a positive longitude towards east or towards west? More...
 
enum  Domain { Domain360 , Domain180 }
 Use LongitudeDomain360 if 0-360 is the primary range of the longitude values with 180 being the 'center'. More...
 
enum  Units { Degrees , Radians }
 The set of usable angle measurement units. More...
 

Public Member Functions

 Longitude ()
 Create a blank Longitude object with 0-360 domain.
 
 Longitude (double longitude, Angle::Units longitudeUnits, Direction lonDir=PositiveEast, Domain lonDomain=Domain360)
 Create and initialize a Longitude value.
 
 Longitude (Angle longitude, Direction lonDir=PositiveEast, Domain lonDomain=Domain360)
 Create and initialize a Longitude value.
 
 Longitude (double longitude, PvlGroup mapping, Angle::Units longitudeUnits)
 Create and initialize a Longitude value.
 
 Longitude (const Longitude &longitudeToCopy)
 This copies the given longitude exactly.
 
 ~Longitude ()
 This cleans up the Longitude class.
 
double positiveEast (Angle::Units units=Angle::Radians) const
 Get the longitude in the PositiveEast coordinate system.
 
void setPositiveEast (double longitude, Angle::Units units=Angle::Radians)
 Set the longitude given a value in the PositiveEast longitude system.
 
double positiveWest (Angle::Units units=Angle::Radians) const
 Get the longitude in the PositiveWest coordinate system.
 
void setPositiveWest (double longitude, Angle::Units units=Angle::Radians)
 Set the longitude given a value in the PositiveWest longitude system.
 
Longitude force180Domain () const
 This returns a longitude that is constricted to -180 to 180 degrees.
 
Longitude force360Domain () const
 This returns a longitude that is constricted to 0-360 degrees.
 
bool inRange (Longitude min, Longitude max) const
 Checks if this longitude value is within the given range.
 
Longitudeoperator= (const Longitude &longitudeToCopy)
 Same as positiveEast.
 
bool isValid () const
 This indicates whether we have a legitimate angle stored or are in an unset, or invalid, state.
 
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* (int value) const
 Multiply this angle by an integer 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.
 
Angle operator/ (int value) const
 Divide this angle by an integer and return the resulting angle.
 
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.
 
void operator*= (double value)
 Multiply this angle by a double and set this instance to 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.
 
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.
 

Static Public Member Functions

static QList< QPair< Longitude, Longitude > > to360Range (Longitude startLon, Longitude endLon)
 Calculates where the longitude range is in 0-360.
 
static Angle fullRotation ()
 Makes an angle to represent a full rotation (0-360 or 0-2pi).
 

Private Attributes

Domain m_currentDomain
 This is necessary for converting to PositiveWest and back.
 
double m_radians
 The angle measure, always stored in radians.
 

Detailed Description

This class is designed to encapsulate the concept of a Longitude.

This is used primary for surface points but is also a general purpose class. This class accepts values past the longitude domain limits. This adds the concept of longitude direction to the Angle class.

Author
2010-10-12 Steven Lambright
History

2011-01-25 Steven Lambright - Added a constructor which takes a mapping group.

2012-06-29 Kimberly Oyama and Steven Lambright - added to360Range() to calculate where the longitude range is in 0-360. Also updated the unit tests to test inRange() and to360Range(). References #958.

2012-08-10 Kimberly Oyama - Modified force360Domain() so that if the angle is 360, it is left at 360 instead of being changed to 0. Added a test case to the unit test to exercise this change. Fixes #999.

Definition at line 40 of file Longitude.h.

Member Enumeration Documentation

◆ Direction

Possible longitude directions: Is a positive longitude towards east or towards west?

Enumerator
PositiveEast 

As the longitude increases the actual position is more east.

PositiveWest 

As the longitude increases the actual position is more west.

Definition at line 46 of file Longitude.h.

◆ Domain

Use LongitudeDomain360 if 0-360 is the primary range of the longitude values with 180 being the 'center'.

use LongitudeDomain180 if 0 is the 'center' longitude. This is used for converting between longitude directions, because a 'center' longitude of 0 (-180 to 180) implies negation is all that needs done to reverse the longitude direction, whereas if you are in the 360 domain, where 180 is the center, more needs done.

Enumerator
Domain360 

As the longitude increases the actual position is more east.

Domain180 

As the longitude increases the actual position is more west.

Definition at line 62 of file Longitude.h.

◆ Units

enum Isis::Angle::Units
inherited

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 49 of file Angle.h.

Constructor & Destructor Documentation

◆ Longitude() [1/5]

Isis::Longitude::Longitude ( )

Create a blank Longitude object with 0-360 domain.

Definition at line 24 of file Longitude.cpp.

References Domain360, and m_currentDomain.

Referenced by force180Domain(), force360Domain(), and to360Range().

◆ Longitude() [2/5]

Isis::Longitude::Longitude ( double longitude,
Angle::Units longitudeUnits,
Direction lonDir = PositiveEast,
Domain lonDomain = Domain360 )

Create and initialize a Longitude value.

This value can wrap the planet any number of times regardless of the domain.

Parameters
longitudeThe longitude value this instance will represent
longitudeUnitsThe angular units of the longitude value (degs, rads)
lonDirTrue if moving east means an increase in longitude
lonDomainDomain of the given longitude value

Definition at line 103 of file Longitude.cpp.

References m_currentDomain, PositiveEast, PositiveWest, Isis::IException::Programmer, setPositiveEast(), and setPositiveWest().

◆ Longitude() [3/5]

Isis::Longitude::Longitude ( Angle longitude,
Direction lonDir = PositiveEast,
Domain lonDomain = Domain360 )

Create and initialize a Longitude value.

This value can wrap the planet any number of times regardless of the domain.

Parameters
longitudeThe longitude value this instance will represent
lonDirTrue if moving east means an increase in longitude
lonDomainDomain of the given longitude value

Definition at line 76 of file Longitude.cpp.

References m_currentDomain, PositiveEast, PositiveWest, Isis::IException::Programmer, Isis::Angle::Radians, setPositiveEast(), and setPositiveWest().

◆ Longitude() [4/5]

Isis::Longitude::Longitude ( double longitude,
PvlGroup mapping,
Angle::Units longitudeUnits )

Create and initialize a Longitude value.

This value can wrap the planet any number of times regardless of the domain. The longitude domain and direction are read from the mapping group.

Parameters
longitudeThe longitude value this instance will represent
mappingThe mapping group containing the longitude direction and domain
longitudeUnitsThe angular units of the longitude value (degs, rads)

Definition at line 39 of file Longitude.cpp.

References Domain180, Domain360, m_currentDomain, Isis::IException::Programmer, setPositiveEast(), and setPositiveWest().

◆ Longitude() [5/5]

Isis::Longitude::Longitude ( const Longitude & longitudeToCopy)

This copies the given longitude exactly.

Parameters
longitudeToCopyThe latitude we're duplicating

Definition at line 126 of file Longitude.cpp.

References m_currentDomain.

◆ ~Longitude()

Isis::Longitude::~Longitude ( )

This cleans up the Longitude class.

Definition at line 135 of file Longitude.cpp.

Member Function Documentation

◆ angle()

double Isis::Angle::angle ( const Units & unit) const
virtualinherited

◆ degrees()

◆ force180Domain()

Longitude Isis::Longitude::force180Domain ( ) const

This returns a longitude that is constricted to -180 to 180 degrees.

Returns
Longitude with an angular value between -180 and 180 inclusive

Definition at line 289 of file Longitude.cpp.

References Isis::Angle::Angle(), Isis::Angle::Degrees, force360Domain(), Isis::Angle::isValid(), and Longitude().

Referenced by Isis::RingPlaneProjection::To180Domain(), and Isis::TProjection::To180Domain().

◆ force360Domain()

Longitude Isis::Longitude::force360Domain ( ) const

This returns a longitude that is constricted to 0-360 degrees.

Returns
Longitude with an angular value between 0 and 360 inclusive

Definition at line 267 of file Longitude.cpp.

References Isis::Angle::angle(), Isis::Angle::Degrees, Isis::Angle::degrees(), Isis::Angle::isValid(), and Longitude().

Referenced by Isis::Spice::computeSolarLongitude(), force180Domain(), inRange(), Isis::RingPlaneProjection::To360Domain(), and Isis::TProjection::To360Domain().

◆ fullRotation()

Angle Isis::Angle::fullRotation ( )
staticinherited

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

Returns
the angle of 1 full rotation

Definition at line 106 of file Angle.cpp.

References Isis::Angle::Angle(), and Isis::Angle::Degrees.

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

◆ inRange()

bool Isis::Longitude::inRange ( Longitude min,
Longitude max ) const

Checks if this longitude value is within the given range.

Defines the range as the change from the minimum longitude to the maximum longitude (an angle), and returns whether the change from the minimum longitude to this longitude is less than or equal to the maximum change allowed (the range).

All longitude values are restricted to a 0-360 range for the sake of comparison. If the provided min and max longitude values are nominally different, but resolve to the same value when clamped to the 0-360 range, (for example: min=0 and max=360 => adjustedMin=0 and adjustedMax=0), then every point will be considered valid (because the whole planet is the range).

Parameters
minThe beginning of the valid longitude range
maxThe end of the valid longitude range
Returns
Whether the longitude is in the given range

Definition at line 319 of file Longitude.cpp.

References force360Domain(), Isis::PI, and to360Range().

◆ isValid()

◆ operator!=()

bool Isis::Angle::operator!= ( const Angle & angle2) const
inlineinherited

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 186 of file Angle.h.

◆ operator*() [1/2]

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

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 154 of file Angle.cpp.

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

◆ operator*() [2/2]

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

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 126 of file Angle.h.

◆ operator*=()

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

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 137 of file Angle.h.

◆ operator+()

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

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 118 of file Angle.cpp.

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

◆ operator+=()

void Isis::Angle::operator+= ( const Angle & angle2)
inlineinherited

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 104 of file Angle.h.

◆ operator-()

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

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 136 of file Angle.cpp.

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

◆ operator-=()

void Isis::Angle::operator-= ( const Angle & angle2)
inlineinherited

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

Parameters
angle2The angle to subtract from this angle

Definition at line 115 of file Angle.h.

◆ operator/() [1/3]

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

Divide this angle by another angle and return the ratio.

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

Definition at line 194 of file Angle.cpp.

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

◆ operator/() [2/3]

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

Divide this angle by a double.

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

Definition at line 181 of file Angle.cpp.

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

◆ operator/() [3/3]

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

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 148 of file Angle.h.

◆ operator/=()

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

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

Parameters
valueThe double value to use as the divisor

Definition at line 158 of file Angle.h.

◆ operator<()

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

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 208 of file Angle.cpp.

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

◆ operator<=()

bool Isis::Angle::operator<= ( const Angle & angle2) const
inlineinherited

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 197 of file Angle.h.

◆ operator=()

Longitude & Isis::Longitude::operator= ( const Longitude & longitudeToCopy)

Same as positiveEast.

Assign the values in the given longitude to ourselves.

See also
positiveEast

operator double() const { return positiveEast(); }

This will make an exact duplicate.

Parameters
longitudeToCopyThe longitude we're duplicating with the current instance

Definition at line 252 of file Longitude.cpp.

References m_currentDomain, and setPositiveEast().

◆ operator==()

bool Isis::Angle::operator== ( const Angle & angle2) const
inlineinherited

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 174 of file Angle.h.

References Isis::Angle::angle(), and Isis::Angle::Radians.

◆ operator>()

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

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 226 of file Angle.cpp.

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

◆ operator>=()

bool Isis::Angle::operator>= ( const Angle & angle2) const
inlineinherited

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 209 of file Angle.h.

◆ positiveEast()

double Isis::Longitude::positiveEast ( Angle::Units units = Angle::Radians) const

Get the longitude in the PositiveEast coordinate system.

Parameters
unitsThe angular units to get the longitude in
See also
Direction
Returns
The PositiveEast longitude value

Definition at line 146 of file Longitude.cpp.

References Isis::Angle::angle().

Referenced by Isis::LidarData::write().

◆ positiveWest()

double Isis::Longitude::positiveWest ( Angle::Units units = Angle::Radians) const

Get the longitude in the PositiveWest coordinate system.

Parameters
unitsThe angular units to get the longitude in
See also
Direction
Returns
The PositiveWest longitude value

Definition at line 158 of file Longitude.cpp.

References Isis::Angle::angle(), Domain360, Isis::IsSpecial(), m_currentDomain, and Isis::Angle::unitWrapValue().

◆ radians()

◆ setAngle()

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

Set angle value in desired units.

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

Reimplemented in Isis::Latitude.

Definition at line 323 of file Angle.cpp.

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

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

◆ setDegrees()

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

Set the angle in units of Degrees.

Parameters
degreesThe new angle value, Null for invalid angle

Definition at line 246 of file Angle.h.

References Isis::Angle::Degrees, Isis::Angle::degrees(), and Isis::Angle::setAngle().

◆ setPositiveEast()

void Isis::Longitude::setPositiveEast ( double longitude,
Angle::Units units = Angle::Radians )

Set the longitude given a value in the PositiveEast longitude system.

Parameters
longitudeThe positive east longitude to set ourselves to
unitsThe angular units longitude is in

Definition at line 199 of file Longitude.cpp.

References Isis::Angle::setAngle().

Referenced by Longitude(), Longitude(), Longitude(), and operator=().

◆ setPositiveWest()

void Isis::Longitude::setPositiveWest ( double longitude,
Angle::Units units = Angle::Radians )

Set the longitude given a value in the PositiveWest longitude system.

Parameters
longitudeThe positive west longitude to set ourselves to
unitsThe angular units longitude is in

Definition at line 210 of file Longitude.cpp.

References Domain360, Isis::IsSpecial(), m_currentDomain, Isis::Angle::setAngle(), and Isis::Angle::unitWrapValue().

Referenced by Longitude(), Longitude(), and Longitude().

◆ setRadians()

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

Set the angle in units of Radians.

Parameters
radiansThe new angle value, Null for invalid angle

Definition at line 239 of file Angle.h.

References Isis::Angle::Radians, Isis::Angle::radians(), and Isis::Angle::setAngle().

Referenced by Isis::LinearAlgebra::toAxisAngle().

◆ to360Range()

QList< QPair< Longitude, Longitude > > Isis::Longitude::to360Range ( Longitude startLon,
Longitude endLon )
static

Calculates where the longitude range is in 0-360.

This method will return 2 subranges if the total range intersects the 0/360 line. For instance, if the input range is -10-10, the output ranges will be 350-360 and 0-10. If the longitude range is invalid then an empty list will result.

Parameters
startLonthe western edge of the longitude range
endLonthe eastern edge of the range
Returns
a list of longitude pairs (first is the start and second is the end) that represent the calculated range(s).

Definition at line 364 of file Longitude.cpp.

References Isis::Angle::Degrees, Isis::Angle::fullRotation(), and Longitude().

Referenced by inRange(), and Isis::FeatureNomenclature::queryFeatures().

◆ toString()

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

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 243 of file Angle.cpp.

References Isis::Angle::degrees(), Isis::Angle::isValid(), and Isis::toString().

Referenced by Isis::Latitude::Latitude(), Isis::Latitude::planetographic(), and Isis::Hillshade::shadedValue().

◆ unitWrapValue()

double Isis::Angle::unitWrapValue ( const Units & unit) const
inherited

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 266 of file Angle.cpp.

References Isis::Angle::Degrees, Isis::PI, Isis::IException::Programmer, and Isis::Angle::Radians.

Referenced by positiveWest(), and setPositiveWest().

Member Data Documentation

◆ m_currentDomain

Domain Isis::Longitude::m_currentDomain
private

This is necessary for converting to PositiveWest and back.

Definition at line 111 of file Longitude.h.

Referenced by Longitude(), Longitude(), Longitude(), Longitude(), Longitude(), operator=(), positiveWest(), and setPositiveWest().

◆ m_radians

double Isis::Angle::m_radians
privateinherited

The angle measure, always stored in radians.

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

Definition at line 258 of file Angle.h.

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


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