|
|
Greg M. Johnson wrote:
>
> Is there an automatic way to calculate the volume of a 3d mesh?
For each triangle, take the following matrix:
[A.x A.y A.z]
[B.x B.y B.z]
[C.x C.y C.z]
Where A, B, and C are the vertices of the triangle. Make sure that
the order from A to B to C goes in the same direction for each triangle
(either clockwise or counter-clockwise) when viewed from the outside
of the mesh.
Take the determinant of this matrix. Divide it by six. If the
determinant is negative, leave it that way.
Add up all of the determinants for all of the triangles. Divide by
six. If the sum is negative, make it positive. The result is the
volume of the mesh.
Note that every edge *MUST* be shared by exactly TWO triangles, or the
sum will be entirely meaningless.
Hope this helps,
John
--
ICQ: 46085459
Post a reply to this message
|
|