Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Stefano Moretto on December 19, 2007 at 2:16 am

    I know this is not a new topic which has been already discussed in other threads but…
    i’m having quite a hard time in setting up inverse kinematics in my project. I’m trying to use Dan Ebberts’ IK expressions to animate a leg which is supposed to cycle (yes, as if it’s running on a bicycle).
    I’ve started from the picture of a right leg, which has been “cut” into three different layers (thigh, calf, feet).
    I’ve imported them, moved the anchor points, created the null, moved it to the same position as the feet, parented as explained and copied-and-pasted the code.
    I guess I’m following his instruction step by step but I always end up with non aligned thigh and calf, so they don’t even react correctly to the movement of the feet.
    my question is… Does anybody have any tips? or maybe the project files for me to download so that i can figure out where i’m going wrong?
    I’ve already looked everywhere in the web to find something to help me, with no luck.
    please, help!
    …excuse any mistakes 🙂
    Thank you!

    Dan Ebberts replied 17 years, 5 months ago 3 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    December 19, 2007 at 4:41 am

    If you’re using a null, I’m guessing you’re using the older version of the expressions from here, is that correct?

    https://www.motionscript.com/expressions-lab-ae65/ik.html

    If so, you might want to try the updated version here:

    https://www.motionscript.com/design-guide/ik.html

    Dan

  • Stefano Moretto

    December 20, 2007 at 9:50 am

    Dan, you’re right, I was using the older version.
    However I’ve just finished setting up the updated one, and it seems to work great!
    BTW, now I’m using a single leg image, which has been duplicated three times and then masked to show only the thigh for the first layer, the calf for the second and so on, so that i can move the masks around to cover and correct any gaps or overlaying between the limbs while the effector makes them move. NICE!
    you were really helpful!
    Thank you very much!!! 🙂

  • Jarod Gibson

    January 5, 2009 at 9:52 pm

    Hi Dan,

    This doesn’t seem to work in cs4.
    Also, on your website when outlining your technique, you don’t say what to do about parenting the effectors…

    Any suggestions?
    Thanks a lot!

  • Dan Ebberts

    January 6, 2009 at 6:48 am

    Hi Jarod,

    In what way does it not work in CS4? Are you getting an error message? As far as I can tell it works fine.

    The effectors don’t have parents, unless you want to try making the hand effectors children of the torso so that the hands maintain their relation to the torso.

    Dan

  • Jarod Gibson

    January 8, 2009 at 3:21 pm
    cw = false;
    upper = false;
    upperLimb = "L upper leg";
    lowerLimb = "L lower leg";
    extremity = "L foot";
    effector = "L foot control";
    
    function getWorldPos(theLayerName){
      L = thisComp.layer(theLayerName);
      return L.toWorld(L.anchorPoint);
    }
    
    A = getWorldPos(upperLimb);
    B = getWorldPos(lowerLimb);
    C = getWorldPos(extremity);
    E = getWorldPos(effector);
    
    a = length(B,C);
    b = length(E,A);
    c = length(A,B);
    
    x = (b*b + c*c - a*a )/(2*b);
    alpha = Math.acos(clamp(x/c,-1,1));
    if{
      y = b - x;
      gamma = Math.acos(clamp(y/a,-1,1));
      result = (cw ? 1 : -1)*radiansToDegrees(gamma + alpha);
      V1 = B - A;
      adj1 = radiansToDegrees(Math.atan2(V1[1],V1[0]));
      V2 = C - B;
      adj2 = radiansToDegrees(Math.atan2(V2[1],V2[0]));
      result +  adj1 - adj2 + value;
    }
    
    

    Okay. I understand now about the effectors.

    That’s the expression I am trying to use on a lower limb.
    I do get an error that is referring to line 24 and layer 18.

    Thanks!

  • Dan Ebberts

    January 8, 2009 at 3:30 pm

    It looks like you tried to take out the code that gets used if it’s an upper limb, but you didn’t do it completely. Instead of this:

    if{
    y = b – x;
    gamma = Math.acos(clamp(y/a,-1,1));
    result = (cw ? 1 : -1)*radiansToDegrees(gamma + alpha);
    V1 = B – A;
    adj1 = radiansToDegrees(Math.atan2(V1[1],V1[0]));
    V2 = C – B;
    adj2 = radiansToDegrees(Math.atan2(V2[1],V2[0]));
    result + adj1 – adj2 + value;
    }

    You would just want to use this:

    y = b – x;
    gamma = Math.acos(clamp(y/a,-1,1));
    result = (cw ? 1 : -1)*radiansToDegrees(gamma + alpha);
    V1 = B – A;
    adj1 = radiansToDegrees(Math.atan2(V1[1],V1[0]));
    V2 = C – B;
    adj2 = radiansToDegrees(Math.atan2(V2[1],V2[0]));
    result + adj1 – adj2 + value;

    Although I would recommend just using it the way it is on my web site.

    Dan

  • Jarod Gibson

    January 8, 2009 at 4:31 pm

    I see.

    It works now. I was cutting out that part of the code thinking that your layman’s terms explainations of the expression were directions.

    err.

    Thanks a lot Dan.

  • Jarod Gibson

    January 8, 2009 at 4:43 pm

    so the three leg pieces I have are now joined together and move together when the effector is moved but the movement is focused around the knee joint rather than the foot (ankle) joint. Example. When I move the upper leg down (like a squat), the foot leaves the ground moving up as the knee bends. I want the foot to stay still on the ground.

    Can this be done?

    Thanks again!

  • Dan Ebberts

    January 8, 2009 at 4:50 pm

    I can’t figure out exactly what you’re doing, but you shouldn’t be moving the upper leg. Just the torso and/or the effector. If you move the torso, the feet should stay put, with the hip, knee and ankle flexing to accomodate the move.

    Dan

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy