Skip to content

Instantly share code, notes, and snippets.

@BruceMcKinnon
Created February 17, 2021 22:27
Show Gist options
  • Save BruceMcKinnon/fd06c963ad068d087551c274c21b73fa to your computer and use it in GitHub Desktop.
Save BruceMcKinnon/fd06c963ad068d087551c274c21b73fa to your computer and use it in GitHub Desktop.
Volume of a bag
<?php
// calcBagVolume() - Calculate the volume of a bag or satcel. Provide the width/height dimensions in cms and get the volume in litres
function calcBagVolume($length,$width) {
// https://mathworld.wolfram.com/PaperBagSurface.html
$volume = pow($width,3) * ( ( $length / (pi() * $width) ) - ( 0.142 * ( 1 - (pow(10,(0-($length/$width)) ) ) ) ) );
$litres = $volume / 1000;
return $litres;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment