 # camera rotation

How can I do the following:

Z = roll by a small angle around camera viewing axis (z roll in the opposite direction) = roll around the n axis in the uvn coord system

Y = yaw by a small angle around the camera y axis. i.e., the V axis in the uvn coord system. (y ywa in the opposite direction)

I want to do these rotations using my existing camera code…

``````extern Object *objs[];
extern int obj_count;

Camera::Camera()
{
eye = Vector3(0.0, 1.75, 15.0);
lookat = Vector3(0.0, 0.0, 0.0);
viewangle = 0.0;
}

void
Camera::orientMe()
{
lookat.c = sin(viewangle);
lookat.c = -cos(viewangle);
gluLookAt(eye.c, eye.c, eye.c,
eye.c + lookat.c,
eye.c + lookat.c,
eye.c + lookat.c,
0.0, 1.0, 0.0);
}

void
Camera::moveMe(int dir)
{
double x = eye.c;
double z = eye.c;
eye.c = eye.c + dir*(lookat.c)*0.05;
eye.c = eye.c + dir*(lookat.c)*0.05;

for (int i=0; i<obj_count; i++)
{
if (objs[i]->inside(eye))
{
eye.c = x;
eye.c = z;
break;
}
}

gluLookAt(eye.c, eye.c, eye.c,
eye.c + lookat.c,
eye.c + lookat.c,
eye.c + lookat.c,
0.0, 1.0, 0.0);
}

void
Camera::step(int dir)
{
double ex = eye.c;
double ez = eye.c;
double lx = lookat.c;
double lz = lookat.c;

if (eye.c < lookat.c)
dir = -dir;

if (lookat.c < 0)
eye.c = eye.c - dir*0.1;
else if (lookat.c > 0)
eye.c = eye.c + dir*0.1;

eye.c = eye.c + dir*0.1;

lookat.c = lookat.c + dir*0.1;
lookat.c = lookat.c + dir*0.1;

for (int i=0; i<obj_count; i++)
{
if (objs[i]->inside(eye))
{
eye.c = ex;
eye.c = ez;
lookat.c = lx;
lookat.c = lz;
break;
}
}

gluLookAt(eye.c, eye.c, eye.c,
eye.c + lookat.c,
eye.c + lookat.c,
eye.c + lookat.c,
0.0, 1.0, 0.0);

}

void
Camera::pitch(double dir)
{
lookat.c += dir*0.075;
}
``````