highfidelity/hifi — pull request #3150 by AndrewMeadows (2014-07-10 00:04:59+00:00)
Title: rename: ParentFrame --> ConstrainedFrame

While I was helping Sam get the LeapMotion working I realized that I had misnamed the "ParentFrame" rotations when I had overhauled JointState. This could cause confusion when future developers try to make sense of the code, so I decided it was worthwhile to change the names to be more correct.

For each joint in a Model we store a rotation that is invarient when upper joint's rotate. The frame of this rotation is NOT quite relative to the parent frame -- instead it is the frame in which the constraints would be applied. The formula for the final model-frame rotation of a joint looks like this:

R = Rp * Rpre * r * Rpost

where

R = final rotation of joint in model-frame
Rp = final rotation of parent in model-frame
Rpre = pre-rotation
r = rotation of joint in frame where constraints are applied
Rpost = post-rotation

The formula for the joint's rotation in its parent frame is as follows:

rotationInParentFrame = Rpre * r * Rpost

Rpre and Rpost are set to values that transfer parent-relative rotations into the frame where the joint's angular constraints (if any) would be applied, and back again. For all of the models I've looked at Rpost is always the identity but Rpre is often non-trivial. This sorta makes sense because the frame where the constraints are defined does not necessarily match that of the parent joint. On a real hand each finger splays a bit relative to the others, so it is impossible for all fingers to align with whatever frame is chosen for the palm -- hence the typical condition is that each finger joint will usually have a non-trivial rotation between its natural frame and that of its parent.