The bones are rotated with quaternions.

The angle between the two PC1 vectors is taken. The object is then rotated (by a quaternion) around the cross product between the PC1 vectors.

The new angles between the next PCs are calculates and the process is repeated for the other PCs

quaternion_rotation_from_angle[source]

quaternion_rotation_from_angle(v, c_axis, theta)

rotates vector around axis by theta

quaternion_rotation_from_quaternion[source]

quaternion_rotation_from_quaternion(v, q)

rotates vector by quaternion

Voxel Interpolation

What's the issue

When you rotate the bone the out puts are decimals which cant be put back into the voxel array by upscaling the voxel more of the coordinates are integers and so reduces the resolution loss when converting back into an array.

rotate[source]

rotate(bone_f1, bone_f2, interpolate=False, scale_factor=2)