Re: Calculating Volume and surface area of STL files?

From: Gill Barequet (barequet@cs.Technion.AC.IL)
Date: Fri Feb 11 2000 - 20:06:00 EET

On Fri, 11 Feb 2000 Gerard Ryder wrote:

> Does anyone on the list have or know where I can find the equations for
> calculating the surface area and volume of STL files?

It is a straightforward generalization to 3D of the method of computing
the area of any simple (not necessarily convex) polygon in 2D.

In 2D you choose an arbitrary reference line (say, the X axis), so that
each edge of the polygon induces a trapezoid (formed by connecting
vertically the edge to the reference line). Some of the trapezoids have
positive areas, some of them have negative areas, depending on the
orientation of the edge relative to the reference plane. Each such
trapezoid (that is, its area) can be computed in constant time,
INDEPENDENTLY of the other trapezoids. Now simply sum up the areas of
all the trapezoids. The sum will match the area of the polygon. This is
very easy to prove, e.g., by an induction on the complexity of the

In 3D you do the same. Choose an arbitrary reference plane (say, the
XY plane). Each triangle of the polyhedron (the .stl file) induces a
triangular prism (again, by connecting the triangle orthogonally to the
reference plane). Some of the prisms have positive volumes, other have
negative volumes, depending on the orientation of the triangle relative
to the reference plane. Similarly to the 2-dimensional case, the sum of
the volumes of all the prisms will match the volume of the polyhedron.

A minor issue is how to compute the volume of any of the above prisms.
The easiest way I know of is to partition the prism into three tetrahedra.
(Draw this on paper and verify how.) Computing the volume of a tetrahedron
out of the coordinates of its four vertices is an easy exercise.
(Hint: | x1 y1 z1 1 |
       | x2 y2 z2 1 |
       | x3 y3 z3 1 | / 6 .)
       | x4 y4 z4 1 |


Gill Barequet, Ph.D. Phone: +972-4-829-3219
Faculty of Computer Science Fax: +972-4-822-1128
The Technion---IIT E-mail:
Haifa 32000 WWW:
                                "Life is NP-Hard." (-)

For more information about the rp-ml, see

This archive was generated by hypermail 2.1.2 : Tue Jun 05 2001 - 23:02:50 EEST