set_identity_matrix(); set_material("redPlasticMaterial"); for (i=0; i<NUMDOFS; i++) { record_transformed_joint(i); glRotatef(angle[i],axis[i][0],axis[i][1],axis[i][2]); append_rotation(angle[i],axis[i][0],axis[i][1],axis[i][2]); if (linkLen[i] != 0.0) { append_translation(0.0,linkLen[i],0.0); draw_linkage(linkLen[i]); glTranslatef(0.0,linkLen[i],0.0); } } record_endEffector(); glPopMatrix();
The append routines (rotation and translation) form the corresponding matrix and post multiplies the transformation matrix.
The routine that records the transformed joint gets the position and axis of rotation in global coordinates. It extracts the position from the 4th column of the transformation matrix and computes the axis of rotation by multiplying the rotation axis by the transformation matrix.
Extra Credit: