PDA

View Full Version : PolyArea ???


I-NetGraFX
08-24-2009, 05:31 AM
Hi there!

I'd like to get the size of a poly face, of any kind like triangles, quadrangles, etc.
I must have overlooked it big times ... or it's simply not there ...

I've found this in the docs, but it calculates the entire surface:

# Local and World Space Area
cmds.polyCube( w=1, h=1, d=1, sx=1, sy=1, sz=1, ax=(0, 0, 1), cuv=1, ch=1 )
cmds.setAttr( 'pCube1.scaleY', 2 )
cmds.polyEvaluate( a=True )
# Result: 6
cmds.polyEvaluate( wa=True )
# Result: 10

I've found various weird methods on the net, where some tried to triangulate it and calculate it after somehow like this, by summing up the resulting area from each triangle:

area = 0.25 * math.sqrt((a+b+c) * (b+c-a) * (c+a-b) * (a+b-c))

any pointers on how to get this without strange workarounds, where I'm forced to manipulate my object?
Your help is very much appreciated, thanks in advance!

Robert Bateman
08-24-2009, 07:03 AM
if you're using python, use the MItMeshPolygon class (from the API) which has the method you are looking for. You can compute the area of a triangle from the cross product, which is what your latter method does - only works for triangles though, hence the need to traingulate (which you can do simply and will probably work most of the time - might fail for strange polys though - eg a starfish shape).

I-NetGraFX
08-24-2009, 11:01 PM
Hello Robert Bateman!

Thanks a lot for you reply. I finally went with the spooky version of getting the total area before I would delete the selection, and then taking the difference with the total poly area after. It does that fairly quick, but feels strange with the undo command in between, to avoid having my model completely scrapped ...

CGTalk Moderation
08-24-2009, 11:01 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.