# Rotation

Rotation is with GLM is not as hard as in the lecture.

We can use glm::rotate achieve rotation around any axis

```cpp
glm::rotate(glm::radians(angle_in_degree), glm::vec3(axis_x, axis_y, axis_z));
```

Let's scale and rotate the triangles around the Z axis by 60 degrees

```cpp
    glm::mat4 mat_scale = glm::scale(glm::vec3(0.5f, 0.5f, 0.5f));
    glm::mat4 mat_rot = glm::rotate(glm::radians(60.0f), glm::vec3(0.0f, 0.0f, 1.0f));

    glm::mat4 mat_modelview = mat_rot * mat_scale;
```

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2Fd8bdFmpV77j8vXyFCANG%2Fimage.png?alt=media&#x26;token=0b7f767a-44ec-4f12-8699-45e9233bf285" alt=""><figcaption></figcaption></figure>

We can temporarily remove the distortion by set the window to a square. We will eliminate the distion for arbitary windows when we learn projection.

```cpp
window = glfwCreateWindow(640, 640, "Hello OpenGL 2", NULL, NULL);
```

<figure><img src="https://3464970502-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3JUKGJZ67JX02QZdPhsy%2Fuploads%2FpPMOCWHgraw4RRDG2s09%2Fimage.png?alt=media&#x26;token=aa690c89-e26f-4075-83ee-b8a452cf2e83" alt=""><figcaption></figcaption></figure>

Remember the Z Axis points to you.
