extract fovy and aspect for perpective matrix

This commit is contained in:
Recep Aslantas
2018-01-04 11:16:09 +03:00
parent 3e4f52b3af
commit 797c4581ee
5 changed files with 59 additions and 1 deletions

View File

@@ -426,6 +426,31 @@ glm_persp_decomp_near(mat4 proj, float * __restrict nearVal) {
*nearVal = proj[3][2] / (proj[2][2] - 1);
}
/*!
* @brief returns field of view angle along the Y-axis (in radians)
*
* if you need to degrees, use glm_deg to convert it or use this:
* fovy_deg = glm_deg(glm_persp_fovy(projMatrix))
*
* @param[in] proj perspective projection matrix
*/
CGLM_INLINE
float
glm_persp_fovy(mat4 proj) {
return 2.0 * atan(1.0 / proj[1][1]);
}
/*!
* @brief returns aspect ratio of perspective projection
*
* @param[in] proj perspective projection matrix
*/
CGLM_INLINE
float
glm_persp_aspect(mat4 proj) {
return proj[1][1] / proj[0][0];
}
/*!
* @brief extracts view frustum planes
*