Isis 3 Developer Reference
Isis::Displacement Class Reference

Displacement is a signed length, usually in meters. More...

#include <Displacement.h>

Collaboration diagram for Isis::Displacement:
Collaboration graph

Public Types

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

Public Member Functions

 Displacement ()
 This initializes the displacement to an invalid state. More...
 
 Displacement (double displacement, Units distanceUnit)
 This is the general purpose constructor for Displacement. More...
 
 Displacement (double displacementInPixels, double pixelsPerMeter)
 This is a constructor for Displacement given pixels with a conversion ratio. More...
 
 Displacement (const Distance &distanceToCopy)
 This creates a displacement equal to a distance. More...
 
 ~Displacement ()
 Free the memory allocated by this instance of the displacement class. More...
 
double meters () const
 Get the displacement in meters. More...
 
void setMeters (double displacementInMeters)
 Set the displacement in meters. More...
 
double kilometers () const
 Get the displacement in kilometers. More...
 
void setKilometers (double displacementInKilometers)
 Set the displacement in kilometers. More...
 
double pixels (double pixelsPerMeter=1.0) const
 Get the displacement in pixels using the given conversion ratio. More...
 
void setPixels (double distanceInPixels, double pixelsPerMeter=1.0)
 Set the displacement in pixels. More...
 
bool isValid () const
 Test if this displacement has been initialized or not. More...
 
bool operator> (const Displacement &otherDisplacement) const
 
Get the displacement in meters. More...
 
bool operator< (const Displacement &otherDisplacement) const
 Compare two displacements with the less than operator. More...
 
bool operator>= (const Displacement &otherDisplacement) const
 Compare the distances of 2 displacements with the >= operator. More...
 
bool operator<= (const Displacement &otherDisplacement) const
 Compare the lengths of 2 displacements with the <= operator. More...
 
bool operator!= (const Displacement &otherDisplacement) const
 Compare the lengths of 2 displacements with the != operator. More...
 
bool operator== (const Displacement &otherDisplacement) const
 Compare the lengths of 2 displacements with the == operator. More...
 
Displacement operator+ (const Displacement &displacementToAdd) const
 Add another displacement to this displacement (1km + 5m = 1005m) More...
 
Displacement operator- (const Displacement &displacementToSub) const
 Subtract another displacement from this displacement (1km - 5m = 995m). More...
 
Displacement operator- (const Distance &distanceToSub) const
 Subtract a distance from this displacement (1km - 5m = 995m). More...
 
double operator/ (const Displacement &displacementToDiv) const
 Divide another displacement into this displacement (5m / 1m = 5). More...
 
Displacement operator/ (const double &valueToDiv) const
 Divide a value from this displacement (5m / 2 = 2.5m). More...
 
Displacement operator* (const double &valueToMult) const
 Multiply this displacement by a value (5m * 2 = 10m). More...
 
void operator+= (const Displacement &displacementToAdd)
 Add and assign the given displacement to ourselves. More...
 
void operator-= (const Displacement &displacementToSub)
 Subtract the given displacement from ourself and assign. More...
 
void operator-= (const Distance &distanceToSub)
 Subtract the given distance from ourself and assign. More...
 
void operator/= (const double &valueToDiv)
 Divide this displacement by a value and assign the result to ourself. More...
 
void operator*= (const double &valueToMult)
 Multiply this displacement by a value and assign the result to ourself. More...
 

Protected Member Functions

double displacement (Units displacementUnit) const
 This is a helper method to access displacements in a universal manner with uniform error checking. More...
 
void setDisplacement (const double &displacement, Units displacementUnit)
 This is a helper method to set displacements in a universal manner with uniform error checking. More...
 

Friends

Displacement operator* (double mult, Displacement displacement)
 Multiply displacement by a value (5m * 2 = 10m). More...
 

Detailed Description

Displacement is a signed length, usually in meters.

This class is designed to encapsulate the concept of a displacement. A displacement has a distance and a sense of direction indicated by a sign (+ or -). It is typically used for vectors or coordinates, but is also available as a general purpose class. This class does accept both positive and negative values.

Author
2010-10-12 Steven Lambright and Debbie A. Cook

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.

Constructor & Destructor Documentation

◆ Displacement() [1/4]

Isis::Displacement::Displacement ( )

This initializes the displacement to an invalid state.

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

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

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

◆ Displacement() [2/4]

Isis::Displacement::Displacement ( double  displacement,
Units  displacementUnit 
)

This is the general purpose constructor for Displacement.

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

Parameters
displacementThe initial displacement; must be in units of displacementUnit
displacementUnitThe unit of displacement; can be any value in displacement::Units

References displacement(), Meters, Pixels, and setDisplacement().

◆ Displacement() [3/4]

Isis::Displacement::Displacement ( double  displacementInPixels,
double  pixelsPerMeter 
)

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

This will initialize with the pixels converted to meters.

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

References Meters, and setDisplacement().

◆ Displacement() [4/4]

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

This creates a displacement equal to a distance.

Parameters
distanceToCopyThis is the distance we are duplicating

References Meters, Isis::Distance::meters(), and setDisplacement().

◆ ~Displacement()

Isis::Displacement::~Displacement ( )
inline

Free the memory allocated by this instance of the displacement class.

Member Function Documentation

◆ displacement()

double Isis::Displacement::displacement ( Units  displacementUnit) const
protected

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

Parameters
displacementUnitUnit of the return value. If this is invalid, an exception will be thrown.
Returns
The displacement in units of displacementUnit

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

Referenced by Displacement(), isValid(), kilometers(), meters(), pixels(), and setDisplacement().

◆ isValid()

bool Isis::Displacement::isValid ( ) const

Test if this displacement has been initialized or not.

Returns
True if this displacement has been initialized.

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

Referenced by Isis::ControlPoint::HasAprioriCoordinates(), operator*(), operator*=(), operator+=(), operator-=(), operator/(), operator/=(), operator<(), operator>(), and Isis::Area3D::setArea().

◆ kilometers()

◆ meters()

◆ operator!=()

bool Isis::Displacement::operator!= ( const Displacement otherDisplacement) const
inline

Compare the lengths of 2 displacements with the != operator.

Two uninitialized displacements are equal to each other.

Parameters
otherDisplacementThis is the displacement we are comparing to, i.e. it is on the right-hand-side of the operator when used
Returns
True if the length of this displacement is not equal to the given displacement

◆ operator*()

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

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

Parameters
valueToMultThis is the value to multiply by
Returns
Resulting value

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

◆ operator*=()

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

Multiply this displacement 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 setDisplacement().

◆ operator+()

Displacement Isis::Displacement::operator+ ( const Displacement displacementToAdd) const

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

Parameters
displacementToAddThis is the displacement we are adding to ourselves
Returns
Resulting displacement, self not modified

◆ operator+=()

void Isis::Displacement::operator+= ( const Displacement displacementToAdd)

Add and assign the given displacement to ourselves.

Parameters
displacementToAddThis is the displacement we are to add

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

◆ operator-() [1/2]

Displacement Isis::Displacement::operator- ( const Displacement displacementToSub) const

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

Parameters
displacementToSubThis is the displacement we are subtracting from ourself
Returns
Resulting displacement, self not modified

◆ operator-() [2/2]

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

Subtract a distance from this displacement (1km - 5m = 995m).

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

◆ operator-=() [1/2]

void Isis::Displacement::operator-= ( const Displacement displacementToSub)

Subtract the given displacement from ourself and assign.

Parameters
displacementToSubThis is the displacement we are to subtract

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

◆ operator-=() [2/2]

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

Subtract the given distance from ourself and assign.

Parameters
distanceToSubThis is the distance we are to subtract

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

◆ operator/() [1/2]

double Isis::Displacement::operator/ ( const Displacement displacementToDiv) const

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

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

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

◆ operator/() [2/2]

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

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

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

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

◆ operator/=()

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

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

Parameters
valueToDivThis is the value we are going to divide by

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

◆ operator<()

bool Isis::Displacement::operator< ( const Displacement otherDisplacement) const

Compare two displacements with the less than operator.

Parameters
otherdisplacementThis is the displacement we're comparing to, i.e. on the right-hand-side of the operator when used
Returns
True if the length of the displacement is less than the length of the given displacement

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

◆ operator<=()

bool Isis::Displacement::operator<= ( const Displacement otherDisplacement) const
inline

Compare the lengths of 2 displacements with the <= operator.

Parameters
otherDisplacementThis is the displacement we are comparing i.e. it is on the right-hand-side of the operator when used
Returns
True if the length of this displacement is less than or equal to the length of the given displacement.

◆ operator==()

bool Isis::Displacement::operator== ( const Displacement otherDisplacement) const
inline

Compare the lengths of 2 displacements with the == operator.

Two uninitialized displacements are equal to each other.

Parameters
otherDisplacementThis is the displacement we are comparing to, i.e. it is on the right-hand-side of the operator when used
Returns
True if the length of this displacement is equal to the
given displacement

◆ operator>()

bool Isis::Displacement::operator> ( const Displacement otherDisplacement) const


Get the displacement in meters.

Compare two displacements with the greater than operator.

This is equivalent to meters()

Returns
The displacement, as a number, in units of Meters

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

Parameters
otherdisplacementThis is the displacement we're comparing to, i.e. it is on the right-hand-side of the operator when used
Returns
True if the length of this displacement is greater than the length of the given displacement

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

◆ operator>=()

bool Isis::Displacement::operator>= ( const Displacement otherDisplacement) const
inline

Compare the distances of 2 displacements with the >= operator.

Parameters
otherDisplacementThis is the displacement we are comparing to, i.e. it is on the right-hand-side of the operator when used
Returns
True if the length (unsigned) of the displacement is greater than or equal to the length of the given displacement

◆ pixels()

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

Get the displacement in pixels using the given conversion ratio.

Parameters
pixelsPerMeterPixels/Meters conversion ratio to use, stored data is always in meters
Returns
Current displacement, in pixels

References displacement(), and Meters.

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

◆ setDisplacement()

void Isis::Displacement::setDisplacement ( const double &  displacement,
Units  displacementUnit 
)
protected

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

Parameters
displacementThe displacement, in units of displacementUnit, to set this class to. If this is negative an exception will be thrown and the state unmodified.
displacementUnitUnit of displacement. If this is invalid, an exception will be thrown and the state left unmodified.

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

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

◆ setKilometers()

void Isis::Displacement::setKilometers ( double  displacementInKilometers)

Set the displacement in kilometers.

Parameters
displacementInKilometersThis is the value to set as the displacement, given in kilometers.

References Kilometers, and setDisplacement().

◆ setMeters()

void Isis::Displacement::setMeters ( double  displacementInMeters)

Set the displacement in meters.

Parameters
displacementInMetersThis is the value to set this displacement to, given in meters.

References Meters, and setDisplacement().

◆ setPixels()

void Isis::Displacement::setPixels ( double  displacementInPixels,
double  pixelsPerMeter = 1.0 
)

Set the displacement in pixels.

Parameters
displacementInPixelsThis is the value to set this displacement to, given in pixels.
pixelsPerMeterPixels/Meters conversion ratio to use, stored data is always in meters

References Meters, and setDisplacement().

Friends And Related Function Documentation

◆ operator*

Displacement operator* ( double  mult,
Displacement  displacement 
)
friend

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

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

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