# psychopy.tools.mathtools.articulate¶

psychopy.tools.mathtools.articulate(boneVecs, boneOris, dtype=None)[source]

Articulate an armature.

This function is used for forward kinematics and posing by specifying a list of ‘bones’. A bone has a length and orientation, where sequential bones are linked end-to-end. Returns the transformed origins of the bones in scene coordinates and their orientations.

There are many applications for forward kinematics such as posing armatures and stimuli for display (eg. mocap data). Another application is for getting the location of the end effector of coordinate measuring hardware, where encoders measure the joint angles and the length of linking members are known. This can be used for computing pose from “Sword of Damocles”1 like hardware or some other haptic input devices which the participant wears (eg. a glove that measures joint angles in the hand). The computed pose of the joints can be used to interact with virtual stimuli.

Parameters
• boneVecs (array_like) – Bone lengths [x, y, z] as an Nx3 array.

• boneOris (array_like) – Orientation of the bones as quaternions in form [x, y, z, w], relative to the previous bone.

• dtype (dtype or str, optional) – Data type for computations can either be ‘float32’ or ‘float64’. If out is specified, the data type of out is used and this argument is ignored. If out is not provided, ‘float64’ is used by default.

Returns

Array of bone origins and orientations. The first origin is root position which is always at [0, 0, 0]. Use transform() to reposition the armature, or create a transformation matrix and use applyMatrix to translate and rotate the whole armature into position.

Return type

tuple

References

1

Sutherland, I. E. (1968). “A head-mounted three dimensional display”. Proceedings of AFIPS 68, pp. 757-764

Examples

Compute the orientations and origins of segments of an arm:

# bone lengths
boneLengths = [[0., 1., 0.], [0., 1., 0.], [0., 1., 0.]]

# create quaternions for joints
shoulder = mt.quatFromAxisAngle('-y', 45.0)
elbow = mt.quatFromAxisAngle('+z', 45.0)
wrist = mt.quatFromAxisAngle('+z', 45.0)

# articulate the parts of the arm
boxPos, boxOri = mt.articulate(pos, [shoulder, elbow, wrist])

# assign positions and orientations to 3D objects
shoulderModel.thePose.posOri = (boxPos[0, :], boxOri[0, :])
elbowModel.thePose.posOri = (boxPos[1, :], boxOri[1, :])
wristModel.thePose.posOri = (boxPos[2, :], boxOri[2, :])