title: OpenGL: Camera not moving as expected when using lookAt function
body: <p><a href="https://i.imgur.com/15z4zCp.mp4" rel="nofollow noreferrer">GIF of issue</a></p>
  <p>I'm currently trying to fly around the perimeter of a maze I have created. Here is the code for my <code>idle</code> function, where I am calling the <code>lookAt</code> function:</p>
  <pre class="lang-c prettyprint-override"><code>void idle()
  {
      GLfloat angle_radian = D2R*angle;
  
      float eye_x = 10 * -1*cos(angle_radian);
      float eye_z = 10 * sin(angle_radian);
  
      vec4 eye = {eye_x, 12, eye_z, 0};
      vec4 at = {5, 0, 5, 0};
      vec4 up = {0, 1, 0, 0};
  
      model_view = look_at(eye, at, up);
  
      angle += 0.5;
  
      glutPostRedisplay();
  }
  </code></pre>
  <p>The camera correctly circles around the maze however, the camera also seems to change the angle at which it is looking down during the rotation. This is confusing me since the Y coordinate of where I am looking does not change (The maze is constructed on the y=0 plane). I'm fairly certain my implementation of the <code>lookAt</code> function is correct, but here is the code for that in case I have overlooked something:</p>
  <pre class="lang-c prettyprint-override"><code>mat4 look_at(vec4 eye, vec4 at, vec4 up)
  {
    vec4 vpn = vec4_sub(eye, at);
    vec4 n = vec4_norm(vpn);
    vec4 u = vec4_norm(vec4_cross(up, n));
    vec4 v = vec4_norm(vec4_cross(n, u));
    vec4 p = { eye.x, eye.y, eye.z, 1 };
  
    mat4 m;
    m.x.x = u.x; m.y.x = u.y; m.z.x = u.z; m.w.x = u.w;
    m.x.y = v.x; m.y.y = v.y; m.z.y = v.z; m.w.y = v.w;
    m.x.z = n.x; m.y.z = n.y; m.z.z = n.z; m.w.z = n.w;
    m.x.w = p.x; m.y.w = p.y; m.z.w = p.z; m.w.w = p.w;
  
    mat4 m_t = mat4_trans(m);
    mat4 m_t_inv= mat4_inv(m_t);
  
    return m_t_inv;
  }
  </code></pre>