So, I have code to create a quaternion from a matrix (using the 3x3 rotational part.)
And I have code to construct a transformation matrix from a lookat + up vector pair.
To go from lookat+up to quaternion, I can thus go via the matrix intermediary:
vec3 lookat; vec3 up; ... mat44 trf = mat44::create_basis( lookup, up ); quat ori = quat::from_matrix( trf );
So far, so good.
But can I do this without the matrix intermediary? Because it seems to inefficient. For starters, both the lookat+up and the quaternion are a lot more concise than the intermediate matrix. It goes from compact to large, to the most compact.
How can I create a quaternion using just a look-at vector and an up-vector, both of which are guaranteed to be unit length and perpendicular to each other.