In my old rig, the lower limbs rotate in single plane only. That simplifies the story. Just put a locator under the FK lower limb, having the same world position as the pvCtrl at initial pose. Snapping to FK means snapping the pvCtrl to this locator because the rotate plane is always correct.

But I want rig like Stewart, where the lower limbs can rotate sideway. This involves simple vector maths.

global proc vector calcPvWPos( string $P1, string $P2, string $P3 ) {
 
     vector $a = `xform -q -ws -t $P1`;
     vector $b = `xform -q -ws -t $P2`;
     vector $c = `xform -q -ws -t $P3`;
 
     vector $AC = $c - $a;
     vector $AB = $b - $a;
 
     // projV = (|b|cos@) ^AC = (a.b/|a|) ^AC
     vector $projV = ( dotProduct($AC,$AB,0) / mag($AC) ) * `unit $AC`;
 
     vector $pvDirV = unit($AB - $projV);
 
     // move it out a bit
     return ( $b + mag($AB) * $pvDirV );
}
share it
Tweet about this on TwitterShare on FacebookShare on Google+Share on LinkedIn