USGS

Isis 3.0 Developer's Reference (API)

Home

Isis::Displacement Class Reference
[Utility]

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

#include <Displacement.h>

List of all members.

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

Protected Member Functions

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

Friends

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

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

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

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().

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:
displacement The initial displacement; must be in units of displacementUnit
displacementUnit The unit of displacement; can be any value in displacement::Units
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:
displacementInPixels The displacement to initialize with, must be in units of pixels and should not be negative
pixelsPerMeter The pixels/meter conversion factor
Isis::Displacement::Displacement ( const Distance distanceToCopy  ) 

This creates a displacement equal to a distance.

Parameters:
distanceToCopy This is the distance we are duplicating

References Isis::Distance::GetMeters(), Meters, and SetDisplacement().

Isis::Displacement::~Displacement (  )  [inline]

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


Member Function Documentation

double Isis::Displacement::GetDisplacement ( Units  displacementUnit  )  const [protected]

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

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

Referenced by GetKilometers(), GetMeters(), and Valid().

double Isis::Displacement::GetKilometers (  )  const
double Isis::Displacement::GetMeters (  )  const
double Isis::Displacement::GetPixels ( double  pixelsPerMeter = 1.0  )  const

Get the displacement in pixels using the given conversion ratio.

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

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

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:
otherDisplacement This 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
Displacement Isis::Displacement::operator* ( const double &  valueToMult  )  const

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

Parameters:
valueToMult This is the value to multiply by
Returns:
Resulting value
void Isis::Displacement::operator*= ( const double &  valueToMult  ) 

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

Parameters:
valueToMult This is the value we are going to multiply by

References GetMeters(), Isis::IsSpecial(), Meters, Isis::Null, SetDisplacement(), and Valid().

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

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

Parameters:
displacementToAdd This is the displacement we are adding to ourselves
Returns:
Resulting displacement, self not modified
void Isis::Displacement::operator+= ( const Displacement displacementToAdd  ) 

Add and assign the given displacement to ourselves.

Parameters:
displacementToAdd This is the displacement we are to add

References GetMeters(), Meters, Isis::Null, SetDisplacement(), and Valid().

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

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

Parameters:
distanceToSub This is the displacement we are subtracting from ourself
Returns:
Resulting displacement, self not modified
Displacement Isis::Displacement::operator- ( const Displacement displacementToSub  )  const

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

Parameters:
displacementToSub This is the displacement we are subtracting from ourself
Returns:
Resulting displacement, self not modified
void Isis::Displacement::operator-= ( const Distance distanceToSub  ) 

Subtract the given distance from ourself and assign.

Parameters:
distanceToSub This is the distance we are to subtract

References Isis::Distance::GetMeters(), GetMeters(), Meters, Isis::Null, SetDisplacement(), Isis::Distance::Valid(), and Valid().

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

Subtract the given displacement from ourself and assign.

Parameters:
displacementToSub This is the displacement we are to subtract

References GetMeters(), Meters, Isis::Null, SetDisplacement(), and Valid().

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

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

Parameters:
valueToDiv This is the divisor displacement (denominator)
Returns:
Resulting value
double Isis::Displacement::operator/ ( const Displacement displacementToDiv  )  const

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

Parameters:
displacementToDiv This is the divisor displacement (denominator)
Returns:
Resulting value
void Isis::Displacement::operator/= ( const double &  valueToDiv  ) 

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

Parameters:
valueToDiv This is the value we are going to divide by

References GetMeters(), Isis::IsSpecial(), Meters, Isis::Null, SetDisplacement(), and Valid().

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

Compare two displacements with the less than operator.

Parameters:
otherdisplacement This 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
bool Isis::Displacement::operator<= ( const Displacement otherDisplacement  )  const [inline]

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

Parameters:
otherDisplacement This 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.
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:
otherDisplacement This 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
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 GetMeters()

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

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

Parameters:
otherdisplacement This 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
bool Isis::Displacement::operator>= ( const Displacement otherDisplacement  )  const [inline]

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

Parameters:
otherDisplacement This 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
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:
displacement The displacement, in units of displacementUnit, to set this class to. If this is negative an exception will be thrown and the state unmodified.
displacementUnit Unit of displacement. If this is invalid, an exception will be thrown and the state left unmodified.

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

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

Set the displacement in kilometers.

Parameters:
displacementInKilometers This is the value to set as the displacement, given in kilometers.

Referenced by Isis::SurfacePoint::FromNaifArray(), and Isis::SurfacePoint::ResetLocalRadius().

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

Set the displacement in meters.

Parameters:
displacementInMeters This is the value to set this displacement to, given in meters.
void Isis::Displacement::SetPixels ( double  displacementInPixels,
double  pixelsPerMeter = 1.0 
)

Set the displacement in pixels.

Parameters:
displacementInPixels This is the value to set this displacement to, given in pixels.
pixelsPerMeter Pixels/Meters conversion ratio to use, stored data is always in meters
bool Isis::Displacement::Valid (  )  const

Test if this displacement has been initialized or not.

Returns:
True if this displacement has been initialized.

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

Referenced by Isis::ControlPoint::HasAprioriCoordinates(), operator*=(), operator+=(), operator-=(), operator/=(), Isis::SurfacePoint::ResetLocalRadius(), and Isis::SurfacePoint::Valid().


Friends And Related Function Documentation

Displacement operator* ( double  mult,
Displacement  displacement 
) [friend]

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

Parameters:
mult This is the value to multiply by
displacement This is the distance to multiply into
Returns:
Resulting value

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