Explanation

Given a rotation as a quaternion, A, and a direction as a vector, B, calculate a rotation, C, that will rotate A to point in the direction of B. In the example above, C is calculated every tick and applied to the vive controller. In this example, B is oriented along positive-x and rotates around the y-axis over time. Observe that under certain opposite directions between A and B, C displays a sudden roll/twist. Why does this artifact occur? Why does it only occur once, not twice (the cross product between the two vectors transitions hemispheres twice is a full rotation)?


Source for this repository is on my GitHub, the rotation calculation code is here