Reply
Reply
 
Thread Tools Display Modes
Sectaurs's Avatar
Old (#1)
is there an easy way in max to determine the surface area and/or volume of a mesh in the scene's units?
Roböt - The Company - 3D Prototypes and Prints

Lead Artist - Stomp Games
Offline , veteran polycounter, 3,855 Posts, Join Date Oct 2004, Location Maynard, MA Send a message via AIM to Sectaurs  
   Reply With Quote

Whargoul's Avatar
Old (#2)
I'm not sure how well you know the scripting language, but here's how you can calculate the surface area of a mesh. The area of a triangle is equal to half the magnitude of the cross product of two of it's edges. ie. for triangle ABC:

area ABC = 0.5 * | AB X AC |

and then the surface area is just that iterated across the entire mesh. I have a quick estimation for volume as well, but I need to look it up in my scripts.
Offline , triangle, 433 Posts, Join Date Oct 2004, Location Vancouver  
   Reply With Quote

KDR_11k's Avatar
Old (#3)
That equation only works with triangles that have one 90° angle. You need to calculate the height on all other types of triangles.
No deity could fill any of our requirements if handicapped with existence. -Ambrose Bierce, The Devil's Dictionary
Offline , veteran polycounter, 4,550 Posts, Join Date Oct 2004, Location Peine, Niedersachsen, Germany, Europe, Sol 3, Milky Way  
   Reply With Quote

Whargoul's Avatar
Old (#4)
No, it works on ALL triagles. Read it carefully, I'm not multiplying the height x width, I'm doing a cross-product between two edge vectors, and the definition of the magnitude of a cross product is that it is the area of the parallelogram formed by the two vectors.



(from http://geometryalgorithms.com/Archive/algorithm_0101/


Now, on to the volume. There is no guaranteed way to calculate the volume of a polygon mesh, because you can't be sure it's closed & non-intersecting. So this little trick works best (most accurately) on a closed & non-self intersecting mesh. This comes from Duncan B. ("chief scientist" at Alias):

// The method uses the divergence theorem:
// int_{vol} Div(f) dV = int_{surf} Dot(f,n) dS
// To use it to compute volumes set f=(0,0,z), you then have
// Volume = int_{vol} 1 dV = int_{surf} n_z(u,v) du dv
// Where n_z is the "z" component of the normal to the surface at the parameter value (u,v).
// If you only have triangles then the formula reads:
// Volume = sum_{over all triangles} (z0+z1+z2)/3*n_z*A

Anyways, I don't completely get the whole thing about divergance theorem (it's been too long since uni calculus), but here's the nuts & bolts of the algorithm:

iterate through all the triangles summing up:
per triangle: sum+= (area of triangle) * (normal's z component) * (average of z components of the triangle)

It works quite well, surprisingly. If the mesh is closed & continuous, it's best. Otherwise (due to the missing faces) the volume varies if the mesh is positioned differently in the world.

pseudo mel-code: (if each triangle has vertices ABC)

<font class="small">Code:</font><hr /><pre>
float $volume;
for (each triangle)
{
float $area = 1/2 * cross (vector AB, vector AC);
vector $normal = face normal;
$volume+= $area * $normal.z * (A.z + B.z + C.z)/3
}
</pre><hr />



Now of you can find a Max scripter to write that up you'll be doing well. [img]/images/graemlins/smile.gif[/img]
Offline , triangle, 433 Posts, Join Date Oct 2004, Location Vancouver  
   Reply With Quote

Sectaurs's Avatar
Old (#5)
hot damn. thanks a lot! now to figure out how to utilize this info. [img]/images/graemlins/smile.gif[/img]
Roböt - The Company - 3D Prototypes and Prints

Lead Artist - Stomp Games
Offline , veteran polycounter, 3,855 Posts, Join Date Oct 2004, Location Maynard, MA Send a message via AIM to Sectaurs  
   Reply With Quote

Sectaurs's Avatar
Old (#6)
okay, i was just told about the Measure button under the Utilities roll out. tells you all that information and more. d'oh!
Roböt - The Company - 3D Prototypes and Prints

Lead Artist - Stomp Games
Offline , veteran polycounter, 3,855 Posts, Join Date Oct 2004, Location Maynard, MA Send a message via AIM to Sectaurs  
   Reply With Quote

poopinmymouth's Avatar
Old (#7)
[ QUOTE ]
No, it works on ALL triagles. Read it carefully,

[/ QUOTE ] 8-P

pwnt
Offline , veteran polycounter, 3,616 Posts, Join Date Oct 2004, Location Reykjavik, Iceland Send a message via ICQ to poopinmymouth Send a message via AIM to poopinmymouth Send a message via MSN to poopinmymouth Send a message via Yahoo to poopinmymouth Send a message via Skype™ to poopinmymouth  
   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Copyright 1998-2012 A. Risch