Hi folks. I'm developing a limb simulator using Inverse Kinematics and I've been wrestling with a problem with quite some time now!
I'm following Hugo Elias' implementation/tutorial, which you can find
HERE
Now the problem I've got is with this :
a. Vector along the axis of the joint.
b. Vector along the bone.
r. Vector at Right angles to a and b.
f. Force vector, from End Point to Target.
What I do at the moment is :
//i.e get position of bone joints
Vector3 a = bone1->getWorldPosition(); //current bone
Vector3 b = bone2->getWorldPosition(); //next bone
Vector3 c = bone0->getWorldPosition(); //previous bone
//Get vectors along bones
Vector3 vectAlongBone1 = (a - b);
Vector3 vectAlongBone2 = (a - c);
//Use Cross Product to get vector along axis Joint
Vector3 A = vectAlongBone1.crossProduct(vectAlongBone2);
A.normalise();
Should this work for a hinge joint? I'm getting some strange results. At certain rotations, the last joint in the limb's 'Vector along the Axis of the Joint' (Vector A) will flip over, so that this (top down view):
0
0
0
A ------0
Becomes this :
0
0
0
0------ A
Or in numerical form :
This : 1,0,0
Becomes This : -1,0,0
I've tried restricting the axis, but that breaks when a joint on another axis does any rotation...
So, is there a flaw in my resoning here?
I would be very grateful for any help!
SFA.