# Formula to find volume of a rectangular solid

Hi all,

I need help finding a formula to find the volume of a solid that has a fixed width and depth but 4 different heights. To see what I mean, please take a look at a sketch I drew below.

Thanks.

## Answers and Replies

Since the top vertices aren't in the same plane, there is no obvious answer. It will likely depend on the shape of the top face.

The top vertices has a rectangular shape and the dimension is 2x3. To clarify, the width of this solid is 2 and the the depth is 3. Meaning all angles on the top vertices are perpendicular to each other.

abbas_majidi
You can get one of the corners of 2×3 face as origin of 3D coordinate and it's face(contain origin and 2×3) must be in x-y plate. Now you must find equation of face which is above of x-y plate (another 2×3 face) in form z=f(x,y) and calculate integral of f in 2 dimension x&y from 0<x<2 and 0<y<3. answer of integral will be volume of solid.

The top vertices has a rectangular shape and the dimension is 2x3. To clarify, the width of this solid is 2 and the the depth is 3. Meaning all angles on the top vertices are perpendicular to each other.
By shape, I meant how the z-value of the top face changes wrt the domain bounded by the top face.

By shape, I meant how the z-value of the top face changes wrt the domain bounded by the top face.

All angles are perpendicular to each other with the exception of the lower vertices. If you cover the bottom of this solid, it would look exactly like a rectangular prism.

Another way to put it is that if the height were all the same, eg.) 1.2, you could calculate the volume by multiplying 2 x 3 x 1.2

Mark44
Mentor
One way to get the volume is to use the calculus technique of integration. To simplify matters I would turn the thing over so that the bottom is flat. Using the (now) top vertices, I would find the equation of the plane that represents the top face. Assuming that the plane of the top surface is defined by z = ax + by + c, the integral would look like this:
$$\int_{x = 0}^2 \int_{y = 0}^3 ax + by + c~dy~dx$$

All angles are perpendicular to each other with the exception of the lower vertices. If you cover the bottom of this solid, it would look exactly like a rectangular prism.

Another way to put it is that if the height were all the same, eg.) 1.2, you could calculate the volume by multiplying 2 x 3 x 1.2
I've attached an example image of what I mean. The model is the same as the one in your image. Notice the drastic change of color on the top face? That's because the quadrilateral polygon is made up of two triangles. If the polygon was planar, the triangles would be in the same plane and there'd be no change in color. Now I can also choose to retriangularize the polygon so the common edge of the triangles runs between the two other vertices. It would hence look differently and possibly have a different volume. So it's important to know the function z=f(x,y) that describes this top face since it's clearly not planar.

Now I don't know what you mean by angles being perpendicular to each other. I've checked the angles for each pair of adjacent edges and if the edges are straight then no pair is at a right angle. Check it yourself by calculating the vectors for each edge and taking the dot product.

#### Attachments

• SolidPolygon.jpg
16.6 KB · Views: 400
One way to get the volume is to use the calculus technique of integration. To simplify matters I would turn the thing over so that the bottom is flat. Using the (now) top vertices, I would find the equation of the plane that represents the top face. Assuming that the plane of the top surface is defined by z = ax + by + c, the integral would look like this:
$$\int_{x = 0}^2 \int_{y = 0}^3 ax + by + c~dy~dx$$

Thanks but how do I find the equation of the plane that represents the top face?

I've attached an example image of what I mean. The model is the same as the one in your image. Notice the drastic change of color on the top face? That's because the quadrilateral polygon is made up of two triangles. If the polygon was planar, the triangles would be in the same plane and there'd be no change in color. Now I can also choose to retriangularize the polygon so the common edge of the triangles runs between the two other vertices. It would hence look differently and possibly have a different volume. So it's important to know the function z=f(x,y) that describes this top face since it's clearly not planar.

Now I don't know what you mean by angles being perpendicular to each other. I've checked the angles for each pair of adjacent edges and if the edges are straight then no pair is at a right angle. Check it yourself by calculating the vectors for each edge and taking the dot product.

Wow, first off thank you for taking the time to write this response. I haven't really thought it out that far. Basically, what I'm trying to do is to estimate the volume of a pit excavation site by measuring all 4 sides of the pit. How do you suggest I find an estimation of the volume of this pit?

Thanks but how do I find the equation of the plane that represents the top face?
It's a surface, but it's not a plane.

For any two points in a plane defined by the equation $a x + b y + c z + d = 0$, the equation $a \Delta x + b \Delta y + c\Delta z = 0$ must apply, where $\Delta x$ represents the difference in x-coordinates and so on. This doesn't apply to the top face in question, since two opposite and parallel edges of equal lengths have different $\Delta z$.

Mark44
Mentor
Thanks but how do I find the equation of the plane that represents the top face?
You have the coordinates of all four vertex points on the top face. Label these points A, B, C, and D (where A and C are opposite vertices, and B and D are opposite vertices).

Form two vectors, ##\vec{AB}## and ##\vec{AD}##.
Find the cross product of these vectors and call it ##\vec{n}##. This will be a vector that is perpendicular to (normal to) the plane of the top face.
Take any of the four vertices, say ##A = (x_a, y_a, z_a)##.
Let P(x, y, z) be any point on the top plane. Then the equation of the plane is given by: ##\vec{PA} \cdot \vec{n} = 0##.

Edit: I've assumed that the top surface is a plane, but as da_nang points out, that might not be the case. The vertical sides of the box have to be specific lengths in order for the top surface to be planar.

Wow, first off thank you for taking the time to write this response. I haven't really thought it out that far. Basically, what I'm trying to do is to estimate the volume of a pit excavation site by measuring all 4 sides of the pit. How do you suggest I find an estimation of the volume of this pit?
Well if you don't have any information on the interior then the best I think you can do without further information is to fit a plane to those coordinates and hope it doesn't vary too much from reality. Least-squares might do. After that, you use this approximation in the integral given by Mark44.

Well if you don't have any information on the interior then the best I think you can do without further information is to fit a plane to those coordinates and hope it doesn't vary too much from reality. Least-squares might do. After that, you use this approximation in the integral given by Mark44.

If its not too much to ask, can you quickly do the calculation needed to find the volume of this solid so I can have something to refer to? Thanks!

Mark44
Mentor
If its not too much to ask, can you quickly do the calculation needed to find the volume of this solid so I can have something to refer to?
Why don't you give it a shot, and we'll take a look at what you did?

SteamKing
Staff Emeritus
Science Advisor
Homework Helper
Hi all,

I need help finding a formula to find the volume of a solid that has a fixed width and depth but 4 different heights. To see what I mean, please take a look at a sketch I drew below.

Thanks.
There's no explicit formula to calculate the volume of such a solid, and using integral calculus and a hefty dose of analytic geometry seems to be a bit much to figure the volume of a hole.

A quick and dirty estimate of the volume can be made by calculating the areas of the ends of the excavation. These are trapezoids with a width of 2 units each. The heights indicated on your diagram are the lengths of the sides of each trapezoid:

http://www.mathopenref.com/trapezoidarea.html

Let's call these areas A1 and A2. The volume can be calculated using the trapezoidal rule and will be:

V ≈ (1/2) * Length * (A1 + A2) cubic units

Here, Length = 3 units

If you need something a little more accurate, you can calculate the area of a section of the excavation in the middle and use Simpson's First Rule, but the trapezoidal rule should give you a sufficiently accurate result for most purposes.

Mark44 and beamthegreat
There's no explicit formula to calculate the volume of such a solid, and using integral calculus and a hefty dose of analytic geometry seems to be a bit much to figure the volume of a hole.

Thank you, SteamKing! This is exactly what I needed.

PeroK
Science Advisor
Homework Helper
Gold Member
2020 Award
If you take x going from 0 to 3, you could consider the cross-sectional area as a function of x. You have a common width of 2 and a variable height (varying linearly on each side). ##h_1## on the left, and ##h_2## on the right.

##A(x) = \frac{1}{2}(2)(h_1 + h_2) = h_1 + h_2##

You could integrate this for x from 0 to 3, or (as it's linear) just take the averages of the h's and multiply by 3.

This gives ##V = 3(1.35 + 1.35) = 8.1##

Am I missing something?

PeroK
Science Advisor
Homework Helper
Gold Member
2020 Award
I thought it was worth posting the general solution here. If the solid has width ##w##, length ##l##, heights ##a, b## at the front corners and heights ##c, d## at the back, then:

##h(x, y) = a + \frac{y}{w}(b-a) + \frac{x}{l}[c + \frac{y}{w}(d - c) - (a + \frac{y}{w}(b-a))]##

Where ##x## is the distance along the length and ##y## across the width and ##h(x,y)## is the height at that point.

##\int_{0}^{l} \int_{0}^{w}h(x, y)dydx = wl(\frac{a+b+c+d}{4})##

So, the volume is ##wl## times the average height of the four corners, which makes sense.

Last edited:
I thought it was worth posting the general solution here. If the solid has width ##w##, length ##l##, heights ##a, b## at the front corners and heights ##c, d## at the back, then:

##h(x, y) = a + \frac{y}{w}(b-a) + \frac{x}{l}[c + \frac{y}{w}(d - c) - (a + \frac{y}{w}(b-a))]##

Where ##x## is the distance along the length and ##y## across the width and ##h(x,y)## is the height at that point.

##\int_{0}^{l} \int_{0}^{w}h(x, y)dydx = wl(\frac{a+b+c+d}{4})##

So, the volume is ##wl## times the average height of the four corners, which makes sense.
This is of course assuming the surface is a hyperbolic paraboloid, which is not necessarily the case. But it works as an approximation.

An alternative approximation is to use two diagonally opposite points at heights $z_1, z_2$. This allows you to calculate the volume as $V = \frac{z_1 + z_2}{2} \Delta x \Delta y$ by interpreting the surface as a plane.

Last edited:
PeroK
Science Advisor
Homework Helper
Gold Member
2020 Award
This is of course assuming the surface is a hyperbolic paraboloid, which is not necessarily the case. But it works as an approximation.

An alternative approximation is to use two diagonally opposite points at heights $z_1, z_2$. This allows you to calculate the volume as $V = \frac{z_1 + z_2}{2} \Delta x \Delta y$ by interpreting the surface as a plane.

The surface is not a plane, but every cross-section (parallel to the sides) is a trapezium. The formula I gave for ##h(x,y)## is exact at every point.