Isis Developer Reference
Isis::Distance Class Reference

Distance measurement, usually in meters. More...

#include <Distance.h>

Collaboration diagram for Isis::Distance:
Collaboration graph

Public Types

enum  Units { Meters, Kilometers, Pixels, SolarRadii }
 This is a list of available units to access and store Distances in. More...
 

Public Member Functions

 Distance ()
 This initializes the distance to an invalid state. More...
 
 Distance (double distance, Units distanceUnit)
 This is the general purpose constructor for Distance. More...
 
 Distance (double distanceInPixels, double pixelsPerMeter)
 This is a constructor for Distance given pixels with a conversion ratio. More...
 
 Distance (const Distance &distanceToCopy)
 This is the copy constructor for Distance. More...
 
virtual ~Distance ()
 This will free the memory allocated by this instance of the Distance class. More...
 
double meters () const
 Get the distance in meters. More...
 
void setMeters (double distanceInMeters)
 Set the distance in meters. More...
 
double kilometers () const
 Get the distance in kilometers. More...
 
void setKilometers (double distanceInKilometers)
 Set the distance in kilometers. More...
 
double pixels (double pixelsPerMeter=1.0) const
 Get the distance in pixels using the given conversion ratio. More...
 
void setPixels (double distanceInPixels, double pixelsPerMeter=1.0)
 Set the distance in pixels. More...
 
double solarRadii () const
 Get the distance in solar radii (a unit of ~696,265km). More...
 
void setSolarRadii (double distanceInSolarRadii)
 Set the distance in solar radii. More...
 
QString toString () const
 Get a textual representation of this distance. More...
 
bool isValid () const
 Test if this distance has been initialized or not. More...
 
bool operator> (const Distance &otherDistance) const
 Compare two distances with the greater than operator. More...
 
bool operator< (const Distance &otherDistance) const
 Compare two distances with the less than operator. More...
 
bool operator>= (const Distance &otherDistance) const
 Compare two distances with the greater than or equal to operator. More...
 
bool operator<= (const Distance &otherDistance) const
 Compare two distances with the less than or equal to operator. More...
 
bool operator== (const Distance &otherDistance) const
 Compare two distances with the == operator. More...
 
bool operator!= (const Distance &otherDistance) const
 Compare two distances with the != operator. More...
 
Distanceoperator= (const Distance &distanceToCopy)
 Assign this distance to the value of another distance. More...
 
Distance operator+ (const Distance &distanceToAdd) const
 Add another distance to this distance (1km + 1m = 1005m) More...
 
Displacement operator- (const Distance &distanceToSub) const
 Subtract another distance from this distance (1km - 1m = 995m). More...
 
double operator/ (const Distance &distanceToDiv) const
 Divide another distance into this distance (5m / 1m = 5). More...
 
Distance operator/ (const double &valueToDiv) const
 Divide a value from this distance (5m / 2 = 2.5m). More...
 
Distance operator* (const double &valueToMult) const
 Multiply this distance by a value (5m * 2 = 10m). More...
 
void operator+= (const Distance &distanceToAdd)
 Add and assign the given distance to ourselves. More...
 
void operator-= (const Distance &distanceToSub)
 Subtract and assign the given distance from ourself. More...
 
void operator/= (const double &valueToDiv)
 Divide this distance by a value and assign the result to ourself. More...
 
void operator*= (const double &valueToMult)
 Multiply this distance by a value and assign the result to ourself. More...
 

Protected Member Functions

virtual double distance (Units distanceUnit) const
 This is a helper method to access distances in a universal manner with uniform error checking. More...
 
virtual void setDistance (const double &distance, Units distanceUnit)
 This is a helper method to set distances in a universal manner with uniform error checking. More...
 

Friends

Distance operator* (double mult, Distance dist)
 Multiply this distance by a value (5m * 2 = 10m). More...
 

Detailed Description

Distance measurement, usually in meters.

This class is designed to encapsulate the concept of a distance. This is typically used for Radius and XYZ values but is also available as a general purpose class. This class does not accept negative values.

Author
2010-10-12 Steven Lambright

Member Enumeration Documentation

◆ Units

This is a list of available units to access and store Distances in.

These values can be passed to the constructor to specify which unit the double you are passing in is in.

Enumerator
Meters 

The distance is being specified in meters.

Kilometers 

The distance is being specified in kilometers.

Pixels 

The distance is being specified in pixels.

SolarRadii 

"Solar radius is a unit of distance used to express the size of stars in astronomy equal to the current radius of the Sun.

"

We're using 6.9599*10^8 meters, because that's the actual unit value, even though the radius has been more accurately calculated to 6.96342*10^8 m.

http://en.wikipedia.org/wiki/Solar_radius http://www.astro.wisc.edu/~dolan/constants.html https://www.cfa.harvard.edu/~dfabricant/huchra/ay145/constants.html

Constructor & Destructor Documentation

◆ Distance() [1/4]

Isis::Distance::Distance ( )

This initializes the distance to an invalid state.

You must set the distance later on with operator= or one of the Set methods.

References Meters, Isis::Null, and setDistance().

Referenced by operator*(), operator+(), and operator/().

◆ Distance() [2/4]

Isis::Distance::Distance ( double  distance,
Units  distanceUnit 
)

This is the general purpose constructor for Distance.

This will initialize with the given distance. If Pixels are supplied as the units, then a default pixels/meter = 1.0 will be used.

Parameters
distanceThe distance to initialize with, must be in units of distanceUnit and not be negative
distanceUnitThe unit distance is in, can be any value in Distance::Units

References distance(), Meters, Pixels, and setDistance().

◆ Distance() [3/4]

Isis::Distance::Distance ( double  distanceInPixels,
double  pixelsPerMeter 
)

This is a constructor for Distance given pixels with a conversion ratio.

This will initialize with the pixels converted to meters.

Parameters
distanceInPixelsThe distance to initialize with, must be in units of pixels and should not be negative
pixelsPerMeterThe pixels/meter conversion factor

References Meters, and setDistance().

◆ Distance() [4/4]

Isis::Distance::Distance ( const Distance distanceToCopy)

This is the copy constructor for Distance.

The distance passed in will be exactly duplicated.

Parameters
distanceToCopyThis is the distance we are making an exact duplicate of

References Meters, meters(), and setDistance().

◆ ~Distance()

Isis::Distance::~Distance ( )
virtual

This will free the memory allocated by this instance of the Distance class.

References Isis::Null.

Member Function Documentation

◆ distance()

double Isis::Distance::distance ( Units  distanceUnit) const
protectedvirtual

This is a helper method to access distances in a universal manner with uniform error checking.

Parameters
distanceUnitUnit of the return value. If this is invalid, an exception will be thrown.
Returns
The distance in units of distanceUnit

References _FILEINFO_, Kilometers, Meters, Isis::Null, Pixels, Isis::IException::Programmer, and SolarRadii.

Referenced by Distance(), isValid(), kilometers(), meters(), pixels(), setDistance(), and solarRadii().

◆ isValid()

◆ kilometers()

◆ meters()

double Isis::Distance::meters ( ) const

Get the distance in meters.

Returns
Current distance, in meters, guaranteed to be >= 0.0

References distance(), and Meters.

Referenced by Isis::CameraStatistics::addStats(), Isis::ControlNetFilter::CubeDistanceFilter(), Isis::Displacement::Displacement(), Distance(), Isis::SurfacePoint::DistanceToDouble(), Isis::AdjustedLatitudeSigmaFilter::evaluate(), Isis::AdjustedLongitudeSigmaFilter::evaluate(), Isis::AdjustedRadiusFilter::evaluate(), Isis::AdjustedRadiusSigmaFilter::evaluate(), Isis::APrioriLatitudeSigmaFilter::evaluate(), Isis::APrioriLongitudeSigmaFilter::evaluate(), Isis::APrioriRadiusFilter::evaluate(), Isis::APrioriRadiusSigmaFilter::evaluate(), Isis::QnetCubeDistanceFilter::filter(), Isis::QnetPointDistanceFilter::filter(), Isis::BundleControlPoint::formatAdjustedSigmaString(), Isis::AbstractPointItem::getData(), Isis::GroundGrid::GroundGrid(), operator!=(), operator*(), operator*=(), operator+(), operator+=(), operator-(), Isis::Displacement::operator-=(), operator-=(), operator/(), operator/=(), operator<(), operator=(), operator==(), operator>(), Isis::BundleSolutionInfo::outputText(), Isis::ControlNetFilter::PointDistanceFilter(), Isis::ControlNetFilter::PointLatLonFilter(), Isis::ProjectionFactory::RingsCreateForCube(), Isis::Image::save(), Isis::Shape::save(), Isis::SurfacePoint::SetRectangularSigmas(), Isis::SurfacePoint::SetSphericalSigmas(), Isis::SurfacePoint::SetSphericalSigmasDistance(), Isis::BundleControlPoint::setWeights(), Isis::ControlNetVersioner::toPvl(), and toString().

◆ operator!=()

bool Isis::Distance::operator!= ( const Distance otherDistance) const
inline

Compare two distances with the != operator.

Two uninitialized distances are equal to each other.

Parameters
otherDistanceThis is the distance we're comparing to, i.e. on the right hand side of the operator when used
Returns
True if this distance is not equal to the given distance

References meters().

◆ operator*()

Distance Isis::Distance::operator* ( const double &  valueToMult) const

Multiply this distance by a value (5m * 2 = 10m).

Parameters
valueToMultThis is the value to multiply by
Returns
Resulting value

References Distance(), Isis::IsSpecial(), isValid(), Meters, and meters().

◆ operator*=()

void Isis::Distance::operator*= ( const double &  valueToMult)

Multiply this distance by a value and assign the result to ourself.

Parameters
valueToMultThis is the value we are going to multiply by

References Isis::IsSpecial(), isValid(), Meters, meters(), Isis::Null, and setDistance().

◆ operator+()

Distance Isis::Distance::operator+ ( const Distance distanceToAdd) const

Add another distance to this distance (1km + 1m = 1005m)

Parameters
distanceToAddThis is the distance we are adding to ourselves
Returns
Resulting distance, self not modified

References Distance(), isValid(), Meters, and meters().

◆ operator+=()

void Isis::Distance::operator+= ( const Distance distanceToAdd)

Add and assign the given distance to ourselves.

Parameters
distanceToAddThis is the distance we are to duplicate exactly

References isValid(), Meters, meters(), Isis::Null, and setDistance().

◆ operator-()

Displacement Isis::Distance::operator- ( const Distance distanceToSub) const

Subtract another distance from this distance (1km - 1m = 995m).

This could throw an exception if the result is negative.

Parameters
distanceToSubThis is the distance we are subtracting from ourself
Returns
Resulting distance, self not modified

References isValid(), Isis::Displacement::Meters, and meters().

◆ operator-=()

void Isis::Distance::operator-= ( const Distance distanceToSub)

Subtract and assign the given distance from ourself.

This could throw an exception if the result is negative, in which case the new value is never applied.

Parameters
distanceToSubThis is the distance we are to subtract

References isValid(), Meters, meters(), Isis::Null, and setDistance().

◆ operator/() [1/2]

double Isis::Distance::operator/ ( const Distance distanceToDiv) const

Divide another distance into this distance (5m / 1m = 5).

Parameters
distanceToDivThis is the divisor displacement (denominator)
Returns
Resulting value

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

◆ operator/() [2/2]

Distance Isis::Distance::operator/ ( const double &  valueToDiv) const

Divide a value from this distance (5m / 2 = 2.5m).

Parameters
valueToDivThis is the divisor displacement (denominator)
Returns
Resulting value

References Distance(), Isis::IsSpecial(), isValid(), Meters, and meters().

◆ operator/=()

void Isis::Distance::operator/= ( const double &  valueToDiv)

Divide this distance by a value and assign the result to ourself.

Parameters
valueToDivThis is the displacement we are to divide by

References Isis::IsSpecial(), isValid(), Meters, meters(), Isis::Null, and setDistance().

◆ operator<()

bool Isis::Distance::operator< ( const Distance otherDistance) const

Compare two distances with the less than operator.

Parameters
otherDistanceThis is the distance we're comparing to, i.e. on the right hand side of the operator when used
Returns
True if this distance is less than the given distance

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

◆ operator<=()

bool Isis::Distance::operator<= ( const Distance otherDistance) const
inline

Compare two distances with the less than or equal to operator.

Parameters
otherDistanceThis is the distance we're comparing to, i.e. on the right hand side of the operator when used
Returns
True if this distance is less than or equal to the given distance

◆ operator=()

Distance & Isis::Distance::operator= ( const Distance distanceToCopy)

Assign this distance to the value of another distance.

Parameters
distanceToCopyThis is the distance we are to duplicate exactly
Returns
Resulting distance, a reference to this distance after assignment

References Meters, meters(), and setDistance().

◆ operator==()

bool Isis::Distance::operator== ( const Distance otherDistance) const
inline

Compare two distances with the == operator.

Two uninitialized distances are equal to each other.

Parameters
otherDistanceThis is the distance we're comparing to, i.e. on the right hand side of the operator when used
Returns
True if this distance is equal to the given distance

References meters().

◆ operator>()

bool Isis::Distance::operator> ( const Distance otherDistance) const

Compare two distances with the greater than operator.

Parameters
otherDistanceThis is the distance we're comparing to, i.e. on the right hand side of the operator when used
Returns
True if this distance is greater than the given distance

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

◆ operator>=()

bool Isis::Distance::operator>= ( const Distance otherDistance) const
inline

Compare two distances with the greater than or equal to operator.

Parameters
otherDistanceThis is the distance we're comparing to, i.e. on the right hand side of the operator when used
Returns
True if this distance is greater than or equal to the given distance

◆ pixels()

double Isis::Distance::pixels ( double  pixelsPerMeter = 1.0) const

Get the distance in pixels using the given conversion ratio.

Parameters
pixelsPerMeterPixels/Meters conversion ratio to use, stored data is always in meters
Returns
Current distance, in pixels, guaranteed to be >= 0.0 if pixelsPerMeter is positive

References distance(), and Meters.

Referenced by Isis::RawCubeChunk::RawCubeChunk().

◆ setDistance()

void Isis::Distance::setDistance ( const double &  distance,
Units  distanceUnit 
)
protectedvirtual

This is a helper method to set distances in a universal manner with uniform error checking.

Parameters
distanceThe distance, in units of distanceUnit, to set this class to. If this is negative an exception will be thrown and the state unmodified.
distanceUnitUnit of distance. If this is invalid, an exception will be thrown and the state left unmodified.

References _FILEINFO_, distance(), Isis::IsSpecial(), Kilometers, Meters, Isis::Null, Pixels, Isis::IException::Programmer, and SolarRadii.

Referenced by Distance(), operator*=(), operator+=(), operator-=(), operator/=(), operator=(), setKilometers(), setMeters(), setPixels(), and setSolarRadii().

◆ setKilometers()

void Isis::Distance::setKilometers ( double  distanceInKilometers)

Set the distance in kilometers.

Parameters
distanceInKilometersThis is the value to set this distance to, given in kilometers. This will throw an exception if the value is negative.

References Kilometers, and setDistance().

◆ setMeters()

void Isis::Distance::setMeters ( double  distanceInMeters)

Set the distance in meters.

Parameters
distanceInMetersThis is the value to set this distance to, given in meters. This will throw an exception if the value is negative.

References Meters, and setDistance().

Referenced by Isis::BundleResults::initialize().

◆ setPixels()

void Isis::Distance::setPixels ( double  distanceInPixels,
double  pixelsPerMeter = 1.0 
)

Set the distance in pixels.

Parameters
distanceInPixelsThis is the value to set this distance to, given in pixels. This will throw an exception if the distance is negative after the conversion to meters.
pixelsPerMeterPixels/Meters conversion ratio to use, stored data is always in meters

References Meters, and setDistance().

◆ setSolarRadii()

void Isis::Distance::setSolarRadii ( double  distanceInSolarRadii)

Set the distance in solar radii.

Parameters
distanceInSolarRadiiThis is the value to set this distance to, given in solar radii. This will throw an exception if the value is negative.

References setDistance(), and SolarRadii.

◆ solarRadii()

double Isis::Distance::solarRadii ( ) const

Get the distance in solar radii (a unit of ~696,265km).

Returns
Current distance, in solar radii, guaranteed to be >= 0.0

References distance(), and SolarRadii.

◆ toString()

QString Isis::Distance::toString ( ) const

Get a textual representation of this distance.

Returns
XXX meters (or empty string if not valid).

References isValid(), meters(), and Isis::toString().

Friends And Related Function Documentation

◆ operator*

Distance operator* ( double  mult,
Distance  dist 
)
friend

Multiply this distance by a value (5m * 2 = 10m).

Parameters
multThis is the value to multiply by
distThis is the distance to multiply into
Returns
Resulting value

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