How to calculate atypical object volume

40 Views Asked by At

I am not a mathematician but a simple programmer and came across a situation where I have to calculate different kinds of object volume. There is no specific type of object and i found that there are dozen of formulas to calculate volume like

  1. Cube $= a^3$
  2. Rectangular prism $= a b c$
  3. Irregular prism $= b h$
  4. Cylinder $= b h = π r^2 h$
  5. Pyramid $= \dfrac13 b h$
  6. Cone $= \dfrac13 b h = \dfrac13 π r^2 h$
  7. Sphere $= \dfrac43 π r^3$
  8. Ellipsoid $= \dfrac43 π r_1 r_2 r_3$

and maybe many more. But is there any general formula exists that can calculate the volume of any type of object?