# problems making a rotating camera using vector math

Hi OF.
I’m trying to make a camera that could rotate around the center of the image on both the X and Y axes. I’m using the ofVec3f class to calculate the coordinates of the camera but i’m having a couple issues.

I made a camera class based on the ofCamera class found here http://www.openframeworks.cc/forum/view-…-t=ofcamera

so far the code looks like this:

``````

Cam::Cam(int _centroX, int _centroY, int _raio){
center = ofVec3f(_centroX, _centroY, 0);
raio = _raio;
position = ofVec3f(0,0,raio);
fieldOfView = 65.0f;
yon = 1000.0f;
hither = 0.5f;

int w, h;
w = glutGet(GLUT_WINDOW_WIDTH);
h = glutGet(GLUT_WINDOW_HEIGHT);
aspectRatio = (float)w/(float)h;

rotX = rotY = 0;
}

Cam::~Cam(){
}

void Cam::move(int mouseX, int mouseY){
rotX = (mouseY-center.y)/1000;
rotY = (mouseX-center.x)/1000;

position.rotate(rotX, ofVec3f(1, 0, 0));
position.rotate(rotY, ofVec3f(0, 1, 0));

cout << position.length() << endl;
camX = center.x + position.x;
camY = center.y + position.y;
camZ = center.z + position.z;
}

void Cam::putInPlace(){
glMatrixMode(GL_PROJECTION);
gluPerspective(fieldOfView, aspectRatio, hither, yon);
glMatrixMode(GL_MODELVIEW);