UNPKG

dive-deco

Version:

A TypeScript implementation of decompression calculation algorithms for scuba diving, featuring Bühlmann ZH-L16C algorithm with gradient factors, gas management, and oxygen toxicity tracking.

68 lines (67 loc) 1.63 kB
"use strict"; // Math utility functions for decompression calculations Object.defineProperty(exports, "__esModule", { value: true }); exports.round = round; exports.ceil = ceil; exports.floor = floor; exports.abs = abs; exports.min = min; exports.max = max; exports.exp = exp; exports.ln = ln; exports.log10 = log10; exports.pow = pow; exports.sqrt = sqrt; exports.lerp = lerp; exports.clamp = clamp; exports.pressureToDepth = pressureToDepth; exports.depthToPressure = depthToPressure; function round(value) { return Math.round(value); } function ceil(value) { return Math.ceil(value); } function floor(value) { return Math.floor(value); } function abs(value) { return Math.abs(value); } function min(a, b) { return Math.min(a, b); } function max(a, b) { return Math.max(a, b); } function exp(value) { return Math.exp(value); } function ln(value) { return Math.log(value); } function log10(value) { return Math.log10(value); } function pow(base, exponent) { return Math.pow(base, exponent); } function sqrt(value) { return Math.sqrt(value); } // Linear interpolation function lerp(a, b, t) { return a + t * (b - a); } // Clamp value between min and max function clamp(value, minVal, maxVal) { return Math.min(Math.max(value, minVal), maxVal); } // Convert pressure to depth (in meters, assuming seawater) function pressureToDepth(pressure, surfacePressure = 1.013) { return (pressure - surfacePressure) * 10.33; } // Convert depth to pressure (in bar, assuming seawater) function depthToPressure(depth, surfacePressure = 1.013) { return surfacePressure + depth / 10.33; }