I'm working on rotating human limbs in a 3d game. I use Linear Algebra matrix rotations and translations to achieve moving the human and limbs. I currently can rotate around a pivot point by first translating to the pivot point then performing the rotation and finally translating back to the origin. I do that easily enough for the shoulder. However I cannot figure out how to also add in a rotation around the elbow for the forearm. The whole issue of the upper arm rotating thus moving the elbow point which I must then rotate around is throwing me off.
I've tried the following for the forearm rotation around the elbow:
1)translate to shoulder, rotate, translate to origin, translate to forearm, rotate, translate to origin 2)translate to shoulder, rotate, translate to forearm, rotate, translate to shoulder, translate to origin
Neither work for me. Any suggestions? I'm really stuck on this one.
I'll restate your problem to make sure I understand it correctly: You have a shoulder joint, an upper arm segment, an elbow joint and a forearm segment. If you turn the shoulder joint, everything else moves; if you turn the elbow joint, only the forearm segment moves. You want to rotate both joints at the same time and find out how the forearm segment moves. I presume that in your description of the approaches you've tried, by "translate to forearm" you mean "translate to elbow".
The problem with the two approaches you tried seems to be that in each case there's a translation to the elbow joint after the elbow joint has already been rotated by a rotation around the shoulder joint. You need to do the rotation around the elbow joint first, since the shoulder joint moves the elbow joint but not vice versa. Thus:
3) translate to elbow, rotate, translate to origin, translate to shoulder, rotate, translate to origin