
How can I derive the formula of the volume of a grain pile in terms of w,l,h,t?

How can I derive the formula of the volume of a grain pile in terms of w,l,h,t?
On
At height $x$ from the base, the horizontal cross section is a rectangle whose dimensions range linearly from $w \times l$ to $t \times 0$
so, area of horizontal cross-section at height x is
$w(h-x) / h \times (l \times (h -x) + t \times x) / h$
$=(wh - wx) (lh - lx + tx) / h^2$
$=(lwh^2 - lwxh + txwh - lwhx + lwx^2 - wtx^2) / h^2$
now integrate x from zero to h, meaning that we are summing the areas of infinitesimal rectangles whose areas we know at a height x from the base
$\int_0^h (lwh^2 - lwxh + txwh - lwhx + lwx^2 - wtx^2) / h^2 dx$
$=[lwx - \frac{1}{2}lwx^2/h + \frac{1}{2}twx^2/h - \frac{1}{2}lwx^2/h + \frac{1}{3}lwx^3/h^2 - \frac{1}{3}wtx^3/h^2]_0^h$
$= lwh - \frac{1}{2}lwh + \frac{1}{2}twh - \frac{1}{2}lwh + \frac{1}{3}lwh - \frac{1}{3}wth$
$= \frac{1}{2}twh + \frac{1}{3}lwh - \frac{1}{3}twh$
$ = wh(\frac{1}{3}l + \frac{1}{6}t)$
We can divide this shape into $3$ parts in order to find the total volume - one triangular based prism in the centre and two rectangular based pyramids, one at either end. We do this by dropping verticals from either end of the length $t$.
We can then find the volumes of these shapes separately - the volume of a prism is:
\begin{align}V_{\text{prism}}&=\text{area of cross section}\times\text{length of side}\\ &=\frac 12 wh \times t\\ &=\frac{wht}2\end{align}
The volume of one pyramid is:
\begin{align}V_{\text{pyramid}}&=\frac 13 \times \text{base area}\times\text{height}\\ &=\frac13 \times \left(w\times \frac{l-t}2\right)\times h\\ &=\frac{hw(l-t)}6\end{align}
Now we can calculate the total area:
\begin{align}T_{\text{total}}&=V_{\text{prism}}+2\times V_{\text{pyramid}}\\ &=\frac{wht}2+2\times\frac{hw(l-t)}6\\ &=\frac{hw(2l+t)}6\\ &=\frac{hlw}3+\frac{htw}6 \end{align}