Line data Source code
1 : #ifndef _ATM_ANGLE_H 2 : #define _ATM_ANGLE_H 3 : /******************************************************************************* 4 : * ALMA - Atacama Large Millimiter Array 5 : * (c) Instituto de Estructura de la Materia, 2009 6 : * 7 : * This library is free software; you can redistribute it and/or 8 : * modify it under the terms of the GNU Lesser General Public 9 : * License as published by the Free Software Foundation; either 10 : * version 2.1 of the License, or (at your option) any later version. 11 : * 12 : * This library is distributed in the hope that it will be useful, 13 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 : * Lesser General Public License for more details. 16 : * 17 : * You should have received a copy of the GNU Lesser General Public 18 : * License along with this library; if not, write to the Free Software 19 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 : * 21 : * "@(#) $Id: ATMAngle.h Exp $" 22 : * 23 : * who when what 24 : * -------- -------- ---------------------------------------------- 25 : * pardo 24/03/09 created 26 : */ 27 : 28 : #ifndef __cplusplus 29 : #error "This is a C++ include file and cannot be used from plain C" 30 : #endif 31 : 32 : #include "ATMCommon.h" 33 : #include <string> 34 : 35 : using std::string; 36 : 37 : ATM_NAMESPACE_BEGIN 38 : 39 : /*! \brief Defines a Class for those parameters being angles. 40 : * 41 : * Defines a Class for those physical parameters having units of angle. For 42 : * example the Total Phase Delay can be expressed as an angle (but also as a length). 43 : */ 44 : class Angle 45 : { 46 : public: 47 : enum Units { 48 : UnitRadian, 49 : UnitDegree, 50 : NumAngleUnits 51 : }; 52 : 53 : /** Default constructor */ 54 : Angle(); 55 : /** A full constructor: Angle value in default units (SI: radians) */ 56 : Angle(double angle); 57 : /** A full constructor: Angle value + units. Implemented units are: deg [DEG], rad [RAD] [Rad]*/ 58 : Angle(double angle, const string &units); 59 : Angle(double angle, Units units); 60 : 61 : /** Destructor */ 62 : virtual ~Angle(); 63 : 64 : /** Accessor to get the angle value in SI units (rad) */ 65 0 : double get() const { return valueIS_; } 66 : /** Accessor to the angle value in specified units. Implemented units are: deg [DEG], rad [RAD] [Rad]. 67 : * If none of these implemented units is given, the SI value will be returned. */ 68 : double get(const string &units) const; 69 : double get(Units units) const; 70 : 71 : /** Operator "equal to a Angle" */ 72 0 : Angle& operator=(const Angle &rhs) { if(&rhs != this) valueIS_ = rhs.valueIS_; return *this; } 73 : /** Operator "equal to a double converted to Angle in Hz" */ 74 : Angle& operator=(double rhs) { valueIS_=rhs; return *this; } 75 : /** Operator "addition of angles" */ 76 0 : Angle operator+(const Angle &rhs) { return Angle(valueIS_+rhs.get()); } 77 : /** Operator "substraction of angles" */ 78 : Angle operator-(const Angle &rhs) { return Angle(valueIS_-rhs.get()); } 79 : /** Operator "multiplication of a angle by a double" */ 80 : Angle operator*(double scf) { return Angle(valueIS_*scf); } 81 : /** Operator "multiplication of a angle by a float" */ 82 : Angle operator*(float scf) { return Angle(valueIS_*(double)scf); } 83 : /** Operator "multiplication of a angle by an int" */ 84 : Angle operator*(int scf) { return Angle(valueIS_*(double)scf); } // rhs scale factor 85 : /** Operator "multiplication of a angle by an unsigned int" */ 86 : Angle operator*(unsigned int scf) { return Angle(valueIS_*(double)scf); } // rhs scale factor 87 : /** Operator "division of a angle by a double" */ 88 : Angle operator/(double scf) { return Angle(valueIS_/scf); } 89 : /** Operator "division of a angle by a float" */ 90 : Angle operator/(float scf) { return Angle(valueIS_/(double)scf); } 91 : /** Operator "division of a angle by an int" */ 92 : Angle operator/(int scf) { return Angle(valueIS_/(double)scf); } 93 : /** Operator "division of a angle by an unsigned int" */ 94 : Angle operator/(unsigned int scf) { return Angle(valueIS_/(double)scf); } 95 : /** Operator "comparator < for two angles" */ 96 : bool operator<(const Angle & rhs) const { return (valueIS_<rhs.get()); } 97 : /** Operator "comparator > for two angles" */ 98 : bool operator>(const Angle & rhs) const { return (valueIS_>rhs.get()); } 99 : /** Operator "comparator <= for two angles" */ 100 : bool operator<=(const Angle & rhs) const { return (valueIS_<=rhs.get()); } 101 : /** Operator "comparator >= for two angles" */ 102 : bool operator>=(const Angle & rhs) const { return (valueIS_>=rhs.get()); } 103 : /** Operator "comparator == for two angles" */ 104 : bool operator==(const Angle & rhs) const { return (valueIS_==rhs.get()); } 105 : /** Operator "comparator != for two angles" */ 106 : bool operator!=(const Angle & rhs) const { return (valueIS_!=rhs.get()); } 107 : 108 : private: 109 : double valueIS_; 110 : }; // class Angle 111 : 112 : ATM_NAMESPACE_END 113 : 114 : #endif /*!_ATM_ANGLE_H*/