# From Vector3f to Quaternion

Hello!

I'm trying to get some of my code cleaner… It's now time to face Quaternions

This is what i'm attempting to do:

1. I have a normalized vector, say 0.5f, 0, 0.5f which identifies the direction a Node is facing;
2. I'd love to have a quaternion out of it;

My attempts are not that good (I mean, it's just plain wrong). So, something tells me there's an easy solution to this problem

I think you need at least one more Vector.

A single vector can indicate a direction but, if you imagine, your node can roll without changing that vector - therefore the vector alone cannot define a quaternion. If you have two vectors, then you can calculate the third (product) from them and use the .fromAxes method to get a quaternion.

You should bear the following points in mind when considering the above paragraph.

• I am unnecessarily verbose at the best of times.
• I am really tired.
• I am quite drunk.
• I am not very good at math.

Quaternion has a lookAt method, but you need to specify an up vector.

Momoko_Fan said:

Quaternion has a lookAt method, but you need to specify an up vector.

Ah nice! Exactly what I needed. Thanks ^_^

Alric said:

bear the following points in mind

Hmm, in my case, I'd also add:
`It computes the rotation to transform the z-axis to point into 'direction'`