Forum: Poser - OFFICIAL


Subject: Morph Cleanup Script

Cage opened this issue on Feb 24, 2010 · 592 posts


Cage posted Tue, 30 March 2010 at 3:28 PM

I end up with this, then:

def get_weights(dists):<br></br>
    """Calculate weights for
correlated vertices, by distance."""<br></br>
    dmax = max(dists)<br></br>
    if dmax <= FLT_EPSILON: # Float division
error protection.<br></br>
        return [1.0/len(dists)
for i in dists]<br></br>
    total = 0.0<br></br>
    result = [0.0 for i in dists]<br></br>
    for i in range(len(dists)):<br></br>
        result[i] = 1.0 /
dists[i]<br></br>
        total += result[i]<br></br>
    if total <= FLT_EPSILON: # Float division
error protection.<br></br>
        return [1.0/len(dists)
for i in dists]<br></br>
    for i in range(len(result)):<br></br>
        result[i] = result[i] /
total<br></br>
    return result

I think the second zero-division test is probably unnecessary, now that it no longer generates zero weights.

Is the difference in the result a matter of it being more correct, or just differently incorrect?  😕  :lol:  I mean, should I keep looking for a better solution, or is this what we need?

===========================sigline======================================================

Cage can be an opinionated jerk who posts without thinking.  He apologizes for this.  He's honestly not trying to be a turkeyhead.

Cage had some freebies, compatible with Poser 11 and below.  His Python scripts were saved at archive.org, along with the rest of the Morphography site, where they were hosted.