0
$\begingroup$

I have a tedious problem with IK stretch, and haven't found any hint when googling it. In a 2 bones IK chain with stretch, how to find the exact stretch value for each bone so that they are scaled with the same factor?

Let's say we want to stretch these two bones, same length in rest position. The third one at the top is the target. Setting the stretch value to 0.5 for each gives a correct scale of x2 when moving up the target bone to multiply the chain length by 2 (picture 1 and 2, click on the pic to expand it and see the unit grid better)

But, when dividing the first bone length by two in edit mode, the stretch is no more proportional (picture 3). The first bone should reach the red line to double its length, whereas it's a little higher. It's still possible to manually lower and find by iterations the stretch value of this bone to get the right scale, but i'd like to find the exact formula to write it in a python script.

Blend File

Thanks for any help!

stretch bones

$\endgroup$
0
$\begingroup$

Finally found the answer from Rigify scripts:

    l1 = ulimb_p.length
    l2 = flimb_p.length
    if l1 < l2:
        ulimb_p.ik_stretch = (l1 ** (1 / 3)) / (l2 ** (1 / 3))
        flimb_p.ik_stretch = 1.0
    else:
        ulimb_p.ik_stretch = 1.0
        flimb_p.ik_stretch = (l2 ** (1 / 3)) / (l1 ** (1 / 3))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.