Did you check against 'non orientable surfaces'? like Möbius strip Klein Bottle I doubt the algorithm stands with that... As far as I remember those objects have no defined volume? As : how would you like to make a cylinder from a Möbius strip? You can always create a bounding object .. like in triangulating the circle .. alas .. it will be getting close enough, which might be sufficient for blender, and might be nice to have..
Well if blender refuses to create such geometry .. bad enough Mathematica and friends can. Well I think you should check the definition of 'closed' and require 'orientable' and it will work out fine. so much for that BM one more .. your algorithm assumes homogeneous density .. how realistic is that ? .. for all cases ? Is a balloon filled with air the same as the balloon filled with water? As the mass is on the surface versus the mass is in the volume ? Am 21.11.2012 04:30, schrieb Ummi Nom: > Hi! > > I've written some center of mass calculations in python for closed meshes, > but there is an issue with using tessfaces in my code; I run mesh.update > with tessfaces=True but when I loop over mesh.tessfaces there are only 6 > faces in default scene cube so the center of mass is offset. > > It seems to work when the mesh is triangulated > http://www.pasteall.org/37396/python > > # Code > import mathutils > from mathutils import * > import bpy > > tess_count = 0 > > # Handle tri as a tetrahedron with fourth point at origo > def handleTri(v1, v2, v3): > global tess_count > tess_count = tess_count + 1 > > temp = (v3-v1).cross(v2-v1) > nor = temp.normalized() > area = 0.5*temp.dot(nor) > vol = area*nor.dot(v1)/3.0 > centroid = (v1+v2+v3)/4.0 > > return (centroid, vol) > > > for me in bpy.data.meshes: > me.update(calc_tessface=True) > > sumc= Vector() > summ = 0 > > > for f in me.tessfaces: > v1 = Vector(me.vertices[f.vertices[0]].co) > v2 = Vector(me.vertices[f.vertices[1]].co) > v3 = Vector(me.vertices[f.vertices[2]].co) > > centroid, mass = handleTri(v1, v2, v3) > sumc += centroid * mass > summ += mass > > print(tess_count) > > print(sumc/summ) > _______________________________________________ > Bf-committers mailing list > Bf-committers@blender.org > http://lists.blender.org/mailman/listinfo/bf-committers > _______________________________________________ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers