Calculating the volume of a square tank or vertical cylinder is a about the limit of my Math skills. embarrassingly it's been 25 years since i used cos or square root.
Could someone offer some insight on how to translate this equation into C++?
In case someone is interested in understanding why.. i have an unusual shape domestic heating oil tank and wish to use an HC-SR4 to measure the quantity of oil.
I'd probably cheat - put four load cells underneath and weigh it.
Edit: No matter what, you'll have an inaccuracy due to the ribs in the container, and it's a pretty complex shape overall. Weighing is relatively easy.
I'd planned on calculating the volume of liquid by subtracting the volume of the piece of cylinder that has been removed from the measured level calculation of a complete cylinder.
I'll have a go at re-writing the formula and post here for you to laugh at or make suggestions!
OldSteve Nice idea. thanks for that. It's a possibility although the tank will never be empty enough to lift for sometime. it's getting colder and wet over here in the UK.
Approach the cylinder as a cube with its current footprint as one side.
As this cube is smaller than the real volume you are always on the safe side.
(otherwise take the footprint a bit smaller)
float volume = floor * height.
a more accurate approximation would be an "hexagon-cylinder".
Calculating the volume could be done in 2 steps. Volume upper halve + volume lower halve.
Ah Rob, thanks that's super. looks as though i tweaked your interest too. i think i will ignore the tanks ribs and slightly domed ends as it's really only an approximation of the oil volume i'm after. I agree a flow meter would show consumption with the best accuracy. something to add when the aga gets turned off in the spring.