Hi,
Last month I had the idea to create a "physics.h" which is a (sub)set of different physics formulas one can use. Recall what "math.h" is for math formulas.
The rationale was that while I was making a library for the DHT (temp/humidity) sensor I thought the dewPoint() formula should not be part of the sensor library as it is useful for any temp/humid sensor combination.
So physics.h doesn't do sensors, actuators or I/O,
just formulas. For now I have a simple first version with a few temperature related macro's and functions.
The architecture / structure I have in mind has 2 levels, at top is "physics.h" which just includes the more specific areas => To have multiple files one can tweak physics.h to include/exclude subsets very easily. Drawback is that some formulas will fit in multiple subsections.....
The following questions: (high level)
1) What do you think of this idea? why?
2) What do you think of the architecture? other ideas? why?
3) other remarks? why?
(low level)
4) what subsections should exist? (mechanics, electro, radiation, ...?
5) which formulas in which subsection?
6) sources for good formulas?
Please shoot!

Rob
physics.h
//
// FILE: physics.h
// VERSION: 0.1.00
// PURPOSE: physics functions for Arduino
//
// HISTORY:
// 2011-04-17 first version rob.tillaart(at)gmail.com
//
//
#ifndef physics_h
#define physics_h
#include "temperature.h"
#endif
temperature.h
//
// FILE: temperature.h
// VERSION: 0.1.00
// PURPOSE: temperature functions for Arduino
//
// HISTORY:
// 2011-04-17 first version
//
//
#ifndef temperature_h
#define temperature_h
#include "WProgram.h"
#define TEMPERATURE_LIB_VERSION "0.1.00"
// TEMPERATURE
#define Celsius2Fahrenheit(C) ((C)*9/5+32)
#define Fahrenheit2Celsius(F) (((F)-32)*5/9)
#define Celsius2Kelvin(C) ((C)+273.15)
#define Kelvin2Celsius(K) ((K)-273.15)
// DEWPOINT
// dewPoint function NOAA
// reference: http://wahiduddin.net/calc/density_algorithms.htm
double dewPoint(double celsius, double humidity)
{
double A0= 373.15/(273.15 + celsius);
double SUM = -7.90298 * (A0-1);
SUM += 5.02808 * log10(A0);
SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
SUM += log10(1013.246);
double VP = pow(10, SUM-3) * humidity;
double T = log(VP/0.61078); // temp var
return (241.88 * T) / (17.558-T);
}
// delta max = 0.6544 wrt dewPoint()
// 5x faster than dewPoint()
// reference: http://en.wikipedia.org/wiki/Dew_point
double dewPointFast(double celsius, double humidity)
{
double a = 17.271;
double b = 237.7;
double temp = (a * celsius) / (b + celsius) + log(humidity/100);
double Td = (b * temp) / (a - temp);
return Td;
}
#endif
//
// END OF FILE
//