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

The Angle class can represent any angle in any units. More...

#include <carma/services/Angle.h>

Inheritance diagram for carma::services::Angle:
carma::services::ConformableQuantity carma::services::HourAngle

Public Member Functions

 Angle ()
 Default constructor. More...
 
 Angle (double value, const std::string &units)
 Construct an Angle given a value and units. More...
 
double arcMinutes (bool modulo=false) const
 Convenience method that returns the value of this angle in arcminutes. More...
 
double arcSeconds (bool modulo=false) const
 Convenience method that returns the value of this angle in arcseconds. More...
 
double degrees (bool modulo=false) const
 Convenience method that returns the value of this angle in degrees. More...
 
std::string dms (bool modulo=true, int precision=0) const
 
double hours (bool modulo=true) const
 Convenience method that returns the value of this angle in hours. More...
 
Angleoperator*= (double scalar)
 Multiply an angle by a scalar. More...
 
const Angle operator+ (const Angle &angle) const
 Add two Angles. More...
 
Angleoperator+= (const Angle &angle)
 Add Angle. More...
 
const Angle operator- (const Angle &angle) const
 Subtract two Angles. More...
 
Angleoperator-= (const Angle &angle)
 Subtract Angle. More...
 
const Angle operator/ (double scalar) const
 Divide an angle by a scalar. More...
 
Angleoperator/= (double scalar)
 Divide by a scalar. More...
 
bool operator< (const Angle &right) const
 Less than comparison. More...
 
bool operator<= (const Angle &right) const
 Less than or equal comparison. More...
 
bool operator> (const Angle &right) const
 Greater than comparison. More...
 
bool operator>= (const Angle &right) const
 Greater than or equal comparison. More...
 
double radians (bool modulo=true) const
 Convenience method that returns the value of this angle in radians. More...
 
void setRadians (double radians)
 Set the value of this angle in radians. More...
 
virtual ~Angle ()
 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 std::string getString (double angle, int precision=0)
 Return a zero filled string +/-ddd:mm:ss.s. More...
 

Static Public Attributes

static const std::string ARCMIN_STR
 A const string that may be used for unit conversion. More...
 
static const std::string ARCSEC_STR
 A const string that may be used for unit conversion. More...
 
static const std::string DEGREES_STR
 A const string that may be used for unit conversion. More...
 
static const std::string HOURS_STR
 A const string that may be used for unit conversion. More...
 
static const std::string RADIANS_STR
 A const string that may be used for unit conversion. More...
 

Static Protected Member Functions

static std::string getAngleString (double a, int precision=0, bool dms=true, bool useSign=false)
 

Static Protected Attributes

static const double twoPi_ = 2 * M_PIl
 Two pi. More...
 

Friends

const Angle operator* (double left, const Angle &right)
 Multiply an angle by a scalar. More...
 
const Angle operator* (const Angle &left, double right)
 

Additional Inherited Members

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

Detailed Description

The Angle class can represent any angle in any units.

It uses the Units class internally to handle conversion of any angular unit to any other angular unit. For example,
Angle angle1(M_PI,"radians")
Angle angle2(180.0,"degrees")
both angle1 and angle2 represent the same physical quantity. Binary operations + and - are supported, as is the stream operation <<. This class was inspired by Erik Leitch's sza::util::Angle.

Definition at line 38 of file Angle.h.

Constructor & Destructor Documentation

carma::services::Angle::Angle ( )
explicit

Default constructor.

Constructs an angle of value 0.0.

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

Construct an Angle given a value and units.

Parameters
valueThe value of this angle
unitsThe units of the value.
virtual carma::services::Angle::~Angle ( )
virtual

Destructor.

Member Function Documentation

double carma::services::Angle::arcMinutes ( bool  modulo = false) const

Convenience method that returns the value of this angle in arcminutes.

Parameters
moduloWhether or not to return the value modulo 21600 arcminutes (=360 degrees) or not; false if you do want modulo 21600 arcminutes ; default is FALSe;
Returns
angular value in arcminute
double carma::services::Angle::arcSeconds ( bool  modulo = false) const

Convenience method that returns the value of this angle in arcseconds.

Parameters
moduloWhether or not to return the value modulo 1296000 arcseconds (=360 degrees) or not; false if you do want modulo 1296000 arcseconds; default is FALSE;
Returns
angular value in arcseconds
double carma::services::Angle::degrees ( bool  modulo = false) const

Convenience method that returns the value of this angle in degrees.

Parameters
moduloWhether or not to return the value modulo 360 degrees or not; false if you do want modulo 360 degrees; default is FALSE;
Returns
angular value in hours (0..360 if requested)
std::string carma::services::Angle::dms ( bool  modulo = true,
int  precision = 0 
) const
Parameters
moduloWhether or not to return the value modulo 360 degrees or not; false if you do want modulo 360 degrees; default is true;
precisiondigits to the right of the decimal for seconds
Returns
This angle in degrees in sexagesimal format, +/-DD:MM:SS[.ss]
static std::string carma::services::Angle::getString ( double  angle,
int  precision = 0 
)
static

Return a zero filled string +/-ddd:mm:ss.s.

Parameters
angleangle in radians
precisionnumber of digits after the decimal point

Definition at line 206 of file Angle.h.

double carma::services::Angle::hours ( bool  modulo = true) const

Convenience method that returns the value of this angle in hours.

Parameters
moduloWhether or not to return the value modulo 24 hours or not; false if you do want modulo 24 hours; default is true;
Returns
angular value in hours (0..24 if requested)
Angle& carma::services::Angle::operator*= ( double  scalar)

Multiply an angle by a scalar.

const Angle carma::services::Angle::operator+ ( const Angle angle) const

Add two Angles.

Returns
an Angle with radian units that is the sum of the two Angles modulo 2PI.
Exceptions
ConformabilityException
Angle& carma::services::Angle::operator+= ( const Angle angle)

Add Angle.

Returns
an Angle with radian units that is the sum of the two angles modulo 2PI.
Exceptions
ConformabilityException
const Angle carma::services::Angle::operator- ( const Angle angle) const

Subtract two Angles.

Returns
an Angle with radian units that is the difference of the two angles modulo 2PI.
Exceptions
ConformabilityException
Angle& carma::services::Angle::operator-= ( const Angle angle)

Subtract Angle.

Returns
an Angle with radian units that is the difference of the two angles modulo 2PI.
Exceptions
ConformabilityException
const Angle carma::services::Angle::operator/ ( double  scalar) const

Divide an angle by a scalar.

Angle& carma::services::Angle::operator/= ( double  scalar)

Divide by a scalar.

bool carma::services::Angle::operator< ( const Angle right) const

Less than comparison.

bool carma::services::Angle::operator<= ( const Angle right) const

Less than or equal comparison.

bool carma::services::Angle::operator> ( const Angle right) const

Greater than comparison.

bool carma::services::Angle::operator>= ( const Angle right) const

Greater than or equal comparison.

double carma::services::Angle::radians ( bool  modulo = true) const

Convenience method that returns the value of this angle in radians.

Parameters
moduloWhether or not to return the value modulo 2PI or not; false if you do want modulo 2PI; default is true;
Returns
angular value in radians, modulo 2PI if requested.
void carma::services::Angle::setRadians ( double  radians)

Set the value of this angle in radians.

The units will be reset to "radians".

Parameters
radiansthe new value of the Angle in radians

Definition at line 124 of file Angle.h.

Friends And Related Function Documentation

const Angle operator* ( double  left,
const Angle right 
)
friend

Multiply an angle by a scalar.

Member Data Documentation

const std::string carma::services::Angle::ARCMIN_STR
static

A const string that may be used for unit conversion.

"arcminutes"

Definition at line 256 of file Angle.h.

const std::string carma::services::Angle::ARCSEC_STR
static

A const string that may be used for unit conversion.

"arcseconds"

Definition at line 262 of file Angle.h.

const std::string carma::services::Angle::DEGREES_STR
static

A const string that may be used for unit conversion.

"degrees"

Definition at line 244 of file Angle.h.

const std::string carma::services::Angle::HOURS_STR
static

A const string that may be used for unit conversion.

"hours"

Definition at line 250 of file Angle.h.

const std::string carma::services::Angle::RADIANS_STR
static

A const string that may be used for unit conversion.

"radians"

Definition at line 238 of file Angle.h.

const double carma::services::Angle::twoPi_ = 2 * M_PIl
staticprotected

Two pi.

Used for modulus function in this class and subclasses.

Definition at line 216 of file Angle.h.


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