Isis 3 Developer Reference
Displacement.h
Go to the documentation of this file.
1 #ifndef Displacement_h
2 #define Displacement_h
3 
23 namespace Isis {
24  class Distance;
25 
43  class Displacement {
44  public:
50  enum Units {
57  };
58 
59  Displacement();
60  Displacement(double displacement, Units distanceUnit);
61  Displacement(double displacementInPixels, double pixelsPerMeter);
62  Displacement(const Distance &distanceToCopy);
63 
68 
69  double meters() const;
70  void setMeters(double displacementInMeters);
71 
72  double kilometers() const;
73  void setKilometers(double displacementInKilometers);
74 
75  double pixels(double pixelsPerMeter = 1.0) const;
76  void setPixels(double distanceInPixels, double pixelsPerMeter = 1.0);
77 
78  bool isValid() const;
79 
89  bool operator >(const Displacement &otherDisplacement) const;
90  bool operator <(const Displacement &otherDisplacement) const;
91 
92 
101  bool operator >=(const Displacement &otherDisplacement) const {
102  return *this > otherDisplacement || *this == otherDisplacement;
103  }
104 
105 
114  bool operator <=(const Displacement &otherDisplacement) const {
115  return *this < otherDisplacement || *this == otherDisplacement;
116  }
117 
128  bool operator !=(const Displacement &otherDisplacement) const {
129  return !(*this == otherDisplacement);
130  }
131 
142  bool operator ==(const Displacement &otherDisplacement) const {
143  return m_displacementInMeters ==
144  otherDisplacement.m_displacementInMeters;
145  }
146 
147  Displacement operator +(const Displacement &displacementToAdd) const;
148  Displacement operator -(const Displacement &displacementToSub) const;
149  Displacement operator -(const Distance &distanceToSub) const;
150  double operator /(const Displacement &displacementToDiv) const;
151  Displacement operator /(const double &valueToDiv) const;
152  Displacement operator *(const double &valueToMult) const;
153  friend Displacement operator *(double mult, Displacement displacement);
154  void operator +=(const Displacement &displacementToAdd);
155  void operator -=(const Displacement &displacementToSub);
156  void operator -=(const Distance &distanceToSub);
157  void operator /=(const double &valueToDiv);
158  void operator *=(const double &valueToMult);
159 
160  protected:
161  double displacement(Units displacementUnit) const;
162  void setDisplacement(const double &displacement, Units displacementUnit);
163 
164  private:
169  double m_displacementInMeters;
170  };
171 }
172 
173 #endif
Displacement operator-(const Displacement &displacementToSub) const
Subtract another displacement from this displacement (1km - 5m = 995m).
Definition: Displacement.cpp:219
The distance is being specified in kilometers.
Definition: Displacement.h:54
void setKilometers(double displacementInKilometers)
Set the displacement in kilometers.
Definition: Displacement.cpp:118
double meters() const
Get the displacement in meters.
Definition: Displacement.cpp:86
bool isValid() const
Test if this displacement has been initialized or not.
Definition: Displacement.cpp:154
void operator*=(const double &valueToMult)
Multiply this displacement by a value and assign the result to ourself.
Definition: Displacement.cpp:355
bool operator>=(const Displacement &otherDisplacement) const
Compare the distances of 2 displacements with the >= operator.
Definition: Displacement.h:101
The distance is being specified in meters.
Definition: Displacement.h:52
Distance measurement, usually in meters.
Definition: Distance.h:47
bool operator<(const Displacement &otherDisplacement) const
Compare two displacements with the less than operator.
Definition: Displacement.cpp:186
void setPixels(double distanceInPixels, double pixelsPerMeter=1.0)
Set the displacement in pixels.
Definition: Displacement.cpp:143
double displacement(Units displacementUnit) const
This is a helper method to access displacements in a universal manner with uniform error checking...
Definition: Displacement.cpp:371
The distance is being specified in pixels.
Definition: Displacement.h:56
Units
This is a list of available units to access and store Distances in.
Definition: Displacement.h:50
bool operator==(const Displacement &otherDisplacement) const
Compare the lengths of 2 displacements with the == operator.
Definition: Displacement.h:142
bool operator>(const Displacement &otherDisplacement) const
Get the displacement in meters.
Definition: Displacement.cpp:167
bool operator<=(const Displacement &otherDisplacement) const
Compare the lengths of 2 displacements with the <= operator.
Definition: Displacement.h:114
void operator/=(const double &valueToDiv)
Divide this displacement by a value and assign the result to ourself.
Definition: Displacement.cpp:342
void operator-=(const Displacement &displacementToSub)
Subtract the given displacement from ourself and assign.
Definition: Displacement.cpp:316
Displacement is a signed length, usually in meters.
Definition: Displacement.h:43
Displacement operator*(const double &valueToMult) const
Multiply this displacement by a value (5m * 2 = 10m).
Definition: Displacement.cpp:277
double pixels(double pixelsPerMeter=1.0) const
Get the displacement in pixels using the given conversion ratio.
Definition: Displacement.cpp:130
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void setMeters(double displacementInMeters)
Set the displacement in meters.
Definition: Displacement.cpp:97
double kilometers() const
Get the displacement in kilometers.
Definition: Displacement.cpp:107
void setDisplacement(const double &displacement, Units displacementUnit)
This is a helper method to set displacements in a universal manner with uniform error checking...
Definition: Displacement.cpp:413
Displacement operator+(const Displacement &displacementToAdd) const
Add another displacement to this displacement (1km + 5m = 1005m)
Definition: Displacement.cpp:204
~Displacement()
Free the memory allocated by this instance of the displacement class.
Definition: Displacement.h:67
bool operator!=(const Displacement &otherDisplacement) const
Compare the lengths of 2 displacements with the != operator.
Definition: Displacement.h:128
double operator/(const Displacement &displacementToDiv) const
Divide another displacement into this displacement (5m / 1m = 5).
Definition: Displacement.cpp:249
void operator+=(const Displacement &displacementToAdd)
Add and assign the given displacement to ourselves.
Definition: Displacement.cpp:303
Displacement()
This initializes the displacement to an invalid state.
Definition: Displacement.cpp:33