Angles and IK CCD Help

Posted By: EpsiloN

Angles and IK CCD Help - 07/10/15 20:31

Can anyone translate this into Lite-C?
Quote:
We create two vectors: one from the last joint position to the endpoint of the last bone (the effector) and another from the same last joint to the target we are trying to reach. Now we can compute the angle between these two vectors by computing the dot product of their unit vectors. Notice that we have the angle between two vectors, but we need to make sure we rotate in the appropriate direction to make the shortest path possible. Again, we can use our AI knowledge by performing a cross product between the two vectors to obtain a third, perpendicular vector. Then, we use the sign of the Z coordinate of the newly computed vector. This sign determines the direction at which we must rotate, and the arc-cosine of the dot product will give you the angle.


I can understand two vec_to_angle for finding bone direction and destination direction, and one ang_diff between the two angles, but nothing more grin

Can anyone clarify?

PS.: Any thoughts on how to get the length of a bone by script? Cant find any functions in the Manual...

Thanks.

*** EDIT ***
Or, how to get the bone pos?? Cant find a function for that either grin
Oops, found it: vec_for_bone() gives the hinge(joint) before that bone, I think. Could be used to get a bone starting pos...
Posted By: EpsiloN

Re: Angles and IK CCD Help - 07/11/15 12:29

No replys yet, but here's a thought (dont have time to test it right now)
Example:
Rotate an angle to point from elbow to target, rotate the first bone by that angle,
then for the bicep bone...

Get a dummy angle to point from shoulder to target, and get another to point from shoulder to wrist (those are two angles from two vectors) and then use ang_diff to get the difference and rotate the bicep bone with the difference.

Those two operations repeated over and over will turn an arm towards a point in space...
For more bones, the procedure for the bicep bone is repeated for every bone, turning an angle towards the target, an angle towards the last bone in the chain (effector, or eg. a finger) and turn that bone by the difference of those two angles and go to next bone or iteration.

Gonna test it tonight, if I have the time...
© 2024 lite-C Forums