views:

538

answers:

6

Dear Sir,

I have a 3D closed mesh car object having a surface made up triangles. I want to calculate its volume, center of volume and inertia tensor.

Could you help me

Regards. George

A: 

Well, there isn't much information on the car being provided here - you should be able to break down the car into simpler shapes - the higher degree of approximation your require - the more simpler shapes you can break it into. (This could be difficult if the car is somehow dynamically generated and completely different every time ... but I don't see that situation making any sense).

This should help with finding the Inertial Tensor of various simpler shapes: http://www.gamedev.net/community/forums/topic.asp?topic%5Fid=57001 , finding the volumes and the likes of things like spheres and cubes is pretty common knowledge so I won't bother linking that.

Streklin
A: 

From numerical point of view, what you are trying to achieve is quite simple and can be reduced to calculating few quadratures. Wikipedia will provide needed information about maths behind it.

If you are looking for out-of-the-box volume calculation, take a look at this entry. As of inertia -- shape is not enough, as you also need distribution of mass.

samuil
A: 

I think it was Archimedes who discovered that if you submerge the car in a volume of liquid, the displaced liquid will have the same volume as the car.

I'm not sure what this would help you in this case though. Having a liquid simulation running in the background and submerging the mesh into it sounds a bit over the top. Although, I think it does work, and therefore qualifies as a (bit useless nonetheless) answer. ;^)

Toad
The mesh has holes in, so you'd only be measuring the volume of the wire that the mesh was made out of ;-)
Richard Ev
nono... he specifically wrote: I have a 3D closed mesh car object having a surface made up triangles. Since it is closed, it will not let the liquid in ;^)
Toad
Export the mesh to a DXF, print out the car using a Z-printer, submerge in water and then multiply the displaced volume by the scaling of the model. Easy!
Coxy
A: 

Here's a paper and sample code of an algorithm performing these tasks.

DR
+2  A: 

For volume...

For each triangular facet, lookup its corner points. Call 'em P,Q,R.
Compute this quantity (I call it "partial volume")

pv =  PxQyRz + PyQzRx + PzQxRy - PxQzRy - PyQxRz - PzQyRx

Add these together for all facets and divide by 6.

Important! The P,Q,R for each facet must be arranged clockwise as seen from outside. (Or all counter-clockwise, as long as it's consistent for all facets.)

If the mesh has any quadrilaterals, just temporarily hallucinate a diagonal joining one pair of opposite corners. That makes it into two triangles.

Practical computationial improvement: Before doing math with P,Q and R, subtract the coordinates of some "center" point C. This can be the center of mass, a midpoint between the min/max x, y and z, or any convenient point inside or near the mesh. This helps minimize truncation errors for more accurate volumes.

DarenW
A: 

Matlab code can be found here:

http://www.advancedmcode.org/volume-enclosed-by-a-triangulated-surface.html

Luigi Giaccari