1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| class Converter {
public:
constexpr Converter(double factor, double offset) :
factor_(factor), offset_(offset) {}
constexpr double toHuman(double siVal) const {
return (siVal - offset_) / factor_;
}
constexpr double toSI(double humanVal) const {
return humanVal * factor_ + offset_;
}
private:
double factor_;
double offset_;
};
// converts to and from Pa
static Converter pressureHPa (100, 0);
static Converter pressurPSI (6894.75729 , 0);
// converts to and from m3
static Converter volumeL (1/1000.0, 0);
static Converter volumeML (1/1000000.0, 0);
static Converter volumeGal (0.00378541, 0);
// converts to and from m3/s
static Converter flowLPS (1/1000.0, 0);
static Converter flowLPM (1/60000.0, 0);
static Converter flowLPH (1/3600000.0, 0);
static Converter flowCCM (1/60000000.0, 0);
static Converter flowGPM (0.0000630901964, 0);
// converts to and from °K
static Converter tempC (1, 273.15);
static Converter tempF (5.0/9.0, 459.67);
// converts to and from s
static Converter timeM (60, 0);
static Converter timeH (3600, 0);
static Converter timeD (84600, 0);
// converts to and from kg
static Converter massLb (0.453592, 0);
static Converter massG (0.001, 0); |
Partager