Line data Source code
1 : /******************************************************************************* 2 : * ALMA - Atacama Large Millimiter Array 3 : * (c) Instituto de Estructura de la Materia, 2009 4 : * 5 : * This library is free software; you can redistribute it and/or 6 : * modify it under the terms of the GNU Lesser General Public 7 : * License as published by the Free Software Foundation; either 8 : * version 2.1 of the License, or (at your option) any later version. 9 : * 10 : * This library is distributed in the hope that it will be useful, 11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 : * Lesser General Public License for more details. 14 : * 15 : * You should have received a copy of the GNU Lesser General Public 16 : * License along with this library; if not, write to the Free Software 17 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 : * 19 : * "@(#) $Id: ATMInverseLength.cpp Exp $" 20 : * 21 : * who when what 22 : * -------- -------- ---------------------------------------------- 23 : * pardo 24/03/09 created 24 : */ 25 : 26 : #include <stdio.h> 27 : #include "ATMInverseLength.h" 28 : 29 : 30 : 31 : ATM_NAMESPACE_BEGIN 32 : 33 0 : InverseLength::InverseLength() : 34 0 : valueIS_(0.0) 35 : { 36 0 : } 37 : 38 0 : InverseLength::InverseLength(double inverseLength) : 39 0 : valueIS_(inverseLength) 40 : { 41 0 : } 42 : 43 0 : InverseLength::InverseLength(double inverseLength, const std::string &units) 44 : { 45 0 : valueIS_ = sput(inverseLength, units); 46 0 : } 47 : 48 450160 : InverseLength::InverseLength(double inverseLength, InverseLength::Units units) 49 : { 50 450160 : valueIS_ = sput(inverseLength, units); 51 450160 : } 52 : 53 0 : InverseLength::InverseLength(const InverseLength &inverseLength) : 54 0 : valueIS_(inverseLength.valueIS_) 55 : { 56 0 : } 57 : 58 450160 : InverseLength::~InverseLength() 59 : { 60 450160 : } 61 : 62 0 : double InverseLength::sget(double value, const std::string &units) 63 : { 64 0 : if(units == "km-1" || units == "KM-1") { 65 0 : return 1.0E+3 * value; 66 0 : } else if(units == "m-1" || units == "M-1") { 67 0 : return value; 68 0 : } else if(units == "mm-1" || units == "MM-1") { 69 0 : return 1.0E-3 * value; 70 0 : } else if(units == "micron-1" || units == "MICRON-1") { 71 0 : return 1.0E-6 * value; 72 0 : } else if(units == "nm-1" || units == "NM-1") { 73 0 : return 1.0E-9 * value; 74 : } else { 75 0 : return value; 76 : } 77 : } 78 : 79 0 : double InverseLength::sput(double value, const std::string &units) 80 : { 81 0 : if(units == "km-1" || units == "KM-1") { 82 0 : return 1.0E-3 * value; 83 0 : } else if(units == "m-1" || units == "M-1") { 84 0 : return value; 85 0 : } else if(units == "mm-1" || units == "MM-1") { 86 0 : return 1.0E+3 * value; 87 0 : } else if(units == "micron-1" || units == "MICRON-1") { 88 0 : return 1.0E+6 * value; 89 0 : } else if(units == "nm-1" || units == "NM-1") { 90 0 : return 1.0E+9 * value; 91 : } else { 92 0 : return value; 93 : } 94 : } 95 : 96 200 : double InverseLength::sget(double value, InverseLength::Units units) 97 : { 98 200 : if(units == InverseLength::UnitInverseKiloMeter) { 99 0 : return 1.0E+3 * value; 100 200 : } else if(units == InverseLength::UnitInverseMeter) { 101 200 : return value; 102 0 : } else if(units == InverseLength::UnitInverseMilliMeter) { 103 0 : return 1.0E-3 * value; 104 0 : } else if(units == InverseLength::UnitInverseMicron) { 105 0 : return 1.0E-6 * value; 106 0 : } else if(units == InverseLength::UnitInverseNanoMeter) { 107 0 : return 1.0E-9 * value; 108 : } else { 109 0 : return value; 110 : } 111 : } 112 : 113 450160 : double InverseLength::sput(double value, InverseLength::Units units) 114 : { 115 450160 : if(units == InverseLength::UnitInverseKiloMeter) { 116 0 : return 1.0E-3 * value; 117 450160 : } else if(units == InverseLength::UnitInverseMeter) { 118 450160 : return value; 119 0 : } else if(units == InverseLength::UnitInverseMilliMeter) { 120 0 : return 1.0E+3 * value; 121 0 : } else if(units == InverseLength::UnitInverseMicron) { 122 0 : return 1.0E+6 * value; 123 0 : } else if(units == InverseLength::UnitInverseNanoMeter) { 124 0 : return 1.0E+9 * value; 125 : } else { 126 0 : return value; 127 : } 128 : } 129 : 130 : ATM_NAMESPACE_END