title: rotate the camera around an object in spherical coordinates glulookat
body: <p>so i'm trying to rotate the camera around a cube object , using the keyboard arrows to change the y angle and the x angle , i want a result like this : <a href="https://drive.google.com/file/d/1rBbaXir_DuB9Kuj38A0sIU_MuNshtD0p/view?usp=sharing" rel="nofollow noreferrer">this video</a></p>
  <p>Well now I want to move the camera in a circular motion around the shape, so I used
  the sphere parametric equation to determine the camera's x, y, and z coordinates on the parameter of the sphere using the x angle and the y angle , this is the equation : <a href="https://i.stack.imgur.com/JrQoI.png" rel="nofollow noreferrer">sphere parametric equation</a></p>
  <p>For this moment, the equation is as following:</p>
  <p>x = radius*cos(y_angle)*cos(x_angle)</p>
  <p>y = radius*cos(y_angle)*sin(x_angle)</p>
  <p>z = radius*sin(y_angle)</p>
  <p>so the code will be :</p>
  <pre><code>gluLookAt(x, y, z, 0, 0, 0, 0, 1, 0); // x,y and z that we calculated above
  </code></pre>
  <p>Now it is supposed to work without problems, but the camera dose rotate in a strange way that is not as it should, I think this has something to do with the <strong>up vector</strong> in the
  glulookat() function because i'm using a constant up vector like
  (0,1,0)</p>
  <p>Anyway, I can't calculate the up vector correctly, so I want help in making a circular motion around the cube like the one that appeared in the video using the glulookat , i hope i made it clear ، Because as you have noticed, I can't explain well</p>