diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-03-01 15:11:35 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-03-01 15:11:35 -0500 |
| commit | 0d05cb75ee3c3d85481fe87ea287c97a439fe47a (patch) | |
| tree | 8603e4ac9d3a58715690643862d27ed769347b8d /unit.c | |
| parent | 47874c2ec00339314e43d282ab2bc906e9c9ac9b (diff) | |
| download | volute-0d05cb75ee3c3d85481fe87ea287c97a439fe47a.zip | |
temperature conversion functions
Diffstat (limited to 'unit.c')
| -rw-r--r-- | unit.c | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -18,6 +18,9 @@ /* Seconds per minute. */ #define SEC_PER_MIN 60.0 +/* Zero Celsius in Kelvin. */ +#define ZERO_C 273.15 + AngularSpeed rad_per_sec(double x) { @@ -108,6 +111,50 @@ as_psi(Pressure x) { } +Temperature +kelvin(double x) { + return x; +} + +Temperature +celsius(double x) { + return x + ZERO_C; +} + +Temperature +fahrenheit(double x) { + double c; + + c = (x - 32.0) * 5.0 / 9.0; + return c + ZERO_C; +} + +Temperature +rankine(double x) { + return x * 5.0 / 9.0; +} + +double +as_kelvin(Temperature t) { + return t; +} + +double +as_celsius(Temperature t) { + return t - ZERO_C; +} + +double +as_fahrenheit(Temperature t) { + return as_celsius(t) * 9.0 / 5.0 + 32.0; +} + +double +as_rankine(Temperature t) { + return t * 9.0 / 5.0; +} + + Volume cubic_centimetre(double x) { return x * 1e-6; |