|  | Isis 3 Programmer Reference
    | 
Displacement is a signed length, usually in meters. More...
#include <Displacement.h>

| 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 | meters () const | 
| Get the displacement in meters. | |
| void | setMeters (double displacementInMeters) | 
| Set the displacement in meters. | |
| double | kilometers () const | 
| Get the displacement in kilometers. | |
| void | setKilometers (double displacementInKilometers) | 
| Set the displacement in kilometers. | |
| double | pixels (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 | isValid () 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 | displacement (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. | |
| Private Attributes | |
| double | m_displacementInMeters | 
| This is the displacement value that this class is encapsulating, always stored in meters. | |
| Friends | |
| Displacement | operator* (double mult, Displacement displacement) | 
| Multiply displacement by a value (5m * 2 = 10m). | |
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.
Definition at line 31 of file Displacement.h.
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. | 
Definition at line 38 of file Displacement.h.
| 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.
Definition at line 20 of file Displacement.cpp.
References Meters, Isis::Null, and setDisplacement().
Referenced by operator*(), and operator/().
| 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.
| displacement | The initial displacement; must be in units of displacementUnit | 
| displacementUnit | The unit of displacement; can be any value in displacement::Units | 
Definition at line 46 of file Displacement.cpp.
References displacement(), Meters, Pixels, and setDisplacement().
| 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.
| displacementInPixels | The displacement to initialize with, must be in units of pixels and should not be negative | 
| pixelsPerMeter | The pixels/meter conversion factor | 
Definition at line 62 of file Displacement.cpp.
References Meters, and setDisplacement().
| Isis::Displacement::Displacement | ( | const Distance & | distanceToCopy | ) | 
This creates a displacement equal to a distance.
| distanceToCopy | This is the distance we are duplicating | 
Definition at line 30 of file Displacement.cpp.
References Meters, and setDisplacement().
| 
 | inline | 
Free the memory allocated by this instance of the displacement class.
Definition at line 55 of file Displacement.h.
| 
 | protected | 
This is a helper method to access displacements in a universal manner with uniform error checking.
| displacementUnit | Unit of the return value. If this is invalid, an exception will be thrown. | 
Definition at line 358 of file Displacement.cpp.
References Kilometers, m_displacementInMeters, Meters, Isis::Null, Pixels, and Isis::IException::Programmer.
Referenced by Displacement(), isValid(), kilometers(), meters(), pixels(), and setDisplacement().
| bool Isis::Displacement::isValid | ( | ) | const | 
Test if this displacement has been initialized or not.
Definition at line 141 of file Displacement.cpp.
References displacement(), Meters, and Isis::Null.
Referenced by operator*(), operator*=(), operator+=(), operator-=(), operator-=(), operator/(), operator/(), operator/=(), operator<(), operator>(), Isis::SurfacePoint::ResetLocalRadius(), and Isis::SurfacePoint::SetRectangularPoint().
| double Isis::Displacement::kilometers | ( | ) | const | 
Get the displacement in kilometers.
Definition at line 94 of file Displacement.cpp.
References displacement(), and Kilometers.
Referenced by Isis::BundleLidarRangeConstraint::computeRange(), Isis::BundleControlPoint::formatBundleLatitudinalOutputDetailString(), Isis::BundleControlPoint::formatBundleRectangularOutputDetailString(), Isis::CameraGroundMap::GetXY(), Isis::Camera::LocalPhotometricAngles(), Isis::Sensor::SolarDistance(), and Isis::SurfacePoint::ToNaifArray().
| double Isis::Displacement::meters | ( | ) | const | 
Get the displacement in meters.
Definition at line 73 of file Displacement.cpp.
References displacement(), and Meters.
Referenced by Isis::SurfacePoint::ComputeLocalRadius(), Isis::QnetSetAprioriDialog::fillAverageAprioriLineEdits(), Isis::SurfacePoint::GetLatitude(), Isis::SurfacePoint::GetLongitude(), Isis::IsisShape::intersect(), operator*(), operator*=(), operator+=(), operator-=(), operator-=(), operator/(), operator/(), operator/=(), operator<(), operator>(), Isis::SurfacePoint::SetRectangularMatrix(), Isis::Projection::SetUpperLeftCorner(), Isis::ControlNetVersioner::toPvl(), and Isis::ControlNetVersioner::writeFirstPoint().
| 
 | inline | 
Compare the lengths of 2 displacements with the != operator.
Two uninitialized displacements are equal to each other.
| otherDisplacement | This is the displacement we are comparing to, i.e. it is on the right-hand-side of the operator when used | 
Definition at line 116 of file Displacement.h.
| Displacement Isis::Displacement::operator* | ( | const double & | valueToMult | ) | const | 
Multiply this displacement by a value (5m * 2 = 10m).
| valueToMult | This is the value to multiply by | 
Definition at line 264 of file Displacement.cpp.
References Displacement(), Isis::IsSpecial(), isValid(), Meters, and meters().
| void Isis::Displacement::operator*= | ( | const double & | valueToMult | ) | 
Multiply this displacement by a value and assign the result to ourself.
| valueToMult | This is the value we are going to multiply by | 
Definition at line 342 of file Displacement.cpp.
References Isis::IsSpecial(), isValid(), Meters, meters(), Isis::Null, and setDisplacement().
| Displacement Isis::Displacement::operator+ | ( | const Displacement & | displacementToAdd | ) | const | 
Add another displacement to this displacement (1km + 5m = 1005m)
| displacementToAdd | This is the displacement we are adding to ourselves | 
Definition at line 190 of file Displacement.cpp.
| void Isis::Displacement::operator+= | ( | const Displacement & | displacementToAdd | ) | 
Add and assign the given displacement to ourselves.
| displacementToAdd | This is the displacement we are to add | 
Definition at line 290 of file Displacement.cpp.
References isValid(), Meters, meters(), Isis::Null, and setDisplacement().
| Displacement Isis::Displacement::operator- | ( | const Displacement & | displacementToSub | ) | const | 
Subtract another displacement from this displacement (1km - 5m = 995m).
| displacementToSub | This is the displacement we are subtracting from ourself | 
Definition at line 205 of file Displacement.cpp.
| Displacement Isis::Displacement::operator- | ( | const Distance & | distanceToSub | ) | const | 
Subtract a distance from this displacement (1km - 5m = 995m).
| distanceToSub | This is the displacement we are subtracting from ourself | 
Definition at line 221 of file Displacement.cpp.
| void Isis::Displacement::operator-= | ( | const Displacement & | displacementToSub | ) | 
Subtract the given displacement from ourself and assign.
| displacementToSub | This is the displacement we are to subtract | 
Definition at line 303 of file Displacement.cpp.
References isValid(), Meters, meters(), Isis::Null, and setDisplacement().
| void Isis::Displacement::operator-= | ( | const Distance & | distanceToSub | ) | 
Subtract the given distance from ourself and assign.
| distanceToSub | This is the distance we are to subtract | 
Definition at line 316 of file Displacement.cpp.
References isValid(), Meters, meters(), Isis::Null, and setDisplacement().
| double Isis::Displacement::operator/ | ( | const Displacement & | displacementToDiv | ) | const | 
Divide another displacement into this displacement (5m / 1m = 5).
| displacementToDiv | This is the divisor displacement (denominator) | 
Definition at line 236 of file Displacement.cpp.
References isValid(), meters(), and Isis::Null.
| Displacement Isis::Displacement::operator/ | ( | const double & | valueToDiv | ) | const | 
Divide a value from this displacement (5m / 2 = 2.5m).
| valueToDiv | This is the divisor displacement (denominator) | 
Definition at line 250 of file Displacement.cpp.
References Displacement(), Isis::IsSpecial(), isValid(), Meters, and meters().
| void Isis::Displacement::operator/= | ( | const double & | valueToDiv | ) | 
Divide this displacement by a value and assign the result to ourself.
| valueToDiv | This is the value we are going to divide by | 
Definition at line 329 of file Displacement.cpp.
References Isis::IsSpecial(), isValid(), Meters, meters(), Isis::Null, and setDisplacement().
| bool Isis::Displacement::operator< | ( | const Displacement & | otherDisplacement | ) | const | 
Compare two displacements with the less than operator.
| otherdisplacement | This is the displacement we're comparing to, i.e. on the right-hand-side of the operator when used | 
Definition at line 173 of file Displacement.cpp.
References isValid(), meters(), and Isis::IException::Programmer.
| 
 | inline | 
Compare the lengths of 2 displacements with the <= operator.
| otherDisplacement | This is the displacement we are comparing i.e. it is on the right-hand-side of the operator when used | 
Definition at line 102 of file Displacement.h.
| 
 | inline | 
Compare the lengths of 2 displacements with the == operator.
Two uninitialized displacements are equal to each other.
| otherDisplacement | This is the displacement we are comparing to, i.e. it is on the right-hand-side of the operator when used | 
Definition at line 130 of file Displacement.h.
References m_displacementInMeters.
| 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()
operator double() const { return meters(); }
| otherdisplacement | This is the displacement we're comparing to, i.e. it is on the right-hand-side of the operator when used | 
Definition at line 154 of file Displacement.cpp.
References isValid(), meters(), and Isis::IException::Programmer.
| 
 | inline | 
Compare the distances of 2 displacements with the >= operator.
| otherDisplacement | This is the displacement we are comparing to, i.e. it is on the right-hand-side of the operator when used | 
Definition at line 89 of file Displacement.h.
| double Isis::Displacement::pixels | ( | double | pixelsPerMeter = 1.0 | ) | const | 
Get the displacement in pixels using the given conversion ratio.
| pixelsPerMeter | Pixels/Meters conversion ratio to use, stored data is always in meters | 
Definition at line 117 of file Displacement.cpp.
References displacement(), and Meters.
| 
 | protected | 
This is a helper method to set displacements in a universal manner with uniform error checking.
| 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. | 
Definition at line 400 of file Displacement.cpp.
References displacement(), Isis::IsSpecial(), Kilometers, m_displacementInMeters, Meters, Isis::Null, Pixels, and Isis::IException::Programmer.
Referenced by Displacement(), Displacement(), Displacement(), Displacement(), operator*=(), operator+=(), operator-=(), operator-=(), operator/=(), setKilometers(), setMeters(), and setPixels().
| void Isis::Displacement::setKilometers | ( | double | displacementInKilometers | ) | 
Set the displacement in kilometers.
| displacementInKilometers | This is the value to set as the displacement, given in kilometers. | 
Definition at line 105 of file Displacement.cpp.
References Kilometers, and setDisplacement().
Referenced by Isis::SurfacePoint::FromNaifArray(), and Isis::SurfacePoint::ResetLocalRadius().
| void Isis::Displacement::setMeters | ( | double | displacementInMeters | ) | 
Set the displacement in meters.
| displacementInMeters | This is the value to set this displacement to, given in meters. | 
Definition at line 84 of file Displacement.cpp.
References Meters, and setDisplacement().
| void Isis::Displacement::setPixels | ( | double | displacementInPixels, | 
| double | pixelsPerMeter = 1.0 ) | 
Set the displacement in pixels.
| 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 | 
Definition at line 130 of file Displacement.cpp.
References Meters, and setDisplacement().
| 
 | friend | 
Multiply displacement by a value (5m * 2 = 10m).
| mult | This is the value to multiply by | 
| displacement | This is the distance to multiply into | 
Definition at line 279 of file Displacement.cpp.
| 
 | private | 
This is the displacement value that this class is encapsulating, always stored in meters.
Definition at line 157 of file Displacement.h.
Referenced by displacement(), operator==(), and setDisplacement().