# Rotation to Direction

Hi! I know how to get Rotation from Direction - Quaternion.lookAt(Vector3f). But I’m in an opposite situation.
I have a quaternion and I want to a direction vector.

[java]quaternion.mult(vec);[/java]

will rotate a vector by that quaternion

1 Like

i think that quaternion.getRotationColumn(2) is what you are looking for.

1 Like

Its probably not. A quaternion is a relative rotation, converting it to a direction vector means that you have an initial direction, e.g. the z-axis unit vector. You can then rotate that as wezrule showed.

1 Like

@bubuche - yes it was that! Thank you. So 2nd column is the direction vector. What are two other columns?

@normen - yes, my spatial has an initial direction. It’s a character and I want to make a Ray object but to make one I need a direction vector, not rotation.

Edit: hmm do you suggest to make a Vector3f representing initial direction of spatial and then rotate it by Quaternion.mult() according to spatial rotation changes?

@ubuntuser said:

Edit: hmm do you suggest to make a Vector3f representing initial direction of spatial and then rotate it by Quaternion.mult() according to spatial rotation changes?

Yes

1 Like
@ubuntuser said: @bubuche - yes it was that! Thank you. So 2nd column is the direction vector. What are two other columns?

Direction vectors. The thing is, trying to get an axis from a Quaternion is the super-duper-long way to go to do the same thing as quat.mult(Vector3f.UNIT_Z)

I often wonder where this whole getRotationColumn() thing comes from because I see it used a lot and it’s generally a kind of silly way to do it. It’s more complicate than needs to be, does more work than needed, hides what is really going on, etc…

1 Like