473,378 Members | 1,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

physical constants header file

Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
It might be used like this:
cat main.cc #include<iostream>
#include"physical.h"
int
main(int argc, char* argv[]) {
using namespace physical::units;
double x = 13.0*meters;
std::cout << "x = " << x << " meters" << std::endl;
double factor = year/second;
std::cout << (365.0*days)/second
<< " = (365.0*days)/second" << std::endl;
std::cout << factor
<< " = seconds/year" << std::endl;
std::cout << (factor -pi*10000000.0)/days
<< " = (factor -pi*10000000.0)/days" << std::endl;
std::cout << (factor -pi*10000000.0)/factor
<< " = (factor -pi*10000000.0)/factor" << std::endl;
return 0;
}
g++ -Wall -ansi -pedantic -o main main.cc
./main

x = 13 meters
3.1536e+07 = (365.0*days)/second
3.15569e+07 = seconds/year
1.63193 = (factor -pi*10000000.0)/days
0.00446807 = (factor -pi*10000000.0)/factor

namespace physical {
namespace unit { // conversion factor
const double radian = 1.0;
const double radians = radian;
const double rad = radian;
const double steradian = 1.0;
const double steradians = steradian;
const double sr = steradian;
const double dollar = 1.0;
const double dollars = dollar;
const double cent = dollar/100.0;
const double cents = cent;
const double dozen = 12.0;
const double doz = dozen;
const double dz = dozen;
namespace bakers {
const double dozen = 13.0;
const double doz = dozen;
const double dz = dozen;
}
const double gross = 12.0*dozen;
const double gro = gross;
const double quire = 25.0;
const double quires = quire;
const double ream = 500.0;
const double reams = ream;
const double percent = 1.0/100.0;
const double proof = percent/2.0;
const double karat = 1.0/24.0;
const double karats = karat;
const double mole = 6.0221367e+23;
const double moles = mole;
const double mol = mole;
const double pi = 3.14159265358979323846*radians;
namespace arc {
const double degree = pi/180.0;
const double degrees = degree;
const double minute = degree/60.0;
const double minutes = minute;
const double min = minute;
const double second = minute/60.0;
const double seconds = second;
const double sec = second;
const double grade = 0.9*degrees;
const double grades = grade;
namespace centesimal {
const double minute = grade/100.0;
const double minutes = minute;
const double min = minute;
const double second = grade/10000.0;
const double seconds = second;
const double sec = second;
}
}

// SI units (mks)
// length
const double meter = 1.0;
const double meters = meter;
const double m = meter;
const double kilometer = 1000.0*meters;
const double kilometers = kilometer;
const double km = kilometer;
const double decimeter = meters/10.0;
const double decimeters = decimeter;
const double dm = decimeter;
const double centimeter = meters/100.0;
const double centimeters = centimeter;
const double cm = centimeter;
const double millimeter = meters/1000.0;
const double millimeters = millimeter;
const double mm = millimeter;
const double micron = meter/1000000.0;
const double microns = micron;
const double nanometer = meter/1000000000.0;
const double nanometers = nanometer;
const double nm = nanometer;
const double decinanometer = meter/10000000000.0;
const double decinanometers = decinanometer;
const double Angstrom = decinanometer;
const double Angstroms = Angstrom;
const double Xunit = 1.00202e-13*meters;
const double Xunits = Xunit;
const double Fermi = meter/1000000000000000.0;
const double Fermis = Fermi;
// area
const double hectare = 10000.0*meter*meter;
const double hectares = hectare;
const double ha = hectare;
// volume
const double stere = meter*meter*meter;
const double steres = stere;
const double liter = stere/1000.0;
const double liters = liter;
const double l = liter;
const double milliliter = stere/1000000.0;
const double milliliters = milliliter;
const double ml = milliliter;
const double cc = milliliter;
namespace displacement {
const double ton = stere;
const double tons = ton;
const double t = ton;
}
// mass
const double kilogram = 1.0;
const double kilograms = kilogram;
const double kg = kilogram;
const double quintal = 100.0*kilograms;
const double quintals = quintal;
const double doppelzentner = quintal;
const double doppelzentners = doppelzentner;
const double gram = kilograms/1000.0;
const double grams = gram;
const double g = gram;
const double milligram = kilogram/1000000.0;
const double milligrams = milligram;
const double mg = milligram;
namespace metric { // weight
const double carat = gram/5.0;
const double carats = carat;
const double ton = 1000.0*kilograms;
const double tons = ton;
const double t = ton;
}
// time
const double second = 1.0;
const double seconds = second;
const double sec = second;
const double s = second;
const double millisecond = second/1000.0;
const double milliseconds = millisecond;
const double ms = millisecond;
const double microsecond = second/1000000.0;
const double microseconds = microsecond;
const double us = microsecond;
const double nanosecond = second/1000000000.0;
const double nanoseconds = nanosecond;
const double picosecond = second/1000000000000.0;
const double picoseconds = picosecond;
const double minute = 60.0*seconds;
const double minutes = minute;
const double min = minute;
const double hour = 60.0*minutes;
const double hours = hour;
const double hr = hour;
const double day = 24.0*hours;
const double days = day;
const double da = day;
const double week = 7.0*days;
const double weeks = week;
const double fortnight = 2.0*weeks;
const double fortnights = fortnight;
const double year = 365.2421896698*days;
const double years = year;
const double yr = year;
const double month = year/12.0;
const double months = month;
const double mo = month;
const double decade = 10.0*years;
const double decades = decade;
const double century = 100.0*years;
const double centuries = century;
const double millenium = 1000.0*years;
const double millenia = millenium;
// temporal frequency
const double Hertz = 1.0/second;
const double Hz = Hertz;
const double kiloHertz = 1000.0*Hertz;
const double kHz = kiloHertz;
const double megaHertz = 1000000*Hertz;
const double MHz = megaHertz;
// spacial frequency
const double diopter = 1.0/meter;
const double diopters = diopter;
// speed
const double kph = kilometers/hour;
// radioactivity
const double Becquerel = 1.0/second;
const double Becquerels = Becquerel;
const double Bq = Becquerel;
const double Rutherford = 1000000.0*Becquerels;
const double Rutherfords = Rutherford;
const double Curie = 3.7e+10*Becquerels;
const double Curies = Curie;
const double Ci = Curie;
// force
const double Newton = kilogram*meter/(second*second);
const double Newtons = Newton;
const double N = Newton;
const double dyne = Newton/100000.0;
const double dynes = dyne;
const double dyn = dyne;
// pressure
const double Pascal = Newton/(meter*meter);
const double Pascals = Pascal;
const double Pa = Pascal;
const double Barie = Pascal/10.0;
const double Baries = Barie;
const double Barye = Barie;
const double Baryes = Barye;
const double pieze = 1000.0*Pascals;
const double piezes = pieze;
const double pz = pieze;
const double bar = 10000.0*Pascals;
const double bars = bar;
const double Torr = 133.3224*Pascals;
const double atmosphere = 760.0*Torr;
const double atmospheres = atmosphere;
const double atm = atmosphere;
// energy
const double Joule = Newton*meter;
const double Joules = Joule;
const double J = Joule;
const double erg = Joule/10000000.0;
const double ergs = erg;
const double kiloWatthour = 3600000.0*Joules;
const double kiloWatthours = kiloWatthour;
const double kWh = kiloWatthour;
// power
const double Watt = Joule/second;
const double Watts = Watt;
const double W = Watt;
const double kiloWatt = 1000.0*Watts;
const double kiloWatts = kiloWatt;
const double kW = kiloWatt;
const double megaWatt = 1000000.0*Watts;
const double megaWatts = megaWatt;
const double MW = megaWatt;
const double milliWatt = Watt/1000.0;
const double milliWatts = milliWatt;
const double mW = milliWatt;
namespace dose { // energy
const double Gray = Joule/kilogram;
const double Grays = Gray;
const double Gy = Gray;
const double Sievert = Gray;
const double Sieverts = Sieverts;
const double rad = Gray/100.0;
const double rads = rad;
const double rd = rad;
}
// electrical current
const double Ampere = 1.0;
const double Amperes = Ampere;
const double A = Ampere;
const double Biot = 10.0*Amperes;
const double Biots = Biot;
// electrical potential
const double Volt = Watt/Ampere;
const double Volts = Volt;
const double V = Volt;
// electrical resistance
const double Ohm = Volt/Ampere;
const double Ohms = Ohm;
// electrical conductance
const double mho = 1.0/Ohm;
const double mhos = mho;
const double Siemens = mho;
const double S = Siemens;
// elsectrical charge
const double Coulomb = Ampere*second;
const double Coulombs = Coulomb;
const double C = Coulomb;
const double Franklin = 3.33564e-10*Coulombs;
const double Franklins = Franklin;
// electrical capacity
const double Farad = Coulomb/Volt;
const double Farads = Farad;
const double F = Farad;
// magnetic flux
const double Weber = Volt*second;
const double Webers = Weber;
const double Wb = Weber;
const double Maxwell = Weber/100000000.0;
const double Maxwells = Maxwell;
const double M = Maxwell;
// magnetic field B
const double Tesla = Weber/(meter*meter);
const double Teslas = Tesla;
const double T = Tesla;
const double Gauss = Tesla/10000.0;
const double gamma = Tesla/1000000000.0;
// magnetic field H
const double Oerstedt = 79.57747*Ampere/meter;
const double Oerstedts = Oerstedt;
const double Oe = Oerstedt;
// magnetic inductivity
const double Henry = Weber/Ampere;
const double Henrys = Henry;
const double H = Henry;
const double milliHenry = Henry/1000.0;
const double milliHenrys = milliHenry;
const double mH = milliHenry;
// temperature
const double Kelvin = 1.0;
const double Kelvins = Kelvin;
const double K = Kelvin;
// luminous intensity
const double candela = 1.0;
const double candelas = candela;
const double cd = candela;
const double apostilb = candelas/meter/meter;
const double apostilbs = apostilb;
const double nit = apostilb;
const double nits = nit;
const double skot = apostilb/1000.0;
const double skots = skot;
const double stilb = 10000.0*apostilbs;
const double stilbs = stilb;
const double Blondel = apostilb/pi;
const double Blondels = Blondel;
const double Lambert = 10000.0*Blondels;
const double Lamberts = Lambert;
// light flux
const double lumen = candela*steradian;
const double lumens = lumen;
const double lm = lumen;
// light intensity
const double lux = lumens/meter/meter;
const double luxes = lux;
const double luces = lux;
const double lx = lux;
const double nox = lux/1000.0;
const double phot = lumens/centimeter/centimeter;
const double phots = phot;
namespace equivalent {
const double lux = unit::lux/pi;
const double luxes = lux;
const double luces = lux;
const double lx = lux;
const double lumen = unit::lumen/pi;
const double lumens = lumen;
const double lm = lumen;
const double phot = apostilb/pi;
const double phots = phot;
}
// acceleration
const double Galileo = centimeters/second/second;
const double Galileos = Galileo;
// standard gavitational acceleration at sea level
const double gravity = 9.80665*meters/second/second;
// mass
const double kilohyl = kilogram*gravity*second*second/meter;
const double kilohyls = kilohyl;
const double hyl = kilohyl/1000.0;
const double hyls = hyl;

// English Units
// length
const double inch = 0.0254*meters;
const double inches = inch;
const double in = inch;
const double mil = inch/1000.0;
const double mils = mil;
const double point = inch/72.27;
const double points = point;
const double pt = point;
const double bottommeasure = inch/40.0;
const double bottommeasures = bottommeasure;
const double line = inch/12.0;
const double lines = line;
const double pica = 12.0*points;
const double picas = pica;
const double barleycorn = inch/3.0;
const double barleycorns = barleycorn;
const double finger = 7.0*inches/8.0;
const double fingers = finger;
const double palm = 3.0*inches;
const double palms = palm;
const double hand = 4.0*inches;
const double hands = hand;
const double link = 7.92*inches;
const double links = link;
const double li = link;
const double span = 9.0*inches;
const double spans = span;
const double foot = 12.0*inches;
const double feet = foot;
const double ft = foot;
const double cubit = 18.0*inches;
const double cubits = cubit;
const double yard = 3.0*feet;
const double yards = yard;
const double yd = yard;
const double nail = yard/16.0;
const double nails = nail;
const double ell = 45.0*inches;
const double ells = ell;
const double pace = 5.0*feet;
const double paces = pace;
const double fathom = 6.0*feet;
const double fathoms = fathom;
const double fm = fathom;
const double rod = 198.0*inches;
const double rods = rod;
const double rd = rod;
const double pole = rod;
const double poles = pole;
const double p = pole;
const double perch = rod;
const double perches = perch;
const double rope = 20.0*feet;
const double ropes = rope;
const double bolt = 40.0*yards;
const double bolts = bolt;
const double chain = 4.0*rods;
const double chains = chain;
const double ch = chain;
namespace Gunters {
const double chain = unit::chain;
const double chains = chain;
}
namespace engineers {
const double link = foot;
const double links = link;
const double chain = 100.0*feet;
const double chains = chain;
}
const double skein = 120*yards;
const double skeins = skein;
const double furlong = 220*yards;
const double furlongs = furlong;
const double spindle = 14400*yards;
const double spindles = spindle;
namespace US {
const double cable_length = 120.0*fathoms;
const double cable_lengths = cable_length;
}
namespace British {
const double cable_length = 100.0*fathoms;
const double cable_lengths = cable_length;
}
namespace statute {
const double mile = 5280.0*feet;
const double miles = mile;
const double mi = mile;
const double league = 3.0*miles;
const double leagues = league;
}
namespace nautical {
const double mile = 1852*meters;
const double miles = mile;
const double nm = mile;
const double league = 3.0*miles;
const double leagues = league;
}
namespace marine = nautical;
namespace geodetic {
const double foot = (1200.0/3937.0)*meters;
const double feet = foot;
const double ft = foot;
}
namespace geographical {
const double mile = nautical::mile;
const double miles = mile;
const double mi = mile;
}
const double parasang = 3.5*statute::miles;
const double parasangs = parasang;
const double arpentcan = 27.52*statute::miles;
const double arpentcans = arpentcan;
const double arpentlin = 191.835*feet;
const double arpentlins = arpentlin;
const double astronomical_unit = 1.49597871e11*meters;
const double astronomical_units = astronomical_unit;
const double AU = astronomical_unit;
const double lightyear = 9.4605e15*meters;
const double lightyears = lightyear;
const double ly = lightyear;
const double parsec = AU*radians/arc::second;
const double parsecs = parsec;
const double pc = parsec;
// area
const double barn = 1.0e-28*meter*meter;
const double barns = barn;
const double b = barn;
const double circular_inch = 0.25*pi*inch*inch;
const double circular_inches = circular_inch;
const double circular_mil = 0.25*pi*mil*mil;
const double circular_mils = circular_mil;
const double sabin = foot*foot;
const double sabins = sabin;
const double square = 100.0*sabin;
const double squares = square;
const double are = 100.0*meter*meter;
const double ares = are;
const double a = are;
const double rood = 40.0*rod*rod;
const double roods = rood;
const double ro = rood;
const double acre = 4.0*roods;
const double acres = acre;
const double section = statute::mile*statute::mile;
const double sections = section;
const double homestead = section/4.0;
const double homesteads = homestead;
const double township = 36.0*sections;
const double townships = township;
// volume
const double minim = 6.161152e-8*(m*m*m);
const double minims = minim;
const double drop = 0.03*cc;
const double drops = drop;
const double teaspoon = 4.928922*cc;
const double teaspoons = teaspoon;
const double tablespoon = 3.0*teaspoons;
const double tablespoons = tablespoon;
namespace US {
namespace liquid {
const double dram = 60.0*minims;
const double drams = dram;
const double dr = dram;
const double ounce = 8.0*drams;
const double ounces = ounce;
const double oz = ounce;
const double gill = 4.0*ounces;
const double gills = gill;
const double gl = gill;
const double pint = 4.0*gills;
const double pints = pint;
const double pt = pint;
const double quart = 2.0*pints;
const double quarts = quart;
const double qt = quart;
const double magnum = 2.0*quarts;
const double magnums = magnum;
const double gallon = 4.0*quarts;
const double gallons = gallon;
const double gal = gallon;
}
namespace dry {
const double pint = 550.61047*cc;
const double pints = pint;
const double pt = pint;
const double quart = 2.0*pints;
const double quarts = quart;
const double qt = quart;
}
const double peck = 8.0*dry::quarts;
const double pecks = peck;
const double pk = peck;
const double bushel = 4.0*pecks;
const double bushels = bushel;
const double bu = bushel;
const double barrel = 31.5*liquid::gallons;
const double barrels = barrel;
const double bbl = barrel;
const double bl = barrel;
}
namespace British {
namespace fluid {
const double drachm = 60.0*minims;
const double drachms = drachm;
const double dr = drachm;
const double ounce = 8.0*drachms;
const double ounces = ounce;
const double oz = ounce;
const double gill = 5.0*ounces;
const double gills = gill;
const double gi = gill;
const double pint = 4.0*gills;
const double pints = pint;
const double pt = pint;
const double quart = 2.0*pints;
const double quarts = quart;
const double qt = quart;
const double gallon = 4.0*quarts;
const double gallons = gallon;
const double gal = gallon;
}
const double peck = 2.0*fluid::gallons;
const double pecks = peck;
const double pk = peck;
const double bushel = 4.0*pecks;
const double bushels = bushel;
const double bu = bushel;
const double barrel = 36.0*fluid::gallons;
const double barrels = barrel;
const double bbl = barrel;
const double bl = barrel;
}
const double noggin = 2.0*US::liquid::ounces;
const double noggins = noggin;
const double cup = 8.0*US::liquid::ounces;
const double cups = cup;
const double fifth = US::liquid::gallon/5.0;
const double fifths = fifth;
const double jeroboam = 4.0*fifths;
const double jeroboams = jeroboam;
const double firkin = 9.0*US::liquid::gallons;
const double firkins = firkin;
const double kilderkin = 18.0*US::liquid::gallons;
const double kilderkins = kilderkin;
const double strike = 2.0*US::bushels;
const double strikes = strike;
const double sack = 3.0*US::bushels;
const double sacks = sack;
const double coomb = 4.0*US::bushels;
const double coombs = coomb;
const double seam = 8.0*US::bushels;
const double seams = seam;
const double wey = 40.0*US::bushels;
const double weys = wey;
const double last = 80.0*US::bushels;
const double lasts = last;
const double register_ton = 100.0*(ft*ft*ft);
const double register_tons = register_ton;
const double register_tn = register_ton;
const double cord = 128.0*(ft*ft*ft);
const double cords = cord;
const double cordfoot = cord;
const double cordfeet = cordfoot;
const double boardfoot = 144.0*inch*inch*inch;
const double boardfeet = boardfoot;
const double timberfoot = foot*foot*foot;
const double timberfeet = timberfoot;
const double hogshead = 2.0*US::barrels;
const double hogsheads = hogshead;
const double pipe = 4.0*US::barrels;
const double pipes = pipe;
const double tun = 8.0*US::barrels;
const double tuns = tun;
// mass
const double grain = 0.06479891*grams;
const double grains = grain;
const double gr = grain;
const double pennyweight = 24.0*grains;
const double dwt = pennyweight;
namespace apothecary { // weight
const double scruple = 20.0*grains;
const double scruples = scruple;
const double s = scruple;
const double dram = 3.0*scruples;
const double drams = dram;
const double dr = dram;
const double ounce = 8.0*drams;
const double ounces = ounce;
const double oz = ounce;
const double pound = 12.0*ounces;
const double pounds = pound;
const double lb = pound;
}
namespace troy = apothecary;
namespace ap = apothecary;
namespace t = apothecary;
namespace avoirdupois { // weight
const double pound = 7000.0*grains;
const double pounds = pound;
const double lb = pound;
const double ounce = pound/16.0;
const double ounces = ounce;
const double oz = ounce;
const double dram = ounce/16.0;
const double drams = dram;
const double dr = dram;
}
namespace avdp = avoirdupois;
namespace av = avoirdupois;
const double stone = 14.0*avoirdupois::pounds;
const double stones = stone;
const double st = stone;
namespace US { // short
const double hundredweight = 100.0*avoirdupois::pounds;
const double cwt = hundredweight;
const double quarter = hundredweight/4.0;
const double quarters = quarter;
const double qr = quarter;
const double ton = 20.0*hundredweight;
const double tons = ton;
const double tn = ton;
const double deadweight = ton;
}
namespace British { // long
const double hundredweight = 112.0*avoirdupois::pounds;
const double cwt = hundredweight;
const double quarter = hundredweight/4.0;
const double quarters = quarter;
const double qr = quarter;
const double ton = 20.0*hundredweight;
const double tons = ton;
const double tn = ton;
}
namespace English = British;
namespace Imperial = British;
const double crith = 0.0906*grams;
const double criths = crith;
const double bag = 94.0*avoirdupois::pounds;
const double bags = bag;
const double cental = 100.0*avoirdupois::pounds;
const double centals = cental;
const double weymass = 252.0*avoirdupois::pounds;
// rate
const double mgd = 1000000.0*US::liquid::gallons/day;
const double cfs = foot*foot*foot/second;
const double minersinch = 1.5*foot*foot*foot/minute;
const double mpg = statute::miles/US::liquid::gallon;
// speed
const double mph = statute::miles/hour;
const double knot = nautical::miles/hour;
const double knots = knot;
namespace admiralty {
const double knot = 6980.0*feet/hour;
const double knots = knot;
}
// force
const double poundal = avdp::pound*foot/(second*second);
const double poundals = poundal;
const double pdl = poundal;
const double lbf = avoirdupois::pound*gravity;
// pressure
const double psi = lbf/(inch*inch);
// energy
const double calorie = 4.1868*Joules;
const double calories = calorie;
const double cal = calorie;
const double kilocalorie = 1000.0*calories;
const double kilocalories = kilocalorie;
const double kcal = kilocalorie;
const double Frigorie = kilocalorie;
const double Frigories = Frigorie;
const double Btu = 1055.06*Joules;
const double therm = 10000.0*Btu;
const double therms = therm;
const double thermie = 1000000.0*calories;
const double thermies = thermie;
// power
const double horsepower = 735.49875*Watts;
const double HP = horsepower;
// electrical current
const double Gilbert = 0.795775*Amperes;
const double Gilberts = Gilbert;
// temperature
const double Rankin = 1.8*Kelvins;
const double Rankins = Rankin;
const double R = Rankin;
// luminous intensity
const double candle = 1.02*candelas;
const double candles = candle;
namespace Hefner {
const double candle = 0.9*unit::candles;
const double candles = candle;
}
// light intensity
const double foot_candle = lumens/foot/foot;
const double foot_candles = foot_candle;
const double fc = foot_candle;
const double foot_Lambert = candelas/foot/foot/pi;
const double foot_Lamberts = foot_Lambert;
namespace equivalent {
const double foot_candle = unit::foot_candle/pi;
const double foot_candles = foot_candle;
const double fc = foot_candle;
}
}
namespace units = unit;

namespace constant {
using namespace units;
// speed of light
const double c = 2.99792458e8*meters/second;
// speed of sound
const double Mach = 331.46*meters/second;
// Planck constant
const double h = 6.6260755e-34*Joule*seconds;
const double h_bar = h/(2.0*pi);
// standard gavitational acceleration at sea level
const double g = units::gravity;
// electron charge
const double e = 1.60217733e-19*Coulombs;
// elevtron Volt
const double eV = e*V;
const double keV = 1000.0*eV;
const double MeV = 1000000.0*eV;
const double GeV = 1000000000.0*eV;
const double Rydberg = 13.6054*eV;
const double Rydbergs = Rydberg;
// electron mass
const double m_e = 9.1093897e-31*kilograms;
// proton mass
const double m_P = 1.6726231e-27*kilograms;
// deuteron mass
const double m_D = 1875.61339*MeV/(c*c);
// unified atomic mass unit
const double atomic_mass_unit = 1.6605402e-27*kilograms;
const double atomic_mass_units = atomic_mass_unit;
const double amu = atomic_mass_unit;
const double Dalton = atomic_mass_unit;
const double Daltons = Dalton;
// permittivity of free space
const double epsilon = 8.854187817e-12*Farads/meter;
// permeability of free space
const double mu = 12.566370614e-7*Newtons/(A*A);
// fine-structure constant
const double alpha = 1.0/137.0359895;
// classical electron radius
const double r_e = 2.81794092e-15*meters;
// electron Compton wavelength
const double lambda_bar = 3.86159323e-13*meters;
// Bohr radius
const double a_0 = 0.529177249e-10*meters;
// wavelength of 1 eV/c particle
const double lambda_1eV = 1.23984244e-6*meters;
// Thomson cross section
const double sigma_0 = 0.66524616*barns;
// Bohr magneton
const double mu_B = 5.78838263e-11*MeV/Tesla;
// nuclear magneton
const double mu_N = 3.15245166e-14*MeV/Tesla;
// electron cyclotron frequency/field
const double E_M_e = 1.75881962e11*C/kg*(rad/(s*T));
// proton cyclotron frequency/field
const double E_M_P = 9.5788309e7*C/kg*(rad/(s*T));
// gravitational constant
const double G = 6.67259e-11*m*m*m/(kg*s*s);
// Avogadro's constant
const double N_A = 6.0221367e23;
// Boltzmann constant
const double K_B = 1.380658e-23*Joules/Kelvin;
// molar volume, ideal gas at standard temperature and pressure
const double V_molar = 2.897756e-3*meter*Kelvins;
// Stefan-Boltzmann constant
const double sigma_SB = 5.67051e-8*W/(m*m*K*K*K*K);
//
}
namespace constants = constant;
}
Jul 22 '05 #1
34 4932
hm... what does this do:

namespace physical {
namespace unit {
some stuff ;
} ;
namespace units = unit ; // <------ I'm curious about this line. I've never seen this
syntax before.
} ;

Thanks,

David
Jul 22 '05 #2
David Lindauer wrote:
hm... what does this do:

namespace physical {
namespace unit {
some stuff ;
} ;
namespace units = unit ; // <------ I'm curious about this line. I've never seen this
syntax before.
} ;


It creates an alias for namespace unit named units. You can now refer to
the stuff in the unit namespace throught either unit::stuff or
units::stuff.

Jacques.
Jul 22 '05 #3
"Jacques Labuschagne" <ja*****@clawshrimp.com> wrote in message
news:tEpcd.8425
David Lindauer wrote:

hm... what does this do:

namespace physical {
namespace unit {
some stuff ;
} ;
namespace units = unit ; // <------ I'm curious about this line. I've never seen this syntax before.
} ;


It creates an alias for namespace unit named units. You can now refer to
the stuff in the unit namespace throught either unit::stuff or
units::stuff.


It's like typedef for namespaces.
Jul 22 '05 #4
On Sat, 16 Oct 2004 19:58:18 -0700, "E. Robert Tisdale"
<E.**************@jpl.nasa.gov> wrote:
Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
[snip]
namespace physical {
namespace unit { // conversion factor [snip] const double dollar = 1.0;
const double dollars = dollar;
const double cent = dollar/100.0;
const double cents = cent; I have never thought of dollar as a physical unit. Namespace currency
perhaps.
const double pound = 1.0;
const double penny = pound / 100.0;
const double pence = penny;
const double euro = 1.0;
etc.

[snip]
I have added UK English/European spellings. meter --> metre etc. // SI units (mks)
// length
const double meter = 1.0;
const double meters = meter; const double metre = meter;
const double metres = meter;
const double m = meter;
const double kilometer = 1000.0*meters;
const double kilometers = kilometer; const double kilometre = kilometer;
const double kilometres = kilometer;
const double km = kilometer;
const double decimeter = meters/10.0;
const double decimeters = decimeter; const double decimetre = decimeter;
const double decimetres = decimeter;
const double dm = decimeter;
const double centimeter = meters/100.0;
const double centimeters = centimeter; const double centimetre = centimeter;
const double centimetres = centimeter;
const double cm = centimeter;
const double millimeter = meters/1000.0;
const double millimeters = millimeter; const double millimetre = millimeter;
const double millimetres = millimeter;
const double mm = millimeter;
const double micron = meter/1000000.0;
const double microns = micron;
const double nanometer = meter/1000000000.0;
const double nanometers = nanometer; const double nanometre = nanometer;
const double nanometres = nanometer;
const double nm = nanometer;
const double decinanometer = meter/10000000000.0;
const double decinanometers = decinanometer; const double decinanometre = decinanometer;
const double decinanometres = decinanometer;

[snip] // volume
const double stere = meter*meter*meter;
const double steres = stere;
const double liter = stere/1000.0;
const double liters = liter; const double litre = stere/1000.0;
const double litres = liter;
const double l = liter;
const double milliliter = stere/1000000.0;
const double milliliters = milliliter; const double millilitre = milliliter;
const double millilitres = milliliter;
const double ml = milliliter;
const double cc = milliliter; [snip] }
// mass
const double kilogram = 1.0;
const double kilograms = kilogram; const double kilogramme = 1.0;
const double kilogrammes = kilogram;
const double kg = kilogram; [snip] const double gram = kilograms/1000.0;
const double grams = gram; const double gramme = kilograms/1000.0;
const double grammes = gram;
const double g = gram;
const double milligram = kilogram/1000000.0;
const double milligrams = milligram; const double milligramme = kilogram/1000000.0;
const double milligrammes = milligram;
const double mg = milligram;
namespace metric { // weight
const double carat = gram/5.0;
const double carats = carat;
const double ton = 1000.0*kilograms;
const double tons = ton; const double tonne = 1000.0*kilograms;
const double tonnes = ton;

You have namespace metric, but these two might be useful.
const double metric_ton = ton;
const double metric_tons = ton;
const double t = ton;
} [snip] // spacial frequency
const double diopter = 1.0/meter;
const double diopters = diopter;

const double dioptre = 1.0/meter;
const double dioptres = diopter;

[snip]
rossum
--

The ultimate truth is that there is no Ultimate Truth
Jul 22 '05 #5
On Sat, 16 Oct 2004 19:58:18 -0700, "E. Robert Tisdale"
<E.**************@jpl.nasa.gov> wrote:
Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
[snip]
namespace physical {
namespace unit { // conversion factor [snip] const double dollar = 1.0;
const double dollars = dollar;
const double cent = dollar/100.0;
const double cents = cent; I have never thought of dollar as a physical unit. Namespace currency
perhaps.
const double pound = 1.0;
const double penny = pound / 100.0;
const double pence = penny;
const double euro = 1.0;
etc.

[snip]
I have added UK English/European spellings. meter --> metre etc. // SI units (mks)
// length
const double meter = 1.0;
const double meters = meter; const double metre = meter;
const double metres = meter;
const double m = meter;
const double kilometer = 1000.0*meters;
const double kilometers = kilometer; const double kilometre = kilometer;
const double kilometres = kilometer;
const double km = kilometer;
const double decimeter = meters/10.0;
const double decimeters = decimeter; const double decimetre = decimeter;
const double decimetres = decimeter;
const double dm = decimeter;
const double centimeter = meters/100.0;
const double centimeters = centimeter; const double centimetre = centimeter;
const double centimetres = centimeter;
const double cm = centimeter;
const double millimeter = meters/1000.0;
const double millimeters = millimeter; const double millimetre = millimeter;
const double millimetres = millimeter;
const double mm = millimeter;
const double micron = meter/1000000.0;
const double microns = micron;
const double nanometer = meter/1000000000.0;
const double nanometers = nanometer; const double nanometre = nanometer;
const double nanometres = nanometer;
const double nm = nanometer;
const double decinanometer = meter/10000000000.0;
const double decinanometers = decinanometer; const double decinanometre = decinanometer;
const double decinanometres = decinanometer;

[snip] // volume
const double stere = meter*meter*meter;
const double steres = stere;
const double liter = stere/1000.0;
const double liters = liter; const double litre = stere/1000.0;
const double litres = liter;
const double l = liter;
const double milliliter = stere/1000000.0;
const double milliliters = milliliter; const double millilitre = milliliter;
const double millilitres = milliliter;
const double ml = milliliter;
const double cc = milliliter; [snip] }
// mass
const double kilogram = 1.0;
const double kilograms = kilogram; const double kilogramme = 1.0;
const double kilogrammes = kilogram;
const double kg = kilogram; [snip] const double gram = kilograms/1000.0;
const double grams = gram; const double gramme = kilograms/1000.0;
const double grammes = gram;
const double g = gram;
const double milligram = kilogram/1000000.0;
const double milligrams = milligram; const double milligramme = kilogram/1000000.0;
const double milligrammes = milligram;
const double mg = milligram;
namespace metric { // weight
const double carat = gram/5.0;
const double carats = carat;
const double ton = 1000.0*kilograms;
const double tons = ton; const double tonne = 1000.0*kilograms;
const double tonnes = ton;

You have namespace metric, but these two might be useful.
const double metric_ton = ton;
const double metric_tons = ton;
const double t = ton;
} [snip] // spacial frequency
const double diopter = 1.0/meter;
const double diopters = diopter;

const double dioptre = 1.0/meter;
const double dioptres = diopter;

[snip]
rossum
--

The ultimate truth is that there is no Ultimate Truth
Jul 22 '05 #6
On Sat, 16 Oct 2004 19:58:18 -0700, "E. Robert Tisdale"
<E.**************@jpl.nasa.gov> wrote:
Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
[snip]
namespace physical {
namespace unit { // conversion factor [snip] const double dollar = 1.0;
const double dollars = dollar;
const double cent = dollar/100.0;
const double cents = cent; I have never thought of dollar as a physical unit. Namespace currency
perhaps.
const double pound = 1.0;
const double penny = pound / 100.0;
const double pence = penny;
const double euro = 1.0;
etc.

[snip]
I have added UK English/European spellings. meter --> metre etc. // SI units (mks)
// length
const double meter = 1.0;
const double meters = meter; const double metre = meter;
const double metres = meter;
const double m = meter;
const double kilometer = 1000.0*meters;
const double kilometers = kilometer; const double kilometre = kilometer;
const double kilometres = kilometer;
const double km = kilometer;
const double decimeter = meters/10.0;
const double decimeters = decimeter; const double decimetre = decimeter;
const double decimetres = decimeter;
const double dm = decimeter;
const double centimeter = meters/100.0;
const double centimeters = centimeter; const double centimetre = centimeter;
const double centimetres = centimeter;
const double cm = centimeter;
const double millimeter = meters/1000.0;
const double millimeters = millimeter; const double millimetre = millimeter;
const double millimetres = millimeter;
const double mm = millimeter;
const double micron = meter/1000000.0;
const double microns = micron;
const double nanometer = meter/1000000000.0;
const double nanometers = nanometer; const double nanometre = nanometer;
const double nanometres = nanometer;
const double nm = nanometer;
const double decinanometer = meter/10000000000.0;
const double decinanometers = decinanometer; const double decinanometre = decinanometer;
const double decinanometres = decinanometer;

[snip] // volume
const double stere = meter*meter*meter;
const double steres = stere;
const double liter = stere/1000.0;
const double liters = liter; const double litre = stere/1000.0;
const double litres = liter;
const double l = liter;
const double milliliter = stere/1000000.0;
const double milliliters = milliliter; const double millilitre = milliliter;
const double millilitres = milliliter;
const double ml = milliliter;
const double cc = milliliter; [snip] }
// mass
const double kilogram = 1.0;
const double kilograms = kilogram; const double kilogramme = 1.0;
const double kilogrammes = kilogram;
const double kg = kilogram; [snip] const double gram = kilograms/1000.0;
const double grams = gram; const double gramme = kilograms/1000.0;
const double grammes = gram;
const double g = gram;
const double milligram = kilogram/1000000.0;
const double milligrams = milligram; const double milligramme = kilogram/1000000.0;
const double milligrammes = milligram;
const double mg = milligram;
namespace metric { // weight
const double carat = gram/5.0;
const double carats = carat;
const double ton = 1000.0*kilograms;
const double tons = ton; const double tonne = 1000.0*kilograms;
const double tonnes = ton;

You have namespace metric, but these two might be useful.
const double metric_ton = ton;
const double metric_tons = ton;
const double t = ton;
} [snip] // spacial frequency
const double diopter = 1.0/meter;
const double diopters = diopter;

const double dioptre = 1.0/meter;
const double dioptres = diopter;

[snip]
rossum
--

The ultimate truth is that there is no Ultimate Truth
Jul 22 '05 #7
On Sat, 16 Oct 2004 19:58:18 -0700, "E. Robert Tisdale"
<E.**************@jpl.nasa.gov> wrote:
Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
[snip]
namespace physical {
namespace unit { // conversion factor [snip] const double dollar = 1.0;
const double dollars = dollar;
const double cent = dollar/100.0;
const double cents = cent; I have never thought of dollar as a physical unit. Namespace currency
perhaps.
const double pound = 1.0;
const double penny = pound / 100.0;
const double pence = penny;
const double euro = 1.0;
etc.

[snip]
I have added UK English/European spellings. meter --> metre etc. // SI units (mks)
// length
const double meter = 1.0;
const double meters = meter; const double metre = meter;
const double metres = meter;
const double m = meter;
const double kilometer = 1000.0*meters;
const double kilometers = kilometer; const double kilometre = kilometer;
const double kilometres = kilometer;
const double km = kilometer;
const double decimeter = meters/10.0;
const double decimeters = decimeter; const double decimetre = decimeter;
const double decimetres = decimeter;
const double dm = decimeter;
const double centimeter = meters/100.0;
const double centimeters = centimeter; const double centimetre = centimeter;
const double centimetres = centimeter;
const double cm = centimeter;
const double millimeter = meters/1000.0;
const double millimeters = millimeter; const double millimetre = millimeter;
const double millimetres = millimeter;
const double mm = millimeter;
const double micron = meter/1000000.0;
const double microns = micron;
const double nanometer = meter/1000000000.0;
const double nanometers = nanometer; const double nanometre = nanometer;
const double nanometres = nanometer;
const double nm = nanometer;
const double decinanometer = meter/10000000000.0;
const double decinanometers = decinanometer; const double decinanometre = decinanometer;
const double decinanometres = decinanometer;

[snip] // volume
const double stere = meter*meter*meter;
const double steres = stere;
const double liter = stere/1000.0;
const double liters = liter; const double litre = stere/1000.0;
const double litres = liter;
const double l = liter;
const double milliliter = stere/1000000.0;
const double milliliters = milliliter; const double millilitre = milliliter;
const double millilitres = milliliter;
const double ml = milliliter;
const double cc = milliliter; [snip] }
// mass
const double kilogram = 1.0;
const double kilograms = kilogram; const double kilogramme = 1.0;
const double kilogrammes = kilogram;
const double kg = kilogram; [snip] const double gram = kilograms/1000.0;
const double grams = gram; const double gramme = kilograms/1000.0;
const double grammes = gram;
const double g = gram;
const double milligram = kilogram/1000000.0;
const double milligrams = milligram; const double milligramme = kilogram/1000000.0;
const double milligrammes = milligram;
const double mg = milligram;
namespace metric { // weight
const double carat = gram/5.0;
const double carats = carat;
const double ton = 1000.0*kilograms;
const double tons = ton; const double tonne = 1000.0*kilograms;
const double tonnes = ton;

You have namespace metric, but these two might be useful.
const double metric_ton = ton;
const double metric_tons = ton;
const double t = ton;
} [snip] // spacial frequency
const double diopter = 1.0/meter;
const double diopters = diopter;

const double dioptre = 1.0/meter;
const double dioptres = diopter;

[snip]
rossum
--

The ultimate truth is that there is no Ultimate Truth
Jul 22 '05 #8
On Mon, 18 Oct 2004 22:50:31 +0100, rossum <ro******@coldmail.com>
wrote:

[snip]

apologies for the multiple post, my newsreader was telling me that it
hadn't posted the reply. Naughty newsreader, I shall send it to bed
early with no dinner.

rossum

--

The ultimate truth is that there is no Ultimate Truth
Jul 22 '05 #9
rossum wrote:
You have namespace metric, but these two might be useful.
const double metric_ton = ton;
const double metric_tons = ton;


What's wrong with using metric::ton or metric::tons?
Jul 22 '05 #10
In message <ck**********@nntp1.jpl.nasa.gov>, E. Robert Tisdale
<E.**************@jpl.nasa.gov> writes
[molto snippo]
const double Hertz = 1.0/second;
const double Newton = kilogram*meter/(second*second);
const double Pascal = Newton/(meter*meter);
const double Joule = Newton*meter;
const double Watt = Joule/second;
const double Ampere = 1.0;
const double Volt = Watt/Ampere;
const double Ohm = Volt/Ampere;
const double Siemens = mho;
const double Coulomb = Ampere*second;
const double Farad = Coulomb/Volt;
const double Weber = Volt*second;
const double Tesla = Weber/(meter*meter);
const double Henry = Weber/Ampere;
const double Kelvin = 1.0;


Bzzzt. SI units named after people have lowercase names.

--
Richard Herring
Jul 22 '05 #11
const double dollar = 1.0;
const double dollars = dollar;

Not that it makes a difference, but I'd use a reference there:
double const dollar = 1.0

double const &dollars = dollar;
-JKop

Jul 22 '05 #12
On Mon, 18 Oct 2004 15:04:16 -0700, "E. Robert Tisdale"
<E.**************@jpl.nasa.gov> wrote:
rossum wrote:
You have namespace metric, but these two might be useful.
const double metric_ton = ton;
const double metric_tons = ton;


What's wrong with using metric::ton or metric::tons?

Nothing at all. I was less sure about these two than the others,
hence my comment.

rossum

--

The ultimate truth is that there is no Ultimate Truth
Jul 22 '05 #13

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:ck**********@nntp1.jpl.nasa.gov...
Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
It might be used like this:
// time
const double second = 1.0;
const double minute = 60.0*seconds;
const double hour = 60.0*minutes;
const double day = 24.0*hours;
const double year = 365.2421896698*days;
Any particular reason you're specifying years in terms of seconds? Really,
what you're specifying is seconds_per_year, but nothing in the constant's
name indicates that. If I were making calculations using years, I'd be more
likely to specify them using 1 as a year, or else using days_per_year, not
seconds_per_year.
const double month = year/12.0;
That's incredibly arbitrary! There are indeed twelve months per year (in
our calendar), but given that you've specified "year" in terms of seconds,
this constant signifies nothing of importance at all. It's the
seconds_per_average_month, or something silly like that.
const double fortnight = 2.0*weeks;
const double fortnights = fortnight;


Now HERE's a useful set of constants! :-)
Another thing that bothers me... you've declared constants named "minutes",
"seconds", "hours", etc. Assuming that I've added the appropriate "using"
clause, (which is hard to find, given the sheer size of the whole thing),
those so-called-constants would interfere with the most common variable
names used to express specific AMOUNTS of those units. When doing time
calculations, one most often computes variables named "hours", "minutes" and
"seconds" (etc.) as the NUMBER OF hours, minutes and seconds! (Of course,
you may prefer something like "numSeconds", but I'm pretty sure "seconds" is
more common, especially since a "num" prefix tends to indicate an integral
value such as a count.)

To make them more useable, I really think that constants like these ought to
have names using all caps, or else preceded by some kind of
constant-specifier, such as

SECONDS_PER_YEAR
or
kSecondsPerYear

Then at least I have some idea what those are likely to represent (and they
also include the relevant fact that the year constant is expressed in terms
of seconds).

-Howard

Jul 22 '05 #14
Howard wrote:
E. Robert Tisdale wrote:
Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
It might be used like this:
// time
const double second = 1.0;
const double minute = 60.0*seconds;
const double hour = 60.0*minutes;
const double day = 24.0*hours;
const double year = 365.2421896698*days;


Any particular reason you're specifying years in terms of seconds?
Really, what you're specifying is seconds_per_year,
but nothing in the constant's name indicates that.


Apparently, you didn't understand,

"It defines conversion factors to mks units."
If I were making calculations using years,
I'd be more likely to specify them using 1 as a year,
or else using days_per_year, not seconds_per_year.
You missed the point
which is to ensure a consistent set of units for all calculations.
const double month = year/12.0;


That's incredibly arbitrary!
There are indeed twelve months per year (in our calendar),
but given that you've specified "year" in terms of seconds,
this constant signifies nothing of importance at all.
It's the seconds_per_average_month, or something silly like that.
const double fortnight = 2.0*weeks;
const double fortnights = fortnight;


Now HERE's a useful set of constants! :-)


I didn't make this stuff up. Take a look at:

http://www.umich.edu/~archive/physics/constants.h
Another thing that bothers me...
you've declared constants named "minutes", "seconds", "hours", etc.
Assuming that I've added the appropriate "using" clause,
(which is hard to find, given the sheer size of the whole thing),
those so-called-constants would interfere with the most common variable names
used to express specific AMOUNTS of those units.
When doing time calculations, one most often computes variables
named "hours", "minutes" and "seconds" (etc.)
as the NUMBER OF hours, minutes and seconds!
(Of course, you may prefer something like "numSeconds",
but I'm pretty sure "seconds" is more common, especially
since a "num" prefix tends to indicate an integral value such as a count.)
Naming variables is a little like naming children.
Frank Zappa named his daughter "Moon Unit"
and I'm OK with that as long as she is.
But I would *not* reccommend giving the names of units to variables.
Anyway, the purpose of namespaces is to avoid such naming conflicts.
Don't import namespaces
that include names that conflict with local variables
and use the namespace qualified name instead.
To make them more useable,
I really think that constants like these ought to have names using all caps,
or else preceded by some kind of constant-specifier, such as SECONDS_PER_YEAR

or

kSecondsPerYear Then at least I have some idea what those are likely to represent
(and they also include the relevant fact that
the year constant is expressed in terms of seconds).


You are welcome to define:

const double SECONDS_PER_YEAR = physical::unit::year;

or

const double kSecondsPerYear = physical::unit::year/1000.0;

if you think that
it is more important to emphasize the conversion factor
but, usually, we design software to use a consistent set of units
(mks in this case) and convert inputs and outputs
for user convenience.
Jul 22 '05 #15

"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message
news:cl**********@nntp1.jpl.nasa.gov...
Howard wrote:
E. Robert Tisdale wrote:
Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
It might be used like this:


I must have missed that on first look. What's "mks" stand for?

-Howard
Jul 22 '05 #16
"Howard" writes:
I must have missed that on first look. What's "mks" stand for?


On the off chance that you are serious: meter-kilogram-second
Jul 22 '05 #17
Howard wrote:
I must have missed that on first look. What's "mks" stand for?

Meter, Kilogram, Second. This combined with the kelvin, ampere,
and candela form the fundamental units of the SI (Internatial System)
of measurements that forms the basis of scientific computation.

Jul 22 '05 #18

"osmium" <r1********@comcast.net> wrote in message
news:2t*************@uni-berlin.de...
"Howard" writes:
I must have missed that on first look. What's "mks" stand for?


On the off chance that you are serious: meter-kilogram-second


Ah, that makes it clear then, why he based the year constant on the number
of seconds in it. Thanks.

-Howard

(And yes, I'm serious. Sounds like something taught in a science class, the
last of which I took decades ago! :-))
Jul 22 '05 #19
"Howard" <al*****@hotmail.com> wrote in message news:Ao*********************@bgtnsc04-news.ops.worldnet.att.net...

I must have missed that on first look. What's "mks" stand for?

meters, kilograms, seconds

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.
Jul 22 '05 #20
On Wed, 20 Oct 2004 10:33:48 -0400, Ron Natalie wrote:
Howard wrote:
I must have missed that on first look. What's "mks" stand for?

Meter, Kilogram, Second. This combined with the kelvin, ampere,
and candela form the fundamental units of the SI (Internatial System)
of measurements that forms the basis of scientific computation.


Odd, I'd have thought that the gram, not the kilogram, would be considered
the "fundamental" unit. Why would you give the fundamental unit a name
that's derived from the name of a non-fundamental unit? Not saying you're
wrong, just that it seems an odd way to do things. It's like, I dunno,
deriving fstream from ifstream instead of the other way around.

--
Greg Schmidt gr***@trawna.com
Trawna Publications http://www.trawna.com/
Jul 22 '05 #21

"Greg Schmidt" <gr***@trawna.com> wrote in message
news:n4**************@trawna.com...
On Wed, 20 Oct 2004 10:33:48 -0400, Ron Natalie wrote:
Howard wrote:
I must have missed that on first look. What's "mks" stand for?

Meter, Kilogram, Second. This combined with the kelvin, ampere,
and candela form the fundamental units of the SI (Internatial System)
of measurements that forms the basis of scientific computation.


Odd, I'd have thought that the gram, not the kilogram, would be considered
the "fundamental" unit. Why would you give the fundamental unit a name


It is in the cgs system of units. ( I can guess your next question ) ;^)

Jeff F
Jul 22 '05 #22
Odd, I'd have thought that the gram, not the kilogram, would be
considered the "fundamental" unit. Why would you give the fundamental
unit a name that's derived from the name of a non-fundamental unit?
Not saying you're wrong, just that it seems an odd way to do things.
It's like, I dunno, deriving fstream from ifstream instead of the other
way around.

Metric System! Do you not use it (wherever you are)?

Anyway, for all equations to do with Physics, we use the following as the
basic unit:

Energy: Joule
Pressure: Pascal
Dimension: Metre
Mass: Kilogram
Force: Newton
-JKop
Jul 22 '05 #23
Ron Natalie <ro*@sensor.com> wrote in message news:<41***********************@news.newshosting.c om>...
Howard wrote:
I must have missed that on first look. What's "mks" stand for?

Meter, Kilogram, Second. This combined with the kelvin, ampere,
and candela form the fundamental units of the SI (Internatial System)
of measurements that forms the basis of scientific computation.


Mole is also fundamental.
Jul 22 '05 #24
> > E. Robert Tisdale wrote:
Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
It might be used like this:


// time
const double second = 1.0;
const double minute = 60.0*seconds;
const double hour = 60.0*minutes;
const double day = 24.0*hours;
const double year = 365.2421896698*days;


If found an interesting units library at
http://homepage.ntlworld.com/sawatts/projects/.
Jul 22 '05 #25
Jef Driesen wrote:
E. Robert Tisdale wrote:

Please find attached the physical constants header file physical.h

It defines conversion factors to mks units.
It might be used like this:

// time
const double second = 1.0;
const double minute = 60.0*seconds;
const double hour = 60.0*minutes;
const double day = 24.0*hours;
const double year = 365.2421896698*days;


If found an interesting units library at

http://homepage.ntlworld.com/sawatts/projects/.


Yes, there are lots of interesting libraries.
The one that you site above needs basic documentation.
Doxygen is *not* adequate.
It needs, at least, an explanation
of what this this class library is supposed to accomplish.
Note: this is not a simple task.
It will require as much effort to document
as was required to develop the library in the first place.
But, in my opinion, this effort is misguided.
Jul 22 '05 #26
In message <cl**********@nntp1.jpl.nasa.gov>, E. Robert Tisdale
<E.**************@jpl.nasa.gov> writes
Jef Driesen wrote:
E. Robert Tisdale wrote:

>Please find attached the physical constants header file physical.h
>
>It defines conversion factors to mks units.
>It might be used like this:

> // time
> const double second = 1.0;
> const double minute = 60.0*seconds;
> const double hour = 60.0*minutes;
> const double day = 24.0*hours;
> const double year = 365.2421896698*days;

If found an interesting units library at
http://homepage.ntlworld.com/sawatts/projects/.


Yes, there are lots of interesting libraries.
The one that you site above needs basic documentation.
Doxygen is *not* adequate.
It needs, at least, an explanation
of what this this class library is supposed to accomplish.
Note: this is not a simple task.
It will require as much effort to document
as was required to develop the library in the first place.
But, in my opinion, this effort is misguided.


Any *facts* to substantiate that opinion?

--
Richard Herring
Jul 22 '05 #27
On Fri, 22 Oct 2004 08:21:50 GMT, JKop wrote:
Odd, I'd have thought that the gram, not the kilogram, would be
considered the "fundamental" unit. Why would you give the fundamental
unit a name that's derived from the name of a non-fundamental unit?
Not saying you're wrong, just that it seems an odd way to do things.
It's like, I dunno, deriving fstream from ifstream instead of the other
way around.


Metric System! Do you not use it (wherever you are)?

Anyway, for all equations to do with Physics, we use the following as the
basic unit:

Energy: Joule
Pressure: Pascal
Dimension: Metre
Mass: Kilogram
Force: Newton

-JKop


I'm in Canada, so I know and use the metric system. I've taken very few
physics courses, so I didn't know that kilogram was preferred over gram.
Maybe this will illustrate my confusion better:

1/1000 of a joule = 1 millijoule
1/1000 of a pascal = 1 millipascal
1/1000 of a metre = 1 millimetre
1/1000 of a kilogram = 1 gram, not 1 millikilogram

Why is this one different?

--
Greg Schmidt gr***@trawna.com
Trawna Publications http://www.trawna.com/
Jul 22 '05 #28
Greg Schmidt posted:
On Fri, 22 Oct 2004 08:21:50 GMT, JKop wrote:
Odd, I'd have thought that the gram, not the kilogram, would be
considered the "fundamental" unit. Why would you give the
fundamental unit a name that's derived from the name of a
non-fundamental unit? Not saying you're wrong, just that it seems an
odd way to do things. It's like, I dunno, deriving fstream from
ifstream instead of the other way around.


Metric System! Do you not use it (wherever you are)?

Anyway, for all equations to do with Physics, we use the following as
the basic unit:

Energy: Joule
Pressure: Pascal
Dimension: Metre
Mass: Kilogram
Force: Newton

-JKop


I'm in Canada, so I know and use the metric system. I've taken very
few physics courses, so I didn't know that kilogram was preferred over
gram. Maybe this will illustrate my confusion better:

1/1000 of a joule = 1 millijoule
1/1000 of a pascal = 1 millipascal
1/1000 of a metre = 1 millimetre
1/1000 of a kilogram = 1 gram, not 1 millikilogram

Why is this one different?

Well, firstly what's the metric system all about... ? Water.

The aim of the metric system was to make:
1 litre water = 1 kg (nice and round)
..1 m^3 water = 1,000 grams
First thing you notice is that the figure for "grams" is way bigger. They
didn't like this, they preferred:

..1 m^3 = 1 kg

Long story short, the unit "gram" is way way smaller proportionately to the
other physical units, so now we use "kg" in equations.
-JKop
Jul 22 '05 #29
In general, a header file of constants such as this one is useful, but
I think that it should define only values that really are constant. For
example, the length of the day varies for a number of reasons, one of
these being that tidal interaction with the Moon is causing the average
length of the day to slow down. I'm not sure if the year is changing, but
I know that the Earth's orbital elements vary with time. So it would be
best to use the second, which is defined as a fundamental physical unit,
rather than days, weeks, months (which vary in length as previously
mentioned), or years. Values that vary with time are best represented by
functions, say in a standard physics library, rather than constants.

Another problem with units such as the day, month, or year is that there
are several types of each of these. There is a sidereal day (measured with
respect to the stars) and a solar day (measured with respect to the Sun).
These differ in length due to the Earth's motion around the Sun. There are
calendar months, then there is the synodic month (from one new moon to the
next) and the sidereal month (the time the moon takes to make one orbit).
There is a mean year, a sidereal year, an anomalistic year, and so on
(http://www.wordiq.com/definition/Anomalistic_year). So at the very least,
the type of unit being defined, e.g. sideral day, should be indicated by
the name of the constant.

--- Brian
Jul 22 '05 #30
JKop wrote:
Greg Schmidt posted:
JKop wrote:
Odd, I'd have thought that the gram, not the kilogram, would be
considered the "fundamental" unit. Why would you give the
fundamental unit a name that's derived from the name of a
non-fundamental unit? Not saying you're wrong, just that it seems an
odd way to do things. It's like, I dunno, deriving fstream from
ifstream instead of the other way around.

Metric System! Do you not use it (wherever you are)?

Anyway, for all equations to do with Physics, we use the following as
the basic unit:

Energy: Joule
Pressure: Pascal
Dimension: Metre
Mass: Kilogram
Force: Newton
I'm in Canada, so I know and use the metric system. I've taken very
few physics courses, so I didn't know that kilogram was preferred over
gram. Maybe this will illustrate my confusion better:

1/1000 of a joule = 1 millijoule
1/1000 of a pascal = 1 millipascal
1/1000 of a metre = 1 millimetre
1/1000 of a kilogram = 1 gram, not 1 millikilogram

Why is this one different?


Well, firstly what's the metric system all about... ? Water.

The aim of the metric system was to make:

1 litre water = 1 kg (nice and round)

.1 m^3 water = 1,000 grams


You probably meant

(0.1 m)^3 [of water has a mass of] 1,000 grams

but the more common conversion factor is

(1 cm)^3 of water has a mass of 1 gram
First thing you notice is that the figure for "grams" is way bigger.
They didn't like this, they preferred:

.1 m^3 = 1 kg

Long story short, the unit "gram" is way way smaller proportionately to the
other physical units, so now we use "kg" in equations.


The idea behind mks is that they are macroscopic units
suitable for common every-day measurements.
On hardly ever has occasion to measure quantities in grams
but a kilogram is a common measure of [potatoes] for example.
Jul 22 '05 #31
So, it was basically a mental error back when they were naming units?

Also the mass of 1 cubic cm of Water at STP (Standard Temperature and
Pressure) is not 1 gram... not exactly in anyway. (You'll be dealing
with ice).

-JKop
Jul 22 '05 #32
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message news:<ck**********@nntp1.jpl.nasa.gov>...
namespace physical {
namespace unit { // conversion factor
const double radian = 1.0;
const double radians = radian;
const double rad = radian;

[snip]

Paging Mr. K. Sink. Will Mr. K. Sink pick up a white house phone.

Seriously though. Having such constants in a header file is
superior to having them embedded in code. But only just.

Whatever use would be having a huge smacking wheelbarrow of
them hanging around? You are asking for trouble. Eventually
you are going to find that one of the names in there conflicts
with something you are using in your application.

Just as an example: I work in nuclear. The term "dollar" has
a meaning in terms of reactor activity. So does "cent."
And it's not the same as in your mega-everything header.

If you need such things, you pick and choose the few that you
are actually going to use. And you carefully select between
those items that are in fact not going to change (sides on
a square) or are very unlikely to change during the life of
your program (cents in a dollar), and split these from things
that could change. It makes some sense to put the not-going-to-
change things in a header file, when you actually do need them.

If you won't need them, a huge vacuum-cleaner-bag of a collection
of them is just annoying. Because you have to hunt through the
cruft to find the one you want. The savings of "already having
one when you want to add a new one" is trivial in comparison.

The may-change-or-will-change items you put in a data file and
read in at execution. Then you have a data utility of some kind.
A collection of functions that return the factors you want, for
example. Possibly as members of a class. Or even directly getting
the variables in a POD. That way you don't have to recompile your
bicycle design prog when the number of spokes on a wheel changes.
Socks
Jul 22 '05 #33
Something that calls itself puppet_sock wrote:
Whatever use would be
having a huge smacking wheelbarrow of them hanging around?
You are asking for trouble.
Eventually, you are going to find that one of the names in there
conflicts with something you are using in your application.


Evidently, you are unclear on the notion of namespaces.
But, of course, we expect as much
from something that calls itself puppet_sock. :-)
Jul 22 '05 #34
"E. Robert Tisdale" <E.**************@jpl.nasa.gov> wrote in message news:<cl*********@nntp1.jpl.nasa.gov>...
Something that calls itself puppet_sock wrote:
Whatever use would be
having a huge smacking wheelbarrow of them hanging around?
You are asking for trouble.
Eventually, you are going to find that one of the names in there
conflicts with something you are using in your application.


Evidently, you are unclear on the notion of namespaces.
But, of course, we expect as much
from something that calls itself puppet_sock. :-)


Ah, the irony. "That's not a problem because I can work around it."
Socks
Jul 22 '05 #35

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Valentin Tihomirov | last post by:
I have a .c file with a general code. It can be compiled with different constants for different applications. For example char a; where BYTE_SIZE is a constant defined in an external (.h?)...
3
by: eBob.com | last post by:
Is there a namespace of interesting and important constants such as maximum length of a filename, maximum length of a path, maximum and minimum values which can be held by a Long (and other data...
7
by: JohnR | last post by:
Couldn't find it in MSDN. Does anybody have a listing of the message constants that would be received in my application.addmessagefilter routine in VB.net? They are referred to all over MSDN but...
27
by: Matt | last post by:
Does the language have header files containing definitions of numbers such as pi and e? I believe some implementations used to have those, but I can't find them in Stroustrup. Thanks.
8
by: Brian C | last post by:
Hello all, I have a quick question coming from a long time C programmer, trying to get back into C++. What I want to do is something like (C version): int OpenLog(char *Filename) { FILE...
3
by: John Goche | last post by:
A common C++ trend is to use const int foo = 10; where some C programmers would have used #define FOO 10 in order to avoid preprocessor overheads.
2
by: Leslie Sanford | last post by:
I want to define a set of floating point constants using templates insteand of macros. I'd like to determine whether these constants are floats or doubles at compile time. In my header file, I have...
54
by: shuisheng | last post by:
Dear All, I am always confused in using constants in multiple files. For global constants, I got some clues from http://msdn.microsoft.com/en-us/library/0d45ty2d(VS.80).aspx So in header...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.