Hello.
I am new to Opengl and graphical/geometric algorithms.
How can i compute the volume of a given set of points in space.
Do i have to do a triangulation, compute the volumes of the single tetraeders and unify the results to one big volume ?
Or is there a better approach ?
Assuming you can form convex polyhedrons from your points in space, you can calculate the volume of those polyhedrons by selecting a single vertex from the polyhedron as the apex, then forming tetrahedrons with the triangles in the other polygons, one at a time, summing the volumes as you go.
The volume of a single tetrahedron is V = 1/3 * area of triangle * height, which can also be written as V = 1/6 * dot(H, cross(V2,V1)), where H is the vector from polygon point P0 to the apex, apex - P0, and V1, V2 are the vectors Pi+1 - P0, Pi+2 - P0, respectively, with i in [0, n-2) (Pi are the points of the current polygon and n is the total number of points).
Keep in mind volumes can produce some very large numbers so double precision may be advisable depending on the scale of things. You could also simply scale all volumes by a small number to avoid overflow, while still maintaining equivalent relative proportions.
As Zbuffer pointed out, tesselation of the space is probably going to be the hard part of this assignment.