Fixed bug #15, added missing roll, pitch and yaw functions; Fixed half implicit conversions
This commit is contained in:
@@ -212,6 +212,27 @@ namespace detail
|
||||
detail::tvec3<T> eulerAngles(
|
||||
detail::tquat<T> const & x);
|
||||
|
||||
/// Returns roll value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
///
|
||||
/// @see gtx_quaternion
|
||||
template <typename valType>
|
||||
valType roll(
|
||||
detail::tquat<valType> const & x);
|
||||
|
||||
/// Returns pitch value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
///
|
||||
/// @see gtx_quaternion
|
||||
template <typename valType>
|
||||
valType pitch(
|
||||
detail::tquat<valType> const & x);
|
||||
|
||||
/// Returns yaw value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
///
|
||||
/// @see gtx_quaternion
|
||||
template <typename valType>
|
||||
valType yaw(
|
||||
detail::tquat<valType> const & x);
|
||||
|
||||
/// Converts a quaternion to a 3 * 3 matrix.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
|
||||
@@ -512,7 +512,46 @@ namespace detail
|
||||
{
|
||||
return detail::tvec3<T>(pitch(x), yaw(x), roll(x));
|
||||
}
|
||||
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType roll
|
||||
(
|
||||
detail::tquat<valType> const & q
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
return valType(atan2(valType(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
|
||||
#else
|
||||
return glm::degrees(atan(valType(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType pitch
|
||||
(
|
||||
detail::tquat<valType> const & q
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
return valType(atan2(valType(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
|
||||
#else
|
||||
return glm::degrees(atan(valType(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER valType yaw
|
||||
(
|
||||
detail::tquat<valType> const & q
|
||||
)
|
||||
{
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
return asin(valType(-2) * (q.x * q.z - q.w * q.y));
|
||||
#else
|
||||
return glm::degrees(asin(valType(-2) * (q.x * q.z - q.w * q.y)));
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<T> mat3_cast
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user