0

I have a vector which points from my camera to an object I want to point to, so I want to make a quaternion which rotates the camera so that it points to that vector. So i do this (using glm)

glm::quat rotation=glm::angleAxis(0.0f,vector);

If i understand that function correctly in the case of a vector of, for example, (0.0f,0.0f,-1.0f), the camera should point forward in the depth axis, and with no roll. But i don't know why, in that case it creates this quaternion: x:-0 y:-0 z:-0 w:1 wich does nothing, and the x,y,z values only differ from 0 if the angle parameter passed to angleAxis() is different from 0. Why does this happen? if i pass angle 0, shouldn't it simply create a rotation with only yaw and pitch, and no roll?

1 Answer 1

1

Already go the answer: (on the gameDev forum, from the user clb)

No, your understanding is off. Angle-axis rotation generates rotation about the given axis, by the given angle. If you don't specify an angle, you'll always get identity back. This is because rotation a zero angle, be it about any axis, of course does not rotate at all.

What you are thinking about is the LookAt rotation. I am not sure what the function signature in glm is, but I'm sure they have a similar function. Use a LookAt rotation to orient one direction vector to face towards another vector.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.