MVAngle.h

Classes

MVAngle -- Class to handle angle type conversions and I/O (full description)
Global Functions -- Global output/input functions (full description)

class MVAngle

Types

enum formatTypes

ANGLE
TIME
CLEAN = 4
NO_D = 8
NO_DM = NO_D+16,DIG2=1024
FITS = TIME+2048,LOCAL=4096
NO_H = NO_D,NO_HM=NO_DM,ANGLE_CLEAN=ANGLE+CLEAN,ANGLE_NO_D=ANGLE+NO_D,ANGLE_NO_DM=ANGLE+NO_DM,ANGLE_CLEAN_NO_D=ANGLE+CLEAN+NO_D,ANGLE_CLEAN_NO_DM=ANGLE+CLEAN+NO_DM,TIME_CLEAN=TIME+CLEAN,TIME_NO_H=TIME+NO_H,TIME_NO_HM=TIME+NO_HM,TIME_CLEAN_NO_H=TIME+CLEAN+NO_H,TIME_CLEAN_NO_HM=TIME+CLEAN+NO_HM,

Interface

Private Members
friend ostream &operator<<(ostream &os, const MVAngle &meas)
friend istream &operator>>(istream &is, MVAngle &meas)
friend ostream &operator<<(ostream &os, const MVAngle::Format &form)
MVAngle()
MVAngle(const MVAngle &other)
MVAngle &operator=(const MVAngle &other)
MVAngle(Double d)
MVAngle(const Quantity &other)
~MVAngle()
operator Double() const
const MVAngle &operator()()
const MVAngle &operator()(Double norm)
const MVAngle &operator()(const MVAngle &norm)
const MVAngle &binorm(Double norm)
static Bool unitString(UnitVal &uv, String &us, MUString &in)
static Bool read(Quantity &res, const String &in)
static Bool read(Quantity &res, MUString &in)
static Bool read(Quantity &res, const String &in, Bool chk)
static Bool read(Quantity &res, MUString &in, Bool chk)
MVAngle coAngle() const
Double radian() const
Double degree() const
Double circle() const
Quantity get() const
Quantity get(const Unit &inunit) const
String string() const
String string(MVAngle::formatTypes intyp, uInt inprec = 0) const
String string(uInt intyp, uInt inprec) const
String string(uInt inprec) const
String string(const MVAngle::Format &form) const
void print(ostream &oss, const MVAngle::Format &form) const
void print(ostream &oss, const MVAngle::Format &form, Bool loc) const
static Format setFormat(MVAngle::formatTypes intyp, uInt inprec = 0)
static Format setFormat(uInt intyp, uInt inprec)
static Format setFormat(uInt inprec = 0)
static Format setFormat(const Format &form)
static Format getFormat()
static MVAngle::formatTypes giveMe(const String &in)
static Double timeZone()

Description

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Programs:
Tests:

Prerequisite

Etymology

From Measure, Value and Angle

Synopsis

An MVAngle is a simple Double, to be used for angle conversions and I/O. It can be constructed from a Double (in which case radians are assumed), or from a Quantity (Quantum<Double>). Quantities must be in either angle or time units.
It has an automatic conversion to Double, so all standard mathematical operations can operate on it.
The class has a number of special member operations: Output formatting is done with the << statement, with the following rules: The default formatting can be overwritten by a MVAngle::setFormat(); statement; which returns an MVAngle::Format structure, that can be used in a subsequent one to reset to previous. The format set holds for all MVAngle output on all streams.
Temporary formats (i.e. for one MVAngle output only), can be set by outputting a format (i.e. stream << MVAngle::Format() << ... ).
Caution A setFormat() will also reset any lingering temporary format. A setFormat(getFormat()) will reset without changing. Problems could arise in parallel processors.
Input can be read if the values are in any of the above (non-clean) output formats.
For other formatting practice, the output can be written to a String with the string() member function.
Strings and input can be converted to an MVAngle (or Quantity) by Bool read(Quantity &out, const String &in) and istream >> MVAngle &. In the latter case the actual reading is done by the String read, which reads between white-spaces.
The following input formats (note no blanks allowed) are supported (+stands for an optional + or -; v for an unsigned integer; dv for a floating number. [] indicate optional values. Separating codes are case insensitive): Examples of valid strings:
	5::2.59		5h + 0min + 2.59 s
	5..2.59		5deg + 0arcmin + 2.59arcsec
	5.259		5.259 rad
	5..259		5deg + 259arcsec
	5.259a		5.259 * pi * 2 *365.25 rad (normalised)
Caution In general the input will be read as a Quantity. Reading of Quantities will always try to read special formats (like MVAngle, MVTime) first. In that case problems could arise converting strings like 5d, 5::, 5hm, 5dm. In 'angle' mode they could have meant to be 5d0m, 5:0:, 5h0m, 5d0m, but they could have meant: days, min, hectometre, decimetre. In the same vain 5d2 could have meant 5d2m or 5 d2. To try to guess the general use, the following interpretation is made:

Example

See synopsis

Motivation

To be able to format angle-like values in user-required ways.

To Do

Member Description

enum formatTypes

Format types

friend ostream &operator<<(ostream &os, const MVAngle &meas)

Output an angle

friend istream &operator>>(istream &is, MVAngle &meas)

Input an angle

friend ostream &operator<<(ostream &os, const MVAngle::Format &form)

Set a temporary format

MVAngle()

Default constructor: generate a zero value

MVAngle(const MVAngle &other)

Copy constructor

MVAngle &operator=(const MVAngle &other)

Copy assignment

MVAngle(Double d)

Constructor from Double

MVAngle(const Quantity &other)

Constructor from Quantum : value can be an angle or time

Thrown Exceptions

~MVAngle()

Destructor

operator Double() const

Conversion operator

const MVAngle &operator()()

Normalisation between -180 and +180 degrees (-pi and +pi)

const MVAngle &operator()(Double norm)

Normalisation between 2pi*norm and 2pi*norm + 2pi

const MVAngle &operator()(const MVAngle &norm)

Normalisation between norm-pi and norm+pi

const MVAngle &binorm(Double norm)

Normalisation between pi*norm and pi*norm + pi

static Bool unitString(UnitVal &uv, String &us, MUString &in)

Check if String unit

static Bool read(Quantity &res, const String &in)
static Bool read(Quantity &res, MUString &in)
static Bool read(Quantity &res, const String &in, Bool chk)
static Bool read(Quantity &res, MUString &in, Bool chk)

Make res angle Quantity from string in angle/time-like format. In the case of String input, also quantities are recognised. chk checks eos

MVAngle coAngle() const

Make co-angle (e.g. zenith distance from elevation)

Double radian() const
Double degree() const
Double circle() const
Quantity get() const
Quantity get(const Unit &inunit) const

Get value in given unit

String string() const
String string(MVAngle::formatTypes intyp, uInt inprec = 0) const
String string(uInt intyp, uInt inprec) const
String string(uInt inprec) const
String string(const MVAngle::Format &form) const
void print(ostream &oss, const MVAngle::Format &form) const
void print(ostream &oss, const MVAngle::Format &form, Bool loc) const

Output data

static Format setFormat(MVAngle::formatTypes intyp, uInt inprec = 0)
static Format setFormat(uInt intyp, uInt inprec)
static Format setFormat(uInt inprec = 0)
static Format setFormat(const Format &form)

Set default format

static Format getFormat()

Get default format

static MVAngle::formatTypes giveMe(const String &in)

Get code belonging to string. 0 if not known

static Double timeZone()

Get time zone offset (in days)

Global output/input functions (source)

Interface

ostream &operator<<(ostream &os, const MVAngle &meas)
ostream &operator>>(ostream &is, MVAngle &meas)
ostream &operator<<(ostream &os, const MVAngle::Format &form)

Description

Global functions Output/Input

Member Description

ostream &operator<<(ostream &os, const MVAngle &meas)

ostream &operator>>(ostream &is, MVAngle &meas)

ostream &operator<<(ostream &os, const MVAngle::Format &form)