pole vector solution?

342 views
Skip to first unread message

notanymike

unread,
Jul 21, 2011, 12:00:05 AM7/21/11
to python_inside_maya
How does the `ikHandle` command set up the initial pole vector? It
seems to take the vector between the start joint and it's position and
cast a vector orthogonal to it in the direction of the mid joint. I've
found code showing me how to calculate orthogonal vectors, but none
showing me how to do it when you only have one vector (the end joint -
the start joint). How do I get the other two axis and determine which
one to use for the pole vector?

Shawn Patapoff

unread,
Jul 25, 2011, 5:09:15 PM7/25/11
to python_inside_maya
This is something I'd like to know as well, I though it may have
something to do with the preferred angle, but no dice.

Jan Berger

unread,
Jul 25, 2011, 5:15:26 PM7/25/11
to python_in...@googlegroups.com

I think it calculates the angle based on the angle between the start to mid
and mid to end vectors

notanymike

unread,
Jul 25, 2011, 8:06:13 PM7/25/11
to python_inside_maya
Update: I found out how to get the pole vector....It's actually a
vector orthogonal to the vector of the effector to the start joint.
However that's the vector as it lies on the rotate plane. How can I
offset it to return a position that's normal for an "elbow control"
i.e somewhere in between the start joint and effector, whilst keeping
it parallel to the rotate plane/true pole vector?

Jakob Welner

unread,
Jul 31, 2011, 11:33:02 AM7/31/11
to python_in...@googlegroups.com
Here's a simple way of doing it.
It's basically getting the vector from wrist to elbow and from shoulder to elbow, adding them together to get another vector pointing away from the elbow but sticking to the rotation plane, normalize it so you're sure to have the same distance all the time, multiply with whichever distance you want from the elbow and there you go. To get the actual WorldSpace position of the polevector then, you simply add the elbow position.
Does that make sense?



import pymel.core.datatypes as dt

def __snapPolevector(wrist, elbow, shoulder, poleVec):

    distFromElbow = 5

    wristPos =     dt.Vector( mc.xform(wrist,     q=True, translation=True, worldSpace=True) )
    elbowPos =     dt.Vector( mc.xform(elbow,     q=True, translation=True, worldSpace=True) )
    shoulderPos =     dt.Vector( mc.xform(shoulder,     q=True, translation=True, worldSpace=True) )

    vWristElbow = elbowPos - wristPos
    vShoulderElbow = elbowPos - shoulderPos
   
    vDir = vWristElbow + vShoulderElbow
    vDir.normalize()
    vDir = vDir * distFromElbow
   
    poleVecMatch = elbowPos + vDir
   
    mc.xform(poleVec, translation = poleVecMatch, worldSpace=True)





JAKOB WELNER
    _____________
    Animator | R&D
    jakob.welner.dk

notanymike

unread,
Jul 31, 2011, 7:35:53 PM7/31/11
to python_inside_maya
Thanks Jakob, however I'm not trying to create a pole vector, I'm
trying to move one to follow the joints rotations using a custom
transform node. The problem I'm having with the node is that it can't
find the original pole vector's position based on it's parent matrix
and the joint chain. It does find the proper vector midway, but I
derived the math from ZooTools (http://zootoolbox.googlecode.com/svn/
branches/dave/zooVectors.mel) and I can't figure out how to get the
'distance' to match the distance the pole is from the elbow. For now
I've simply added a attribute to my node letting the animator specify
any distance they want, but the control will sill jump once
'enableSnapping' is set to true. How do I apply the pole vector's
position to zooFindPolePosition's distance argument to return the same
distance/position that the elbow control is to the elbow?

On Jul 31, 8:33 am, Jakob Welner <jakob.wel...@gmail.com> wrote:
> Here's a simple way of doing it.
> It's basically getting the vector from wrist to elbow and from shoulder to
> elbow, adding them together to get another vector pointing away from the
> elbow but sticking to the rotation plane, normalize it so you're sure to
> have the same distance all the time, multiply with whichever distance you
> want from the elbow and there you go. To get the actual WorldSpace position
> of the polevector then, you simply add the elbow position.
> Does that make sense?
>
> *import pymel.core.datatypes as dt
>
> def __snapPolevector(wrist, elbow, shoulder, poleVec):
>
>     distFromElbow = 5
>
>     wristPos =     dt.Vector( mc.xform(wrist,     q=True, translation=True,
> worldSpace=True) )
>     elbowPos =     dt.Vector( mc.xform(elbow,     q=True, translation=True,
> worldSpace=True) )
>     shoulderPos =     dt.Vector( mc.xform(shoulder,     q=True,
> translation=True, worldSpace=True) )
>
>     vWristElbow = elbowPos - wristPos
>     vShoulderElbow = elbowPos - shoulderPos
>
>     vDir = vWristElbow + vShoulderElbow
>     vDir.normalize()
>     vDir = vDir * distFromElbow
>
>     poleVecMatch = elbowPos + vDir
>
>     mc.xform(poleVec, translation = poleVecMatch, worldSpace=True)*
Reply all
Reply to author
Forward
0 new messages