Vector Direction to Quaternion...

I know what I am asking is not 100% sane because Quaternions are simply rotations and don’t have a fixed axis, but let’s assume I have a vector direction which is part of the standard OpenGL coordinate system, and I want to create a Quaternion rotation from identity to orientate something…

Do I simply do the usual pitch, yaw calculations on that vector and then do rotations around the Up and Right axis to make the Quaternion? For some reason, and perhaps it’s too late and / or I need coffee but I am not getting predictable results this way.

Or is there a more elegant way?

I have googled and googled and basically it seems you either have to do a rather long winded vector to matrix to Quat calculation, or go back to Euler angles. Both seem inelegant.

I am by no means a Quaternion expert and have a situation where I am only going to get a vector and I need a Quaternion to plug into a models orientation and am having problems getting it to work…

Any help appreciated.

OK. I solved this. I actually aped the Quaternion makeRotate routine from OSG.

By fixing the “from” vector to straight ahead and simplifying the maths in the function accordingly I now have a fairly efficient routine that takes a direction vector and makes my Quaternion.