Advertisement

Volume of a model

Started by February 08, 2002 05:39 PM
5 comments, last by mess 23 years ago
Hi, Ive been searching for code that does this, ive tried to write my own but cant figure out the exact method, like I know i have to convert the concave polys into convex ones, not sure what to do after that. if somone can point me in the right direction, thanks
I''ve not tried this but it should work:

Pick a vertex of the polyhedron. Then for every face form a pyramid from this vertex and face. The volume is then the sum of the volumes of these pyramids, each 1/3 area of base X perpendicular height. Some will be degenerate, with the vertex lying in the plane, but these have zero volume and can be disregarded. Obviously the model will have to be polyhedral for this to work.
John BlackburneProgrammer, The Pitbull Syndicate
Advertisement
ähm .. this is a lot of work... first thing you have to do is you have to check if the Object is closed ( i have done this bye checking every Neighbour of a Face ( and if there is no Neighbour it is''nt closed )

you could also use a tree ... because this would increase your Calculations Speed ...

but it could work with a good Ray Traceing code ... if you are interrested, ask my in ICQ ... i think i''ll have some codes on my PC ...

wbw J@nkey
J.A.N.K.E.Y.: Journeying Artificial Nocturnal Killing and Exploration Youth
pretty sure its something
like summing the dot products
of 2 sides of all the faces....
The best I can offer is the following (since I don''t have time to give it much thought):

Given three vectors a ,b and c with common origin, the volume of the parallelapiped formed by these 3 vectors (the 3-d parallelogram) is given by V = |a .(b xc )|.

You might be able to work out the volume of an arbitrary polygonal object from this (or you might not!?)??

Cheers,

Timkin
To a fair extent, it depends on how you''ve defined the volume: CSG, BSP, poly soup (is it closed? which side is inside?), etc.

Assuming you have some way of determining whether a point is inside or outside, you can use a Monte Carlo method.

Pick a bounding volume of easily calculated volume, like a sphere, cube or cylinder. It should completely surround your model. Then randomly pick points inside the bounding volume. Keep two counters: the number inside the model and the number outside. Use MANY MANY points, and have a good random number generator.

Then the volume of the model is:

  float volume(int num_inside, int num_outside, float bounding_volume){   return (bounding_volume * num_inside) / float(num_inside + num_outside);}  


Of course, this method isn''t fast, but I don''t know what volume determination method is...


---- --- -- -
Blue programmer needs food badly. Blue programmer is about to die!
Advertisement
Try this link!

http://www.cs.berkeley.edu/~mirtich/massProps.html

Note that if you can compute the total mass of an object, then you can compute its volume by setting density = 1!

I don''t think this code is restricted to convex polyhedra.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

This topic is closed to new replies.

Advertisement