Obviously, you also need to know the length of the cylinder.
A chord (such as the line the liquid makes across the end of the cylinder) divides a circle into two parts. The area of the smaller part is given by
A = R2ArcCos[r/R] - r√(R2-r2)
In this formula
R = the radius of the circle
r = the distance from the center of the circle to the chord |R-depth|
A = the area of the smaller part of the circle. If the cylinder is more than half full, this will be the area of the empty space. If the cylinder is less than half full, this will be the area of the liquid.
The ArcCos function needs to return its value in radians, rather than degrees.
Once you know the area of the tank end that is covered by liquid, you can multiply by the length of the cylinder to find the volume.
_____
Of course, the area of the entire circular end is
A = Pi*R2
A chord (such as the line the liquid makes across the end of the cylinder) divides a circle into two parts. The area of the smaller part is given by
A = R2ArcCos[r/R] - r√(R2-r2)
In this formula
R = the radius of the circle
r = the distance from the center of the circle to the chord |R-depth|
A = the area of the smaller part of the circle. If the cylinder is more than half full, this will be the area of the empty space. If the cylinder is less than half full, this will be the area of the liquid.
The ArcCos function needs to return its value in radians, rather than degrees.
Once you know the area of the tank end that is covered by liquid, you can multiply by the length of the cylinder to find the volume.
_____
Of course, the area of the entire circular end is
A = Pi*R2