CARMA C++
carma::services::Distance Class Reference

The Distance class can represent an distance in any units. More...

#include <carma/services/Distance.h>

Inheritance diagram for carma::services::Distance:
carma::services::Length carma::services::ConformableQuantity

Public Member Functions

 Distance (double value, const std::string &units)
 Construct an Distance given a value and units. More...
 
const Angle getParallax () const
 Get the equivalent trigonometric parallax for this distance. More...
 
bool isInfinite () const
 
const Distance operator+ (const Distance &distance) const
 Add two Distances. More...
 
Distanceoperator+= (const Distance &distance)
 Increment Distance. More...
 
const Distance operator- (const Distance &distance) const
 Subtract two Distances. More...
 
Distanceoperator-= (const Distance &distance)
 Decrement Distance. More...
 
virtual ~Distance ()
 Destructor. More...
 
- Public Member Functions inherited from carma::services::Length
 Length (double value, const std::string &units)
 Construct an Length given a value and units. More...
 
double meters () const
 Convenience method to return value in meters. More...
 
double millimeters () const
 Convenience method to return value in millimeters. More...
 
const Length operator+ (const Length &length) const
 Add two Lengths. More...
 
Lengthoperator+= (const Length &frequency)
 Increment Length. More...
 
const Length operator- (const Length &length) const
 Subtract two Lengths. More...
 
Lengthoperator-= (const Length &frequency)
 Decrement Length. More...
 
virtual ~Length ()
 Destructor. More...
 
- Public Member Functions inherited from carma::services::ConformableQuantity
 ConformableQuantity (double value, const std::string &units)
 Construct an ConformableQuantity given a value and units. More...
 
virtual double convert (const std::string &convertTo) const
 Converts this quantity to any conformable units. More...
 
virtual std::string getUnits () const
 
double getValue () const
 
virtual const ConformableQuantity operator+ (const ConformableQuantity &quantity) const
 Add two ConformableQuantities. More...
 
virtual ConformableQuantityoperator+= (const ConformableQuantity &quantity)
 Add ConformableQuantity to itself. More...
 
virtual const ConformableQuantity operator- (const ConformableQuantity &quantity) const
 Subtract two ConformableQuantities. More...
 
virtual ConformableQuantityoperator-= (const ConformableQuantity &quantity)
 Subtract ConformableQuantity from itself. More...
 
virtual void reset (double value, const std::string &units)
 Reset method to change value and/or units. More...
 
virtual ~ConformableQuantity ()
 Destructor. More...
 

Static Public Member Functions

static Distance getDistance (const Angle &parallax)
 Given an parallax angle, return the equivalent distance. More...
 

Additional Inherited Members

- Protected Attributes inherited from carma::services::ConformableQuantity
Units u_
 Used for converting between units. More...
 

Detailed Description

The Distance class can represent an distance in any units.

Distance subclasses Length–the main difference is that distances are not allowed to be negative. As with other Conformable Quantities, Distance uses the Units class internally to handle conversion of any distance unit to any other distance unit. For example,
Distance distance1(149598000.0,"km")
Distance distance2(1.0,"au")
both distance1 and distance2 represent the same physical quantity. Binary operations + and - are supported, as is the stream operation <<.

See Also
carma::services::ConformableQuantity
carma::services::Length

Definition at line 43 of file Distance.h.

Constructor & Destructor Documentation

carma::services::Distance::Distance ( double  value,
const std::string &  units 
)

Construct an Distance given a value and units.

Parameters
valueThe non-negative value of this distance
unitsThe units of the value.
Exceptions
IllegalArgumentExceptionif value < 0.
virtual carma::services::Distance::~Distance ( )
virtual

Destructor.

Member Function Documentation

static Distance carma::services::Distance::getDistance ( const Angle parallax)
static

Given an parallax angle, return the equivalent distance.

Parameters
parallaxAn Angle representing the parallax
Returns
A Distance object containing the distance to the source in parsec.
const Angle carma::services::Distance::getParallax ( ) const

Get the equivalent trigonometric parallax for this distance.

It is returned in the Angle container, with default units "arcsec".
Parallax(arcsec) = 1 / Distance[pc] If isInfinite() is true, a zero parallax is guaranteed.

See Also
Distance::isInfinite()
const Distance carma::services::Distance::operator+ ( const Distance distance) const

Add two Distances.

Returns
a Distance with kilometer units that is the sum of the two Distances.
Exceptions
ConformabilityException
Distance& carma::services::Distance::operator+= ( const Distance distance)

Increment Distance.

Returns
incremented Distance
const Distance carma::services::Distance::operator- ( const Distance distance) const

Subtract two Distances.

Returns
an Distance with kilometer units that is the difference of the two distances
Exceptions
ConformabilityException
Distance& carma::services::Distance::operator-= ( const Distance distance)

Decrement Distance.

Returns
decremented Distance

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