I have screen with dimensions: 800x600. The object that I want to rotate around is located at (400,300, -50) - center of the screen. Orthogonal projection: Near plan - 0.1f, far plane - 1000.0f left - 0, bottom - 0, right - 800, top - 600

Camera: position at (0,0,0) look at (0,0,-50) up vector (0,1,0)

Now what I'm doing to rotate is calculate the X of "look at" using: 0 + width * cos(A). Y remains the same (0). Z is calculated using: -50 + width * sin(A).

Now the problem that I'm facing is that after some angle the object starts to disappear, and it doesn't rotate around the object. What can be the problem?

  • 1
    \$\begingroup\$ According to your math, your camera will orbit around 0,0,-50 with a radius of width. But you are saying the object you wish to orbit is at 400,300,-50. Correct? \$\endgroup\$ May 17, 2013 at 22:06
  • \$\begingroup\$ yes, so in order to fix it, I need to change the look at values? Let's try it \$\endgroup\$ May 18, 2013 at 8:23

1 Answer 1


The image of a point A under a rotation around another point B (an affine rotation if B is not the origin of the space) is A', with

A' = B + R*(A-B)

where R is the matrix of the associated linear rotation.

For example, in dimension 2, say you want to rotate A = (1,0) around B = (1,1) by 90 degrees counter-clockwise. That will yield (2,1). Make a picture if needed. And, if we call R the matrix of the linear counter-clockwise rotation of angle 90 degrees, we have

R = (0 -1)
    (1  0)


(1,1) + R*( (1,0) - (1,1) ) = (1,1) + R*(0,-1)
                            = (1,1) + (1,0)
                            = (2,1)

Now, the solution to your problem actually depends on your implementation of world and camera geometry. You can either rotate your camera around point B or you can "rotate the world" around the camera by the inverse of the previous rotation (as usual in the "ProjectionMatrix * CameraMatrix * ModelMatrix * positionOfVertex" part of a vertex shader, if it's OpenGL or DirectX you're using).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .