mprinkey |
November 23, 2015 15:35 |
Quote:
Originally Posted by prak_1989
(Post 574601)
Hi all,
How to calculate the volume of a general hexahedron whose faces are of different shapes and the four edges connecting the top and bottom surfaces are of different lengths and are not parallel to each other. Hope you could imagine that hexahedron :)
|
I'm no expert in computational geometry, but there is simple formula for computing volumes of tetrahedra. I wrote a library some time ago that implemented the tet formula for volume. Then I implemented the volume of a pyramid (one quad base and four triangular faces) as the sum of the volume of two tets. Then, I implemented the hex volume as the sum of three pyramid volumes (pick three faces that all touch each other at edges use those as the base for each. Use the opposite corner as top point for all three pyramids).
This all assumes that the faces are quadrilateral--I think that is a geometric requirement. If one face has four sides, I think they all do. You can build a six-sided volume using six triangles too. The above formula doesn't handle that case. Also, these quadrahedra must have vertices that are co-planar. This is probably not the most efficient way to compute the volume of general hexs, but it is more fool-proof than directly implementing a hex volume formula using a set of eight vectors. I generally only compute the volumes as part of the initialization process, so correctness is more important than absolute performance.
|