[Bf-committers] Cursor to center of mass
tobias.oelgarte at googlemail.com
Thu Nov 22 03:26:46 CET 2012
Every algorithm has it's limitations. Computing the center of mass for a
body that has no volume is a quite useless task and assuming
inhomogeneous density for a body that is only defined by the surface is
also questionable. For the average case a closed surface and the
assumption of homogeneity is already sufficient enough. For anything
else you could play around with shrinkwrap or something else to create a
hull that approximates the volume.
Regarding the balloon. It doesn't matter in this case if the mass is
centred at the surface or inside the volume. The result for the center
of mass is still the same. It would only matter if you had a balloon
filled half with water and half air.
Am 22.11.2012 02:46, schrieb bjornmose at gmx.net:
> Did you check against 'non orientable surfaces'?
> 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
> 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:
>> 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
>> # 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:
>> sumc= Vector()
>> summ = 0
>> for f in me.tessfaces:
>> v1 = Vector(me.vertices[f.vertices].co)
>> v2 = Vector(me.vertices[f.vertices].co)
>> v3 = Vector(me.vertices[f.vertices].co)
>> centroid, mass = handleTri(v1, v2, v3)
>> sumc += centroid * mass
>> summ += mass
>> Bf-committers mailing list
>> Bf-committers at blender.org
> Bf-committers mailing list
> Bf-committers at blender.org
More information about the Bf-committers