# Converting 2 vectors to quaternions

This topic is 4884 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Okay, basically I'm trying to do screen-aligned billboards using quaternions, but I've got stuck at a paticular maths problem. I've decided that if I get the Up and Forward vectors from the view matrix, I can then convert the Up into the axis for the quaternion, and I want to use the negative Forward vector to calculate the W. I have a very thin grasp on maths at best, and less than that when it comes to quaternions (Although I believe this is more akin to an axis-angle rotation; I'm still not too sure if that's synonymous with a quaternion). Just for reference, the indendity used for this quaternion is the same as my matricies, the axis pointing vertically and W pointing down the positive Z axis. Hope this makes sense, feel free to correct any assumptions I've made on the terminology and concepts.

##### Share on other sites
Quote:
 I have a very thin grasp on maths at best, and less than that when it comes to quaternions (Although I believe this is more akin to an axis-angle rotation; I'm still not too sure if that's synonymous with a quaternion).
It's synonymous-ish. When used to represent rotations, quaternions encode an axis-angle rotation in the form [cos(t/2), sin(t/2)*axis]. Furthermore, it can be shown that the operation q*p*conjugate(q), where p is a vector encoded as a quaternion, is equivalent to an axis-angle rotation. Both an axis-angle pair and a quaternion can be converted to a rotation matrix, and the matrix will be the same in either case.
Quote:
 Just for reference, the indendity used for this quaternion is the same as my matricies, the axis pointing vertically and W pointing down the positive Z axis.
The w component doesn't really 'point' anywhere. Also, when there is no rotation there really isn't an axis of rotation.
Quote:
 I've decided that if I get the Up and Forward vectors from the view matrix, I can then convert the Up into the axis for the quaternion, and I want to use the negative Forward vector to calculate the W.
I may be wrong, but I don't think this will work. You can extract a quaternion from these two vectors, but not the way you describe. Instead, you would need to find the third basis vector from the two that you have, and then extract the quaternion from the resulting 3x3 matrix.

That said, the usual question: what do you need the quaternion for anyway? There are certainly reasons that having the orientation in quaternion form might be handy, but otherwise you might be better off just sticking with matrices.

##### Share on other sites
Unless I missed something, there is no need for using quaternions here. If you have the orientation matrix for the camera, you have the orientation matrix for the billboards. The only difference is that the billboards face the other direction.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633709
• Total Posts
3013481
×