<p>Promoting my comment into an answer since it identified the problem...</p>

<p>The issue is confusion between degrees and radians for the angle parameter. GLM, up to version 0.9.5, was very inconsistent in how it dealt with angles, accepting degrees for some functions and radians for others. This behaviour could be overridden with <code>#define GLM_FORCE_RADIANS</code> before including the header.</p>

<p>In version 0.9.6, radians everywhere became the default. Unfortunately, if you Google 'glm rotate' at the time of writing, the top result is the 0.9.4 doc page, which still describes the parameters as taking degrees, so you need to be aware of which version you are using and its default behaviour in this regard. If you still want to use degrees for your angle variables, you can convert them with <code>glm::radians(angle)</code> before passing them as arguments.</p>

CC BY-SA 3.0
2018-03-16T15:00:30.807Z
2018-03-16T15:00:30.807Z
russ
<p>So I am doing a simple FPS camera with openGL. I store the camera as 4 vector, a position vector, a lookAt vector, an up vector and a right vector. When the user presses a key, I create a rotation matrix that rotates around the up vector 10 degree then multiply the three vectors that specify the orientation of the camera with it. With these new values I create a new view matrix from glm::lookAt. However, the result I get is very weird. When I press the button to rotate, the object the camera is initially pointing at dissapears, no matter how small I set the rotation. After pressing the rotate button several more time, it appears again, then if i press more it dissappears once more.<br>
I feel like the code is not wrong, but my understanding of the math behind it and therefore the implementation is wrong. Can anyone explain to me this weird behavior? 
Below is my code.</p>

<pre><code>look = glm::vec3(glm::rotate(theta, axis) * glm::vec4(look, 1.0f)); // theta set at 2 degree
right = glm::vec3(glm::rotate(theta, axis) * glm::vec4(right, 1.0f));
up = glm::vec3(glm::rotate(theta, axis) * glm::vec4(up, 1.0f));
glm::mat4 cameraMat = glm::lookAt(eyePos, eyePos+camera.look, camera.up);
</code></pre>

CC BY-SA 3.0
2018-03-16T04:57:39.493Z
Are you sure you're specifiying your angle in degrees? Modern versions of GLM use radians everywhere and the docs are not always clear on this.
russ
CC BY-SA 3.0
2018-03-16T05:08:38.003Z
@russ so GLM uses radians? I thought it uses degree. I will test with radians and update the result if it indeed fixes the problem
Manh Nguyen Huu
CC BY-SA 3.0
2018-03-16T05:30:20.623Z
Depends on version. Older versions were inconsistent, you could define GLM_FORCE_RADIANS before including it to make it use radians everywhere. Since version 0.9.6 this has become the default. From the doc - "Finally, here is a list of all the functions that could use degrees in GLM 0.9.5.4 that requires radians in GLM 0.9.6: rotate (matrices and quaternions), perspective, perspectiveFov, infinitePerspective, tweakedInfinitePerspective, roll, pitch, yaw, angle, angleAxis, polar, euclidean, rotateNormalizedAxis, rotateX, rotateY, rotateZ and orientedAngle."
russ
<opengl><3d><camera-matrix><camera>
How to rotate a camera?
Manh Nguyen Huu
# How to rotate a camera?

(Asked by: username_0 on 2018-03-16)

So I am doing a simple FPS camera with openGL. I store the camera as 4 vector, a position vector, a lookAt vector, an up vector and a right vector. When the user presses a key, I create a rotation matrix that rotates around the up vector 10 degree then multiply the three vectors that specify the orientation of the camera with it. With these new values I create a new view matrix from glm::lookAt. However, the result I get is very weird. When I press the button to rotate, the object the camera is initially pointing at dissapears, no matter how small I set the rotation. After pressing the rotate button several more time, it appears again, then if i press more it dissappears once more.  
I feel like the code is not wrong, but my understanding of the math behind it and therefore the implementation is wrong. Can anyone explain to me this weird behavior?
Below is my code.

```
look = glm::vec3(glm::rotate(theta, axis) * glm::vec4(look, 1.0f)); // theta set at 2 degree
right = glm::vec3(glm::rotate(theta, axis) * glm::vec4(right, 1.0f));
up = glm::vec3(glm::rotate(theta, axis) * glm::vec4(up, 1.0f));
glm::mat4 cameraMat = glm::lookAt(eyePos, eyePos+camera.look, camera.up);

```

**Tags:** opengl, 3d, camera-matrix, camera

> **Comments:**
> **username_1**: Are you sure you're specifiying your angle in degrees? Modern versions of GLM use radians everywhere and the docs are not always clear on this.  
> **username_0**: @username_1 so GLM uses radians? I thought it uses degree. I will test with radians and update the result if it indeed fixes the problem  
> **username_1**: Depends on version. Older versions were inconsistent, you could define GLM_FORCE_RADIANS before including it to make it use radians everywhere. Since version 0.9.6 this has become the default. From the doc - "Finally, here is a list of all the functions that could use degrees in GLM 0.9.5.4 that requires radians in GLM 0.9.6: rotate (matrices and quaternions), perspective, perspectiveFov, infinitePerspective, tweakedInfinitePerspective, roll, pitch, yaw, angle, angleAxis, polar, euclidean, rotateNormalizedAxis, rotateX, rotateY, rotateZ and orientedAngle."  

---

## 1 answers

### Answer by username_1 on 2018-03-16. Score: 2 | Accepted answer

Promoting my comment into an answer since it identified the problem...

The issue is confusion between degrees and radians for the angle parameter. GLM, up to version 0.9.5, was very inconsistent in how it dealt with angles, accepting degrees for some functions and radians for others. This behaviour could be overridden with `#define GLM_FORCE_RADIANS` before including the header.

In version 0.9.6, radians everywhere became the default. Unfortunately, if you Google 'glm rotate' at the time of writing, the top result is the 0.9.4 doc page, which still describes the parameters as taking degrees, so you need to be aware of which version you are using and its default behaviour in this regard. If you still want to use degrees for your angle variables, you can convert them with `glm::radians(angle)` before passing them as arguments.


---

