Archived

This topic is now archived and is closed to further replies.

Volum!

This topic is 5009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have defined a convex 3D Shape, by a set of planes(point + normal). The Shape is the space that is behind all planes. Now my problem is: is there a fast way to calculate the volum of this shape, based on the planes? Now i have to reduce the shape to 4 point pyramides, but its to slow to do hundred of times per frame... With this method, i have to rearange the data, and expand it every time. The hard part is that i want to be able to fast add a plane, and then calculate the new volum, 100 times every frame! The original shape is only ~15 planes, so its not very complicated. Anyone? Links? Ideas?

Share on other sites
I think you have to convert the planes-based description of your convex polyhedron into a description of vertices and faces. From there, computing the volume is pretty easy.

Share on other sites
I already did, but this is slow, and i have to do this many times each frame, so its going to kill frame rate!

Can you do this fast and whitout alot of temp data, if you have the faces and the verteces?

Share on other sites
Once you have the representation in vertices and faces, you can do it very, very quickly. Would that be enough for your situation?

Share on other sites
This is probably a useless thought, but it can't hurt to post if it turns out to actually be useful: For any convex polyhedron, it is ridiculously simple to determine whether a point is inside; simply make sure it's on the inside of each of the planes. For an n-gon, that's 'n' tests.

So, if you generate a random point within a bounding AAB, the probability that it will be inside is, Vpoly/Vbox.

Therefore,
Vpoly = (Nin/Nout)*Vbox

If your polyhedron changes slowly with time, for example, it may be sufficient to do a few random tests each frame to adjust the value, rather than recomputing the volume from scratch each frame.

[edited by - TerranFury on March 24, 2004 12:08:33 AM]

Share on other sites
alvaro:

TerranFury:
Thanks, but its going to change alot every frame so i hvae to do it from scratch, and then it becomes slow.

Share on other sites
Make all your faces into triangles. Keep a consistent orientation.

Then for each face, consider the value of the determinant
|x1 y1 z1||x2 y2 z2||x3 y3 z3|

Divide it by 6 and you get the signed volume of a tetrahedron formed by the origin and your three vertices. Sum over all faces and automagically, you get the right answer. Of course you can delay the division by six until the end. You may have to change the sign at the end, depending on the orientation you used in your triangles.

If my explanation is not good enough, I found this one too:
http://www.trianglesoftware.com/solidvolume.htm

Share on other sites
Perfect! Just what i needed!
Thanks alot!

• Forum Statistics

• Total Topics
628642
• Total Posts
2983998

• 9
• 9
• 10
• 21
• 20