First, Which Length Do You Have?
The calculator asks for the radius and the cylinder height: the straight middle section only. Many problems, and most real tanks, give you the total end-to-end length instead. Total length includes the two rounded ends, each one radius deep, so:
A pill-shaped container 24 cm long with a 4 cm radius has a straight section of 24 − 8 = 16 cm. Enter 16, not 24. The results panel shows the total length back to you, so you can confirm it matches your measurement. If you have a diameter, halve it for the radius.
A Cylinder Plus One Sphere
Pull the two rounded ends off a capsule and push them together, and they make one complete sphere of the same radius. So a capsule's volume is simply cylinder volume for the middle plus sphere volume for the ends. The calculator shows both parts separately before adding them, which makes it easy to see how much of a tank's capacity sits in its domed ends.
That share grows as the capsule gets stubbier. With h = 0 the shape is just a sphere, and the formula reduces to (4/3)πr³.
Two Examples in Full
A capsule-shaped solid: r = 3 cm, h = 10 cm
- Middle: π × 3² × 10 = 282.74 cm³
- Ends: (4/3)π × 3³ = 113.10 cm³
- Total: 282.74 + 113.10 = 395.84 cm³
The 24 cm container from above: r = 4 cm, total length 24 cm
- Straight section: 24 − 2 × 4 = 16 cm
- Middle: π × 4² × 16 = 804.25 cm³
- Ends: (4/3)π × 4³ = 268.08 cm³
- Total: 1,072.33 cm³, just over a liter
Had you entered 24 as the cylinder height, you'd get about 1,474 cm³, about 37% too high. That single mix-up is the most common capsule error.
Tanks and Pressure Vessels
Propane tanks, air receivers, and railway tank cars use this shape because domed ends spread internal pressure evenly, with no flat panels or sharp corners to concentrate stress. Three more cases, all at full capacity:
| Tank | Radius | Straight section | Middle + ends | Full volume |
|---|---|---|---|---|
| Horizontal storage tank | 0.6 m | 2.8 m | 3.167 + 0.905 m³ | 4.072 m³ (4,072 L) |
| Small vessel, 8 in diameter | 4 in | 14 in | 703.72 + 268.08 in³ | 971.80 in³ (about 4.2 US gal) |
| Vertical tank | 1.2 ft | 5 ft | 22.62 + 7.24 ft³ | 29.86 ft³ (about 223 US gal) |
Full capacity doesn't depend on whether the tank lies flat or stands upright. Orientation matters only when it's partly full: in a horizontal tank the liquid surface cuts across the curved sides and both domes, so half the depth is not half the volume. This calculator gives the full figure; partial fill of a horizontal tank needs a segment calculation.
Two practical notes. Use inside dimensions, since vessel walls can be thick. And the water capacity on a propane tank's label is not what it's filled to: propane tanks are normally filled to about 80% to leave room for the liquid to expand. If the vessel tapers smoothly with no straight middle, like an egg-shaped digester, the Ellipsoid Volume Calculator fits better.
Liters, Gallons, and Cubic Feet
The answer comes out in the cube of your input unit, and the calculator converts it to liters, US gallons, imperial gallons, and cubic feet. For hand checks: 1,000 cm³ = 1 liter, 1 m³ = 1,000 liters, 231 in³ = 1 US gallon, and 1 ft³ ≈ 7.48 US gallons.
How the Numbers Are Checked
The code has two lines, not one: cylinderVolume = PI * r^2 * height and capVolume = (4/3) * PI * r^3, added together for the total. The second line treats both ends as a single sphere rather than computing each hemisphere separately. The result is identical, but it avoids doing and rounding the same multiplication twice. Both terms read the same radius input, so changing it updates the middle and the ends together.
Frequently Asked Questions
How do you calculate capsule volume?
Use V = πr²h + (4/3)πr³. Calculate the middle cylinder (πr²h) and both rounded ends together as one sphere ((4/3)πr³), then add. Both terms use the same radius. If diameter is given, divide by 2 first: r = d ÷ 2.
How do you calculate capsule volume from total length?
Find cylinder height first: h = total length − 2r. For a capsule 24 cm long with radius 4 cm: cylinder height = 24 − 8 = 16 cm. Then apply the full formula.
Is horizontal capsule tank volume different from vertical?
Full capacity is identical regardless of orientation. Orientation only affects partial-fill calculations, when a horizontal tank is not full, the liquid surface cuts through the rounded ends at an angle, making depth-based estimates inaccurate.
Why does the formula use a full sphere rather than two separate hemispheres?
Two hemispheres of the same radius equal exactly one sphere, so the calculation simplifies to the sphere volume formula (4/3)πr³ for both ends combined. Calculating each hemisphere as (2/3)πr³ and doubling gives the same result, it is just one extra step with no benefit.
References
- Spherical Cylinder, Wolfram MathWorld: mathematical definition of the capsule shape, volume formula, and surface area derivation.
- Cylinder, Wolfram MathWorld: cylinder volume formula (πr²h) and surface area, the basis for the straight-section term.
- Capsule, Math is Fun: practical explanation of total length vs. cylinder height with worked examples.