diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-11-11 10:00:45 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-11-11 10:00:45 +0100 |
commit | 4c3dfee446eda061f862e1fdcce93b54a066feff (patch) | |
tree | a6a3087c1172f8a4856f453223c433e7aa525b1b /dive.h | |
parent | 776f92edcf9e1fb563f8cae5bc49c54a85ff2faf (diff) | |
parent | e167108c76c4a74ab50561fd59b2158704767a75 (diff) | |
download | subsurface-4c3dfee446eda061f862e1fdcce93b54a066feff.tar.gz |
Merge branch 'pressure'
Make depth to absolute pressure conversions consistent.
Diffstat (limited to 'dive.h')
-rw-r--r-- | dive.h | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -282,6 +282,20 @@ struct dive { struct sample sample[]; }; +/* Pa = N/m^2 - so we determine the weight (in N) of the mass of 10m + * of water (and use standard salt water at 1.03kg per liter if we don't know salinity) + * and add that to the surface pressure (or to 1013 if that's unknown) */ +static inline int depth_to_mbar(int depth, struct dive *dive) +{ + double specific_weight = 1.03 * 0.981; + int surface_pressure = 1013; + if (dive->salinity) + specific_weight = dive->salinity / 10000.0 * 0.981; + if (dive->surface_pressure.mbar) + surface_pressure = dive->surface_pressure.mbar; + return depth / 10.0 * specific_weight + surface_pressure + 0.5; +} + /* this is a global spot for a temporary dive structure that we use to * be able to edit a dive without unintended side effects */ extern struct dive edit_dive; |