# = mathconstants.rb
#
# == Copyright (C) 2003 Daniel Carrera, Brian Gough
#
#   GNU General Public License
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or (at
#   your option) any later version.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#   General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# == Author(s)
#
# * Daniel Carrera
# * Brian Gough

# Author::    Daniel Carrera, Brian Gough
# Copyright:: Copyright (c) 2003 Daniel Carrera, Brian Gough
# License::   GNU General Public License (GPL)

# = Math Constants
#
# Large assortment of real world contants. The constants are stored in
# the Math::Constants module, but this is included in Math for direct
# use by other Math libraries. Math::Constants::CGS provides the
# constants in cm kg s format, opposed to the standard m kg s.
#
# == Synopsis
#
#   Math::SPEED_OF_LIGHT                   #=> 2.99792458e8
#   Math::CGS::SPEED_OF_LIGHT              #=> 2.99792458e10
#   Math::Constants::SPEED_OF_LIGHT        #=> 2.99792458e8
#   Math::Constants::CGS::SPEED_OF_LIGHT   #=> 2.99792458e10
#

module Math

  module Constants

    #
    #  Unit-less constants.
    #

    FINE_STRUCTURE  = 7.297352533e-3 # 1
    AVOGADRO        = 6.02214199e23 # 1
    YOTTA           = 1e24  # 1
    ZETTA           = 1e21  # 1
    EXA             = 1e18  # 1
    PETA            = 1e15  # 1
    TERA            = 1e12  # 1
    GIGA            = 1e9   # 1
    MEGA            = 1e6   # 1
    KILO            = 1e3   # 1
    MILLI           = 1e-3  # 1
    MICRO           = 1e-6  # 1
    NANO            = 1e-9  # 1
    PICO            = 1e-12 # 1
    FEMTO           = 1e-15 # 1
    ATTO            = 1e-18 # 1
    ZEPTO           = 1e-21 # 1
    YOCTO           = 1e-24 # 1

    #
    # Constants in the MKS system (meters, kg, sec)
    #

    SPEED_OF_LIGHT           = 2.99792458e8      # m / s 
    GRAV_CONSTANT            = 6.673e-11  # m^3 / kg s^2 
    PLANCKS_CONSTANT_H       = 6.62606876e-34 # kg m^2 / s 
    PLANCKS_CONSTANT_HBAR    = 1.05457159642e-34 # kg m^2 / s 
    VACUUM_PERMEABILITY      = 1.25663706144e-6 # kg m / A^2 s^2 
    ASTRONOMICAL_UNIT        = 1.49597870691e11   # m 
    LIGHT_YEAR               = 9.46053620707e15 # m 
    PARSEC                   = 3.08567758135e16 # m 
    GRAV_ACCEL               = 9.80665e0        # m / s^2 
    ELECTRON_VOLT            = 1.602176462e-19  # kg m^2 / s^2 
    MASS_ELECTRON            = 9.10938188e-31 # kg 
    MASS_MUON                = 1.88353109e-28 # kg 
    MASS_PROTON              = 1.67262158e-27 # kg 
    MASS_NEUTRON             = 1.67492716e-27 # kg 
    RYDBERG                  = 2.17987190389e-18 # kg m^2 / s^2 
    BOLTZMANN                = 1.3806503e-23   # kg m^2 / K s^2 
    BOHR_MAGNETON            = 9.27400899e-24  # A m^2 
    NUCLEAR_MAGNETON         = 5.05078317e-27 # A m^2 
    ELECTRON_MAGNETIC_MOMENT = 9.28476362e-24 # A m^2 
    PROTON_MAGNETIC_MOMENT   = 1.410606633e-26  # A m^2 
    MOLAR_GAS                = 8.314472e0       # kg m^2 / K mol s^2 
    STANDARD_GAS_VOLUME      = 2.2710981e-2 # m^3 / mol 
    MINUTE                   = 6e1        # s 
    HOUR                     = 3.6e3      # s 
    DAY                      = 8.64e4     # s 
    WEEK                     = 6.048e5    # s 
    INCH                     = 2.54e-2    # m 
    FOOT                     = 3.048e-1   # m 
    YARD                     = 9.144e-1   # m 
    MILE                     = 1.609344e3 # m 
    NAUTICAL_MILE            = 1.852e3    # m 
    FATHOM                   = 1.8288e0   # m 
    MIL                      = 2.54e-5    # m 
    POINT                    = 3.52777777778e-4 # m 
    TEXPOINT                 = 3.51459803515e-4 # m 
    MICRON                   = 1e-6    # m 
    ANGSTROM                 = 1e-10   # m 
    HECTARE                  = 1e4     # m^2 
    ACRE                     = 4.04685642241e3 # m^2 
    BARN                     = 1e-28   # m^2 
    LITER                    = 1e-3    # m^3 
    US_GALLON                = 3.78541178402e-3 # m^3 
    QUART                    = 9.46352946004e-4 # m^3 
    PINT                     = 4.73176473002e-4 # m^3 
    CUP                      = 2.36588236501e-4 # m^3 
    FLUID_OUNCE              = 2.95735295626e-5 # m^3 
    TABLESPOON               = 1.47867647813e-5 # m^3 
    TEASPOON                 = 4.92892159375e-6 # m^3 
    CANADIAN_GALLON          = 4.54609e-3  # m^3 
    UK_GALLON                = 4.546092e-3 # m^3 
    MILES_PER_HOUR           = 4.4704e-1   # m / s 
    KILOMETERS_PER_HOUR      = 2.77777777778e-1 # m / s 
    KNOT                     = 5.14444444444e-1 # m / s
    POUND_MASS               = 4.5359237e-1     # kg 
    OUNCE_MASS               = 2.8349523125e-2  # kg 
    TON                      = 9.0718474e2      # kg 
    METRIC_TON               = 1e3     # kg 
    UK_TON                   = 1.0160469088e3 # kg 
    TROY_OUNCE               = 3.1103475e-2   # kg 
    CARAT                    = 2e-4    # kg 
    UNIFIED_ATOMIC_MASS      = 1.66053873e-27 # kg 
    ATOMIC_MASS              = 1.66053873e-27 # kg 
    GRAM_FORCE               = 9.80665e-3 # kg m / s^2 
    POUND_FORCE              = 4.44822161526e0 # kg m / s^2 
    KILOPOUND_FORCE          = 4.44822161526e3 # kg m / s^2 
    POUNDAL                  = 1.38255e-1 # kg m / s^2 
    CALORIE                  = 4.1868e0   # kg m^2 / s^2 
    BTU                      = 1.05505585262e3 # kg m^2 / s^2 
    THERM                    = 1.05506e8  # kg m^2 / s^2 
    HORSEPOWER               = 7.457e2    # kg m^2 / s^3 
    BAR                      = 1e5        # kg / m s^2 
    STD_ATMOSPHERE           = 1.01325e5  # kg / m s^2 
    TORR                     = 1.33322368421e2  # kg / m s^2 
    METER_OF_MERCURY         = 1.33322368421e5 # kg / m s^2 
    INCH_OF_MERCURY          = 3.38638815789e3  # kg / m s^2 
    INCH_OF_WATER            = 2.490889e2 # kg / m s^2 
    PSI                      = 6.89475729317e3 # kg / m s^2 
    POISE                    = 1e-1    # kg m^-1 s^-1 
    STOKES                   = 1e-4    # m^2 / s 
    FARADAY                  = 9.6485341472e4  # A s / mol 
    ELECTRON_CHARGE          = 1.602176462e-19 # A s 
    GAUSS                    = 1e-4    # kg / A s^2 
    STILB                    = 1e4     # cd / m^2 
    LUMEN                    = 1e0     # cd sr 
    LUX                      = 1e0     # cd sr / m^2 
    PHOT                     = 1e4     # cd sr / m^2 
    FOOTCANDLE               = 1.076e1 # cd sr / m^2 
    LAMBERT                  = 1e4     # cd sr / m^2 
    FOOTLAMBERT              = 1.07639104e1 # cd sr / m^2 
    CURIE                    = 3.7e10  # 1 / s 
    ROENTGEN                 = 2.58e-4 # A s / kg 
    RAD                      = 1e-2    # m^2 / s^2 
    SOLAR_MASS               = 1.98892e30 # kg 
    BOHR_RADIUS              = 5.291772083e-11 # m 
    VACUUM_PERMITTIVITY      = 8.854187817e-12 # A^2 s^4 / kg m^3 
    NEWTON                   = 1e0     # kg m / s^2 
    DYNE                     = 1e-5    # kg m / s^2 
    JOULE                    = 1e0     # kg m^2 / s^2 
    ERG                      = 1e-7    # kg m^2 / s^2 

    #
    # Constants in the CGS system (cm, kg, s)
    #

    module CGS

        SPEED_OF_LIGHT           = 2.99792458e10     # cm / s 
        GRAVITATIONAL_CONSTANT   = 6.673e-8   # cm^3 / g s^2 
        PLANCKS_CONSTANT_H       = 6.62606876e-27 # g cm^2 / s 
        PLANCKS_CONSTANT_HBAR    = 1.05457159642e-27 # g cm^2 / s 
        VACUUM_PERMEABILITY      = 1.25663706144e-1 # cm g / A^2 s^2 
        ASTRONOMICAL_UNIT        = 1.49597870691e13 # cm 
        LIGHT_YEAR               = 9.46053620707e17   # cm 
        PARSEC                   = 3.08567758135e18   # cm 
        GRAV_ACCEL               = 9.80665e2 # cm / s^2 
        ELECTRON_VOLT            = 1.602176462e-12 # g cm^2 / s^2 
        MASS_ELECTRON            = 9.10938188e-28 # g 
        MASS_MUON                = 1.88353109e-25 # g 
        MASS_PROTON              = 1.67262158e-24 # g 
        MASS_NEUTRON             = 1.67492716e-24 # g 
        RYDBERG                  = 2.17987190389e-11 # g cm^2 / s^2 
        BOLTZMANN                = 1.3806503e-16   # g cm^2 / K s^2 
        BOHR_MAGNETON            = 9.27400899e-20  # A cm^2 
        NUCLEAR_MAGNETON         = 5.05078317e-23 # A cm^2 
        ELECTRON_MAGNETIC_MOMENT = 9.28476362e-20 # A cm^2 
        PROTON_MAGNETIC_MOMENT   = 1.410606633e-22  # A cm^2 
        MOLAR_GAS                = 8.314472e7      # g cm^2 / K mol s^2
        STD_GAS_VOLUME           = 2.2710981e4 # cm^3 / mol 
        MINUTE                   = 6e1     # s 
        HOUR                     = 3.6e3   # s 
        DAY                      = 8.64e4  # s 
        WEEK                     = 6.048e5 # s 
        INCH                     = 2.54e0  # cm 
        FOOT                     = 3.048e1 # cm 
        YARD                     = 9.144e1 # cm 
        MILE                     = 1.609344e5 # cm 
        NAUTICAL_MILE            = 1.852e5    # cm 
        FATHOM                   = 1.8288e2   # cm 
        MIL                      = 2.54e-3    # cm 
        POINT                    = 3.52777777778e-2 # cm 
        TEXPOINT                 = 3.51459803515e-2 # cm 
        MICRON                   = 1e-4    # cm 
        ANGSTROM                 = 1e-8    # cm 
        HECTARE                  = 1e8     # cm^2 
        ACRE                     = 4.04685642241e7 # cm^2 
        BARN                     = 1e-24   # cm^2 
        LITER                    = 1e3     # cm^3 
        US_GALLON                = 3.78541178402e3 # cm^3 
        QUART                    = 9.46352946004e2 # cm^3 
        PINT                     = 4.73176473002e2 # cm^3 
        CUP                      = 2.36588236501e2 # cm^3 
        FLUID_OUNCE              = 2.95735295626e1 # cm^3 
        TABLESPOON               = 1.47867647813e1 # cm^3 
        TEASPOON                 = 4.92892159375e0 # cm^3 
        CANADIAN_GALLON          = 4.54609e3  # cm^3 
        UK_GALLON                = 4.546092e3 # cm^3 
        MILES_PER_HOUR           = 4.4704e1   # cm / s 
        KILOMETERS_PER_HOUR      = 2.77777777778e1 # cm / s 
        KNOT                     = 5.14444444444e1 # cm / s 
        POUND_MASS               = 4.5359237e2    # g 
        OUNCE_MASS               = 2.8349523125e1 # g 
        TON                      = 9.0718474e5    # g 
        METRIC_TON               = 1e6     # g 
        UK_TON                   = 1.0160469088e6 # g 
        TROY_OUNCE               = 3.1103475e1    # g 
        CARAT                    = 2e-1    # g 
        UNIFIED_ATOMIC_MASS      = 1.66053873e-24 # g
        GRAM_FORCE               = 9.80665e2          # cm g / s^2 
        POUND_FORCE              = 4.44822161526e5    # cm g / s^2 
        KILOPOUND_FORCE          = 4.44822161526e8    # cm g / s^2 
        POUNDAL                  = 1.38255e4  # cm g / s^2 
        CALORIE                  = 4.1868e7   # g cm^2 / s^2 
        BTU                      = 1.05505585262e10 # g cm^2 / s^2 
        THERM                    = 1.05506e15 # g cm^2 / s^2 
        HORSEPOWER               = 7.457e9    # g cm^2 / s^3 
        BAR                      = 1e6        # g / cm s^2 
        STD_ATMOSPHERE           = 1.01325e6  # g / cm s^2 
        TORR                     = 1.33322368421e3  # g / cm s^2 
        METER_OF_MERCURY         = 1.33322368421e6 # g / cm s^2
        INCH_OF_MERCURY          = 3.38638815789e4  # g / cm s^2 
        INCH_OF_WATER            = 2.490889e3 # g / cm s^2 
        PSI                      = 6.89475729317e4 # g / cm s^2 
        POISE                    = 1e0      # g / cm s 
        STOKES                   = 1e0      # cm^2 / s 
        FARADAY                  = 9.6485341472e4  # A s / mol 
        ELECTRON_CHARGE          = 1.602176462e-19 # A s 
        GAUSS                    = 1e-1     # g / A s^2 
        STILB                    = 1e0      # cd / cm^2
        LUMEN                    = 1e0      # cd sr 
        LUX                      = 1e-4     # cd sr / cm^2 
        PHOT                     = 1e0      # cd sr / cm^2 
        FOOTCANDLE               = 1.076e-3 # cd sr / cm^2 
        LAMBERT                  = 1e0      # cd sr / cm^2 
        FOOTLAMBERT              = 1.07639104e-3 # cd sr / cm^2 
        CURIE                    = 3.7e10   # 1 / s 
        ROENTGEN                 = 2.58e-7  # A s / g 
        RAD                      = 1e2      # cm^2 / s^2 
        SOLAR_MASS               = 1.98892e33 # g 
        BOHR_RADIUS              = 5.291772083e-9 # cm 
        VACUUM_PERMITTIVITY      = 8.854187817e-21 # A^2 s^4 / g cm^3 
        NEWTON                   = 1e5     # cm g / s^2 
        DYNE                     = 1e0     # cm g / s^2 
        JOULE                    = 1e7     # g cm^2 / s^2 
        ERG                      = 1e0     # g cm^2 / s^2 

    end #module CGS

  end #module Constants

  include Constants

end #module Math



#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#

=begin test

  # If it loads, it works.

=end
