I am new to OpenGL and Computer Graphics in general.
Lately I was learning how to model a camera, specifically how to model the rotation of camera. I was introduced to Euler angles for this purpose.
I got a rough idea about how to use Euler angles to model camera rotation from this post. Based on that, I wrote something like below:
GLfloat yaw, pitch;
...
void mouse_callback(GLFWwindow* window, double xpos, double ypos)
{
/*
Here I am updating the yaw, and pitch values
based on mouse movement and previous mouse position
*/
glm::mat4 yawPitchRotMat;
/* We want to do yaw * pitch. */
//y-axis as yaw axis
yawPitchRotMat = glm::rotate(yawPitchRotMat, glm::radians(yaw),
glm::vec3(0.0f, 1.0f, 0.0f));
//x-axis as pitch axis
yawPitchRotMat = glm::rotate(yawPitchRotMat, glm::radians(pitch),
glm::vec3(1.0f, 0.0f, 0.0f));
cameraFrontDirection = glm::normalize(-1.0f *
glm::vec3(yawPitchRotMat[2].x, yawPitchRotMat[2].y, yawPitchRotMat[2].z));
}
The above code seems to work. However, I would like to hear your opinion about this approach. Specially as my math is not really very strong, so any mathematical insight regarding Euler angles would be very helpful. Also appreciate any reference to online resource on the same, that is easy to understand.
Note: Though later I also came to know about certain limitation of modelling rotation using Euler angles and use quaternions instead. However I would like to save that topic for future discussion, as I am yet to read about that in details.