Units Class Reference

#include <orsa_units.h>

Collaboration diagram for Units:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Units ()
 Units (time_unit, length_unit, mass_unit)
void SetSystem (time_unit tu, length_unit lu, mass_unit mu)
double GetG () const
double GetMSun () const
double GetC () const
double GetG_MKS () const
std::string label (time_unit) const
std::string label (length_unit) const
std::string label (mass_unit) const
std::string TimeLabel () const
std::string LengthLabel () const
std::string MassLabel () const
double FromUnits (const double x, const time_unit t_in, const int power=1) const
double FromUnits (const double x, const length_unit l_in, const int power=1) const
double FromUnits (const double x, const mass_unit m_in, const int power=1) const
const time_unitGetTimeBaseUnit () const
const length_unitGetLengthBaseUnit () const
const mass_unitGetMassBaseUnit () const

Protected Member Functions

double GetTimeScale (const time_unit tu) const
double GetLengthScale (const length_unit lu) const
double GetMassScale (const mass_unit mu) const
double GetTimeScale () const
double GetLengthScale () const
double GetMassScale () const
void Recompute ()

Constructor & Destructor Documentation

Units  ) 
 

Definition at line 57 of file orsa_units.cc.

References orsa::KG, orsa::M, Units::Recompute(), orsa::SECOND, and UnitBaseScale::Set().

00057                {
00058     init_base();
00059     Time.Set(SECOND);
00060     Length.Set(M);
00061     Mass.Set(KG);
00062     TryToSetUnitsFromJPLFile();
00063     Recompute();
00064   };

Here is the call graph for this function:

Units time_unit  ,
length_unit  ,
mass_unit 
 

Definition at line 66 of file orsa_units.cc.

References Units::Recompute(), and UnitBaseScale::Set().

00066                                                          {
00067     init_base();
00068     Time.Set(tu);
00069     Length.Set(lu);
00070     Mass.Set(mu);
00071     TryToSetUnitsFromJPLFile();
00072     Recompute();
00073   }

Here is the call graph for this function:


Member Function Documentation

double FromUnits const double  x,
const mass_unit  m_in,
const int  power = 1
const [inline]
 

Definition at line 196 of file orsa_units.h.

References Units::GetMassScale().

00196 { return (x*__int_pow__(GetMassScale(m_in)/GetMassScale(),power));     }

Here is the call graph for this function:

double FromUnits const double  x,
const length_unit  l_in,
const int  power = 1
const [inline]
 

Definition at line 195 of file orsa_units.h.

References Units::GetLengthScale().

00195 { return (x*__int_pow__(GetLengthScale(l_in)/GetLengthScale(),power)); }

Here is the call graph for this function:

double FromUnits const double  x,
const time_unit  t_in,
const int  power = 1
const [inline]
 

Definition at line 194 of file orsa_units.h.

References Units::GetTimeScale().

00194 { return (x*__int_pow__(GetTimeScale(t_in)/GetTimeScale(),power));     }

Here is the call graph for this function:

double GetC  )  const [inline]
 

Definition at line 158 of file orsa_units.h.

00158 { return c; }; // c = speed of light

double GetG  )  const [inline]
 

Definition at line 156 of file orsa_units.h.

00156 { return G; };

double GetG_MKS  )  const
 

Definition at line 55 of file orsa_units.cc.

References orsa::G_MKS.

00055 { return G_MKS; }

const length_unit& GetLengthBaseUnit  )  const [inline]
 

Definition at line 200 of file orsa_units.h.

References UnitBaseScale::GetBaseUnit().

Referenced by OrsaFile::Write().

00200 { return Length.GetBaseUnit(); };

Here is the call graph for this function:

double GetLengthScale  )  const [protected]
 

Definition at line 205 of file orsa_units.cc.

References UnitBaseScale::GetBaseUnit().

Referenced by Units::FromUnits(), and Units::Recompute().

00205 { return Units::GetLengthScale( Length.GetBaseUnit()); } 

Here is the call graph for this function:

double GetLengthScale const length_unit  lu  )  const [protected]
 

Definition at line 142 of file orsa_units.cc.

References orsa::AU, orsa::CM, orsa::EARTHMOON, orsa::KM, orsa::KPARSEC, orsa::LY, orsa::M, orsa::MPARSEC, orsa::PARSEC, orsa::REARTH, and orsa::RMOON.

00142                                                          {
00143     
00144     double ls=1.0;
00145     
00146     switch(lu) {
00147     case   MPARSEC: ls = (parsec_base*1.0e6); break;
00148     case   KPARSEC: ls = (parsec_base*1.0e3); break;
00149     case    PARSEC: ls = (parsec_base);       break;
00150     case        LY: ls = (c_base*31557600.0); break;
00151     case        AU: ls = (AU_base);           break;
00152     case EARTHMOON: ls = (3.844e8);           break;
00153     case    REARTH: ls = (r_earth_base);      break;
00154     case     RMOON: ls = (r_moon_base);       break;
00155     case        KM: ls = (1000.0);            break;
00156     case         M: ls = (1.0);               break;
00157     case        CM: ls = (0.01);              break;
00158     }
00159     
00160     return (ls);
00161   }

const mass_unit& GetMassBaseUnit  )  const [inline]
 

Definition at line 201 of file orsa_units.h.

References UnitBaseScale::GetBaseUnit().

Referenced by OrsaFile::Write().

00201 { return Mass.GetBaseUnit(); };

Here is the call graph for this function:

double GetMassScale  )  const [protected]
 

Definition at line 206 of file orsa_units.cc.

References UnitBaseScale::GetBaseUnit().

Referenced by Units::FromUnits(), and Units::Recompute().

00206 { return Units::GetMassScale(     Mass.GetBaseUnit()); } 

Here is the call graph for this function:

double GetMassScale const mass_unit  mu  )  const [protected]
 

Definition at line 178 of file orsa_units.cc.

References orsa::GRAM, orsa::KG, orsa::MEARTH, orsa::MJUPITER, orsa::MMOON, and orsa::MSUN.

00178                                                      {
00179     
00180     double ms=1.0;
00181     
00182     switch(mu) {
00183     case     MSUN: ms = (MSun_base);     break;
00184     case MJUPITER: ms = (MJupiter_base); break;
00185     case   MEARTH: ms = (MEarth_base);   break;
00186     case    MMOON: ms = (MMoon_base);    break;
00187     case       KG: ms = (1.0);           break;
00188     case     GRAM: ms = (0.001);         break;
00189     }
00190     
00191     return (ms);
00192   }

double GetMSun  )  const [inline]
 

Definition at line 157 of file orsa_units.h.

00157 { return MSun; };

const time_unit& GetTimeBaseUnit  )  const [inline]
 

Definition at line 199 of file orsa_units.h.

References UnitBaseScale::GetBaseUnit().

Referenced by OrsaFile::Write().

00199 { return Time.GetBaseUnit(); };

Here is the call graph for this function:

double GetTimeScale  )  const [protected]
 

Definition at line 204 of file orsa_units.cc.

References UnitBaseScale::GetBaseUnit().

Referenced by Units::FromUnits(), and Units::Recompute().

00204 { return Units::GetTimeScale(     Time.GetBaseUnit()); } 

Here is the call graph for this function:

double GetTimeScale const time_unit  tu  )  const [protected]
 

Definition at line 122 of file orsa_units.cc.

References orsa::DAY, orsa::HOUR, orsa::MINUTE, orsa::SECOND, and orsa::YEAR.

Referenced by OrsaFile::Write().

00122                                                      {
00123     if (tu == YEAR)   return (31557600.0);
00124     if (tu == DAY)    return (86400.0);
00125     if (tu == HOUR)   return (3600.0);
00126     if (tu == MINUTE) return (60.0);
00127     if (tu == SECOND) return (1.0);
00128     
00129     // here should throw an error...
00130     return 1.0;
00131   }

string label mass_unit   )  const
 

Definition at line 194 of file orsa_units.cc.

References orsa::GRAM, orsa::KG, orsa::MEARTH, orsa::MJUPITER, orsa::MMOON, and orsa::MSUN.

00194                                               {
00195     if (mu == MSUN)     return "Sun mass";
00196     if (mu == MJUPITER) return "Jupiter mass";
00197     if (mu == MEARTH)   return "Earth mass";
00198     if (mu == MMOON)    return "Moon mass";
00199     if (mu == KG)       return "kg";
00200     if (mu == GRAM)     return "g";
00201     return "";
00202   }

string label length_unit   )  const
 

Definition at line 163 of file orsa_units.cc.

References orsa::AU, orsa::CM, orsa::EARTHMOON, orsa::KM, orsa::KPARSEC, orsa::LY, orsa::M, orsa::MPARSEC, orsa::PARSEC, orsa::REARTH, and orsa::RMOON.

00163                                                 {
00164     if (lu == MPARSEC)   return "Mpc";
00165     if (lu == KPARSEC)   return "kpc";
00166     if (lu == PARSEC)    return "pc";
00167     if (lu == LY)        return "ly";
00168     if (lu == AU)        return "AU";
00169     if (lu == EARTHMOON) return "LD"; // earth-moon mean distance
00170     if (lu == REARTH)    return "ER";
00171     if (lu == RMOON)     return "MR";
00172     if (lu == KM)        return "km";
00173     if (lu ==  M)        return "m";
00174     if (lu == CM)        return "cm";
00175     return "";
00176   }

string label time_unit   )  const
 

Definition at line 133 of file orsa_units.cc.

References orsa::DAY, orsa::HOUR, orsa::MINUTE, orsa::SECOND, and orsa::YEAR.

Referenced by Units::LengthLabel(), Units::MassLabel(), and Units::TimeLabel().

00133                                               {
00134     if (tu == YEAR)   return "y";
00135     if (tu == DAY)    return "d";
00136     if (tu == HOUR)   return "h";
00137     if (tu == MINUTE) return "m";
00138     if (tu == SECOND) return "s";
00139     return "";
00140   }

std::string LengthLabel  )  const [inline]
 

Definition at line 169 of file orsa_units.h.

References UnitBaseScale::GetBaseUnit(), and Units::label().

00169 { return label(Length.GetBaseUnit()); };

Here is the call graph for this function:

std::string MassLabel  )  const [inline]
 

Definition at line 170 of file orsa_units.h.

References UnitBaseScale::GetBaseUnit(), and Units::label().

00170 { return label(  Mass.GetBaseUnit()); };

Here is the call graph for this function:

void Recompute  )  [protected]
 

Definition at line 208 of file orsa_units.cc.

References Units::GetLengthScale(), Units::GetMassScale(), Units::GetTimeScale(), orsa::pi, orsa::secure_pow(), and orsa::sin().

Referenced by Units::SetSystem(), and Units::Units().

00208                         {
00209     G = G_base*secure_pow(GetTimeScale(),2.0)*secure_pow(GetLengthScale(),-3.0)*secure_pow(GetMassScale(),1.0); 
00210     MSun = MSun_base/GetMassScale();
00211     c = c_base*GetTimeScale()/GetLengthScale();
00212     parsec_base = AU_base/(2*sin((pi/180)/3600.0/2));
00213   }

Here is the call graph for this function:

void SetSystem time_unit  tu,
length_unit  lu,
mass_unit  mu
 

Definition at line 87 of file orsa_units.cc.

References Units::Recompute(), and UnitBaseScale::Set().

00087                                                                   {
00088     Time.Set(tu);
00089     Length.Set(lu);
00090     Mass.Set(mu);
00091     Recompute();
00092   }

Here is the call graph for this function:

std::string TimeLabel  )  const [inline]
 

Definition at line 168 of file orsa_units.h.

References UnitBaseScale::GetBaseUnit(), and Units::label().

00168 { return label(  Time.GetBaseUnit()); };

Here is the call graph for this function:


The documentation for this class was generated from the following files:
Generated on Tue Jan 11 15:29:46 2005 for liborsa by  doxygen 1.4.0