Notifications
Clear all

[Closed] Move IK mid point onto plane?

Like everyone else I’m building a script that creates a bone rig from a series of markers – however once I apply the IK to the legs the knees bow outwards. This is because the knee marker position doesn’t lie directly on the plane between the thigh and ankle joints.

What’s the best way to adjust the knee marker so that it meets this plane?

3 Replies

Sorted it based on a maths function in a sticky:

fn pointPlaneProj pA pB pC pD = (
local nABC=normalize (cross (pB-pA) (pC-pA))
pD+((dot (pA-pD) nABC)*nABC)
)

I know two points on the plane, so the third point is easy to assume:

– find a correct knee for IK
pointA = $‘Marker L Thigh’.pos
pointB = $‘Marker L Foot’.pos
pointC = $‘Marker L Foot’.pos + [0,1,0]

My knee position is the one I want to move:

pointD = $‘Marker L Calf’.pos

newpos = pointPlaneProj pointA pointB pointC pointD
$‘Marker L Calf’.pos = newpos

 PEN

Mine is a little more long winded as I did this years ago. I could do it far cleaner now.

fn projectSwivelAngle A B C multi:2=
	(
		A=if (isKindOf A node) then A.pos else A
		B=if (isKindOf B node) then B.pos else B
		C=if (isKindOf C node) then C.pos else C

		aa=distance B C
		bb=distance A C
		cc=distance A B
		
		multiMid=cc/(cc+aa)
		bbMidPos=A+((normalize (C-A)*(bb*multiMid)))
		L=length (B-bbMidPos)
		dir=normalize (B-bbMidPos)
		bbMidPos+=dir*L+(dir*multi)
	)

A, B and C are the hip, knee and ankle positions or objects. Then I find the mid point between A and C and project that through B with a multipleier to set it out from the knee as far as you need. It returns a position value.

Ah, that’s a very elegant solution! Thanks Paul