run_time_error
run_time_error

Reputation: 707

How to calculate volume of a 3D mesh from wavefront .obj file?

I am trying to parse wavefront .obj file. From wikipedia I learned it's format specification. I am interested in volume analysis. Before that i worked in .stl files. I can compute volume of tetrahedron by using dot and cross product. In .stl files triangular faces' coordinates are given i.e.

But in wavefront .obj files : Each face can contain three or more vertices. f v1 v2 v3 v4 ..... like this. I do not know how to calculate the volume now. Because my understanding is, it will produce a polyhedron. Any idea will be extremely helpful. Thanks!

Upvotes: 0

Views: 1915

Answers (1)

abenci
abenci

Reputation: 8651

Each polygonal face can be subdivided in triangles and therefore used for tetrahedrons. If you are lucky enough, you can find polygons with 4 vertices only (easy to be decomposed in two triangles on the fly). For polygons with more than 4 vertices you need a triangulation algorithm to decompose the planar polygon in triangles. You can check Ear Clipping for example.

Upvotes: 2

Related Questions