Although the automatic answer is accurate, there are some key points to consider about rotations:
When only two vectors, a
and b
, are provided, there are countless rotations that can transform a
into b
. The aforementioned solution selects the shortest rotation method but necessitates determining the rotational axis using a cross product. Another approach involves using the bisector as the axis of rotation and rotating by Pi
. In this scenario, normalizing to a_n
and b_n
and rotating around (a_n + b_n)
could be an alternative.
The variations in rotations typically impact objects that lack rotational symmetry.
If all vectors are already normalized, the process should be straightforward:
var a = new THREE.Vector3( 0, 0, 1 );
var b = new THREE.Vector3( 1, 0, 0 );
var c = new THREE.Vector3( x, y, z );
var quaternion = new THREE.Quaternion();
quaternion.setFromAxisAngle( a + b, Math.PI );
c.applyQuaternion( quaternion );
If c==a
, then c
has been rotated onto b
; conversely, if c==b
, it means c
has been rotated onto a
.