Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Conversions.h

Go to the documentation of this file.
00001 /* SimData: Data Infrastructure for Simulations
00002  * Copyright (C) 2002, 2003 Mark Rose <tm2@stm.lbl.gov>
00003  * 
00004  * This file is part of SimData.
00005  * 
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  * 
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019  */
00020 
00021 
00027 #ifndef __SIMDATA_CONVERSIONS_H__
00028 #define __SIMDATA_CONVERSIONS_H__
00029 
00030 
00031 // SWIG template instantiations
00032 #ifdef SWIG
00033         #define SIMDATA_CVT(a) %template(convert_##a) a<double>;
00034 #else
00035         #define SIMDATA_CVT(a) 
00036 #endif
00037 
00038 
00039 #include <SimData/Namespace.h>
00040 
00041 NAMESPACE_SIMDATA
00042 
00048 
00049 
00052 namespace convert {
00053 
00054 // This is currently just a small set of unit conversions.  Feel free to add
00055 // additional routines.  Try not to include simple "prefix" conversions such 
00056 // as meters to centimeters.  Use the dominant (i.e. most common) base unit 
00057 // in each system of units if possible.
00058 // 
00059 // NOTE: be sure to add corresponding template instantiations for SWIG
00060         
00061         
00063 template <typename T>
00064 T kts_mps(T x) { return x * 0.514444; }
00065 SIMDATA_CVT(kts_mps)
00066 
00067 
00068 
00069 template <typename T>
00070 T mps_kts(T x) { return x * 1.94385; }
00071 SIMDATA_CVT(mps_kts)
00072 
00073 
00074 template <typename T>
00075 T ft_m(T x) { return x * 0.3048; }
00076 SIMDATA_CVT(ft_m)
00077 
00078 
00079 template <typename T>
00080 T m_ft(T x) { return x * 3.2808398950; }
00081 SIMDATA_CVT(m_ft)
00082 
00083 
00084 template <typename T>
00085 T kg_lb(T x) { return x * 2.2046; }
00086 SIMDATA_CVT(kg_lb)
00087 
00088 
00089 template <typename T>
00090 T lb_kg(T x) { return x * 0.45360; }
00091 SIMDATA_CVT(lb_kg)
00092 
00093 
00094 template <typename T>
00095 T nm_m(T x) { return x * 1852.0; }
00096 SIMDATA_CVT(nm_m)
00097 
00098 
00099 template <typename T>
00100 T m_nm(T x) { return x * 0.0005399568; }
00101 SIMDATA_CVT(m_nm)
00102 
00103 
00104 template <typename T>
00105 T pa_mmhg(T x) { return x * 0.00752; }
00106 SIMDATA_CVT(pa_mmhg)
00107 
00108 
00109 template <typename T>
00110 T mmhg_pa(T x) { return x * 133.0; }
00111 SIMDATA_CVT(mmhg_pa)
00112 
00113 
00114 template <typename T>
00115 T lb_n(T x) { return x * 4.44822; }
00116 SIMDATA_CVT(lb_n)
00117 
00118 
00119 template <typename T>
00120 T n_lb(T x) { return x * 0.22481; }
00121 SIMDATA_CVT(n_lb)
00122 
00123 } // namespace convert
00124 
00126 
00127 NAMESPACE_SIMDATA_END
00128 
00129 
00130 #endif // __SIMDATA_CONVERSIONS_H__
00131 

SimData version pre-0.4.0. For more information on SimData, visit the SimData Homepage.

Generated on Tue Oct 14 12:06:38 2003, using Doxygen 1.2.18.

[SF.net]