CARMA C++
Distance.h
Go to the documentation of this file.
1 // $Id: Distance.h,v 1.7 2004/10/03 19:46:28 mpound Exp $
2 
13 #ifndef CARMA_SERVICES_DISTANCE_H
14 #define CARMA_SERVICES_DISTANCE_H
15 
17 #include "carma/services/Length.h"
18 #include "carma/services/Angle.h"
19 #include <iostream>
20 #include <string>
21 
22 namespace carma {
23  namespace services {
43  class Distance : public Length {
44  public:
45 
52  Distance(double value, const std::string& units);
53 
55  virtual ~Distance();
56 
57 
67  const Angle getParallax() const;
68 
75  static Distance getDistance(const Angle& parallax);
76 
77  /*
78  * @return True if this represents an ''infinite'' distance.
79  * That is, it is far away enough that there is no
80  * parallax. The CARMA convention is that (distance == 0)
81  * means infinite.
82  */
83  bool isInfinite() const;
84 
91  const Distance operator+(const Distance& distance) const;
92 
99  const Distance operator-(const Distance& distance) const;
100 
105  Distance &operator+=(const Distance &distance);
106 
111  Distance &operator-=(const Distance &distance);
112 
113  };
117  std::ostream& operator<<(std::ostream& os,
118  const carma::services::Distance& distance);
119 
120  }
121 }
122 
123 
124 #endif //CARMA_SERVICES_DISTANCE_H
const Angle getParallax() const
Get the equivalent trigonometric parallax for this distance.
const Distance operator+(const Distance &distance) const
Add two Distances.
Representation of an angle, return values are always modulo 2PI radians.
Distance & operator-=(const Distance &distance)
Decrement Distance.
const Distance operator-(const Distance &distance) const
Subtract two Distances.
The Distance class can represent an distance in any units.
Definition: Distance.h:43
Representation of Length in any units.
The Angle class can represent any angle in any units.
Definition: Angle.h:38
Distance & operator+=(const Distance &distance)
Increment Distance.
virtual ~Distance()
Destructor.
static Distance getDistance(const Angle &parallax)
Given an parallax angle, return the equivalent distance.
Parent class for representations of quantities that can have conformable units, e.g.
std::ostream & operator<<(std::ostream &os, const carma::services::Angle &angle)
Define the &lt;&lt; operator to allow, e.g.
The Length class can represent a length in any units.
Definition: Length.h:36
Distance(double value, const std::string &units)
Construct an Distance given a value and units.