glm::eulerAngleZXY vs glm::yawPitchRoll


template
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> eulerAngleZXY
(
T const & t1,
T const & t2,
T const & t3
)
{
T c1 = glm::cos(t1);
T s1 = glm::sin(t1);
T c2 = glm::cos(t2);
T s2 = glm::sin(t2);
T c3 = glm::cos(t3);
T s3 = glm::sin(t3);

mat<4, 4, T, defaultp> Result;
Result[0][0] = c1 * c3 – s1 * s2 * s3;
Result[0][1] = c3 * s1 + c1 * s2 * s3;
Result[0][2] =-c2 * s3;
Result[0][3] = static_cast(0);
Result[1][0] =-c2 * s1;
Result[1][1] = c1 * c2;
Result[1][2] = s2;
Result[1][3] = static_cast(0);
Result[2][0] = c1 * s3 + c3 * s1 * s2;
Result[2][1] = s1 * s3 – c1 * c3 * s2;
Result[2][2] = c2 * c3;
Result[2][3] = static_cast(0);
Result[3][0] = static_cast(0);
Result[3][1] = static_cast(0);
Result[3][2] = static_cast(0);
Result[3][3] = static_cast(1);
return Result;
}

template
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> yawPitchRoll
(
T const& yaw,
T const& pitch,
T const& roll
)
{
T tmp_ch = glm::cos(yaw);
T tmp_sh = glm::sin(yaw);
T tmp_cp = glm::cos(pitch);
T tmp_sp = glm::sin(pitch);
T tmp_cb = glm::cos(roll);
T tmp_sb = glm::sin(roll);

mat<4, 4, T, defaultp> Result;
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
Result[0][1] = tmp_sb * tmp_cp;
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
Result[0][3] = static_cast(0);
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
Result[1][1] = tmp_cb * tmp_cp;
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
Result[1][3] = static_cast(0);
Result[2][0] = tmp_sh * tmp_cp;
Result[2][1] = -tmp_sp;
Result[2][2] = tmp_ch * tmp_cp;
Result[2][3] = static_cast(0);
Result[3][0] = static_cast(0);
Result[3][1] = static_cast(0);
Result[3][2] = static_cast(0);
Result[3][3] = static_cast(1);
return Result;
}