# How does VTKMassProperties compute volume?

Hello,
What is the math behind the volume computation performed in VTKMassProperties? Also what does Volume - X, Y and Z mean?

(I could see a research paper being cited, but can someone explain in a layman terms?)

Thanks

I think it computes the surface integral of the Z position vector over all the triangles that make up the surface. What I mean by Z position vector is the Z component of the (X,Y,Z) position vector, multiplied by the unit vector in the Z direction. Okay, that’s not the best explanation… you know how a position vector (or any vector) can be expressed as the sum of vectors in the X, Y, and Z directions? So the Z position vector is just the Z part.

So for every point on the surface, you take the dot product of the Z position vector at that point with the surface normal, and integrate that over the entire surface. Except this isn’t done point-by-point, but rather triangle-by-triangle. That’s the basic gist I get when I read the code. The choice of Z rather than X or Y seems to be arbitrary.

Edit: I guess I should add an explanation of why this works. Imagine a simple surface, like a sphere. Image a line along the Z direction that passes through the sphere, it will intersect the surface twice. There will be a certain distance between the “entry” point and the “exit” point. Now imagine a line along Z for every possible (X,Y) position, a whole bunch of parallel lines in a dense grid. You can see how the sum of all the entry-to-exit distances for all these lines will give you the volume of the sphere. Well, you can measure the “entry” Z position and “exit” Z position separately, in fact the only difference is the direction of the surface normal with respect to the Z direction. And this works for any shape of surface.