Maths wizzes: volume question...

This should be simple, at least when I talk it out, but I can’t concoct a formula that works. Please help.
The situation boils down to getting the volume of a container. The contain is a cylinder with three distinct sections: a cone, a tube, and a roof.


 
       /\
      /  \
     |    |
     |    |
     |    |
     |    |
     |    |
      \  /
       \/


I can get the volume of an empty container but I need to calculate the volume of product when the bin is partially filled.

I have dimensions as follows:
cone height: ch
cylinder height: h
cylinder area: a
roof height: rh

Assumptions:

  • product in bin is level
  • product fills bin to point of measurement
  • slopes of cone and roof are 45 degrees so volume can be calculated using 1/3
    so volume of a bin = (h * a) + ((1/3) * ch * a) + ((1/3) * rh * a)
    The only measurement (x) I have is one taken from the top of the roof, measuring straight down to the product in the bin.

How can I calculate the volume of the product?

I get hung up when x > h or x < rh.

You can’t set up a single smooth formula for this. Basically, you need three separate formulae for the three different cases. If x < rh, then you’ve got all of the bottom cone filled, and all of the cylinder, so you’re starting off with 1/3 cha + ha. In addition to that, you’ve got part of the roof filled, too: The total volume of the roof is 1/3 rha, and the part of it currently empty is equal to 1/3 pix^2 * x, or converting that, 1/3 a x^3/rh^2. So the total volume filled is equal to a*(1/3 ch + h + 1/3 rh - 1/3 x^3/rh^2) – That’s all of the bottom plus all of the cylinder plus all of the top minus the empty part of the top.

Thanks. I was hoping to do this without if statements.

I guess I could go take a cutting torch and modify all the bins…