title: Converting glm::lookat matrix to quaternion and back
body: <p>I am using glm to create a camera class, and I am running into some problems with a lookat function. I am using a quaternion to represent rotation, but I want to use glm's prewritten lookat function to avoid duplicating code. This is my lookat function right now: </p>
  
  <pre><code>void Camera::LookAt(float x, float y, float z) {
      glm::mat4 lookMat = glm::lookAt(position, glm::vec3(x, y, z), glm::vec3(0, 1, 0));
      rotation = glm::toQuat(lookMat);
  }
  </code></pre>
  
  <p>However when I call <code>LookAt(0.0f,0.0f,0.0f)</code>, my camera is not rotated to that point. When I call <code>glm::eulerangles(rotation)</code> after the lookat call, I get a vec3 with the following values: (180.0f, 0.0f, 180.0f). <code>position</code> is (0.0f,0.0f,-10.0f), so I should not have any rotation at all to look at 0,0,0. This is the function which builds the view matrix:</p>
  
  <pre><code>glm::mat4 Camera::GetView() {
      view = glm::toMat4(rotation) * glm::translate(glm::mat4(), position);
      return view;
  }
  </code></pre>
  
  <p>Why am I not getting the correct quaternion, and how can I fix my code?</p>