Dimitry wrote:
> Ofer, Chad,
>
> but anyway it's interested how it's possible to get mesh middle point
> - centroid of each poly in a mesh
>
> it is possible to get it in the similar way as arrMesh.f[0].getNormal
> ()
> arrMesh.f[0].centroid() - something like this?
>
> all the best!
> Dimitry
> >
>
>   
In pymel.core.datatypes you have the "center" function (working on Points)

center(/p/, /*args/)¶
<http://icare/docs/ASPythonDoc/generated/functions/pymel.core.datatypes/pymel.core.datatypes.center.html#pymel.core.datatypes.center>
    center(p[, q, r, s (...)]) –> Point Returns the Point that is the
    center of p, q, r, s (...)

Also available as a method of the class Point

center(/*args/)¶
<http://icare/docs/ASPythonDoc/generated/classes/pymel.core.datatypes/pymel.core.datatypes.Point.html#pymel.core.datatypes.Point.center>


    p.center(q, r, s (...)) –> Point Returns the Point that is the
    center of p, q, r, s (...)

Didn't add a weighted / barycenter method but that could be done.

Something related that might be interesting to note, because it's not
provided by the Maya API or that easy to compute in a nice way and often
useful :

bWeights(/*args/)¶
<http://icare/docs/ASPythonDoc/generated/classes/pymel.core.datatypes/pymel.core.datatypes.Point.html#pymel.core.datatypes.Point.bWeights>
    p.bWeights(p0, p1, (...), pn) –> tuple Returns a tuple of (n0, n1,
    ...) normalized barycentric weights so that n0*p0 + n1*p1 + ... = p.
    This method works for n points defining a concave or convex n sided
    face, always returns positive normalized weights, and is continuous
    on the face limits (on the edges), but the n points must be
    coplanar, and p must be inside the face delimited by (p0, ..., pn)

Think of an inverse barycenter, for a point p0 in a face and the p1...pn
points of the face, will return normalized positive weights (not all
algorithms ensure that). Works for any number of points face, convex or
concave as long as it's planar (but the error you get for not being
perfectly planar builds up in a continuous way, so still usable for near
planar faces), and it's continuous at the limites (when point p0 is
actually on a edge).




-- 
Olivier Renouard


--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to