# Thread: Camera rotation from vector

1. ## Camera rotation from vector

To start off, i am NOT talking about gluLookAt() to specify the camera rotation,
so dont suggest i use it. I'm using glRotatef to alter
camera rotation.

So far i'v been using angle xrot,yrot,zrot (in degrees)
to specify the camera rotation.
ei:
Code :
```glRotatef(xrot,1.0,0.0,0.0);
glRotatef(yrot,0.0,1.0,0.0);
glRotatef(zrot,0.0,0.0,1.0);```
My
problem, say i have a unit vector (0.3433, 0.4243, 0.242) and i want to find the
appropriate xrot,yrot,zrot to get the camera rotation according the given
vector?

I was thinking to solve, say the xrot, i could take do
->angleBetween( (0.3433,0,0), (1,0,0) ) would give the xrot, and so on for
the yrot,zrot.

2. So let me make sure I understand this correctly. You ditched gluLookAt for specifying your camera in favor of Euler angles. And now you want to use Euler angles to basically do the exact same thing that gluLookAt could do far easier.

Why are you making everything so difficult for yourself? Use the right tool for the right job. And Euler angles are almost never the right job for anything.

Basically, the best way to answer your question is to look at the implementation of gluLookAt and do what it does.

3. But bare with me here,

Given an up-vector of always (0,1,0) and a nonzero direction vector (x,y,z), how do i get the rotation angles for the camera to point in the direction of the given vector?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•