mirror of
https://github.com/g-truc/glm.git
synced 2024-11-23 17:14:36 +00:00
Added GLM_FORCE_RADIANS
This commit is contained in:
parent
ebd1ba8bf6
commit
100b2202dd
@ -590,6 +590,11 @@
|
|||||||
# endif//GLM_MESSAGE_COMPONENT_DISPLAYED
|
# endif//GLM_MESSAGE_COMPONENT_DISPLAYED
|
||||||
#endif//GLM_MESSAGE
|
#endif//GLM_MESSAGE
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Radians
|
||||||
|
|
||||||
|
//#define GLM_FORCE_RADIANS
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Static assert
|
// Static assert
|
||||||
|
|
||||||
|
@ -83,10 +83,10 @@ namespace glm
|
|||||||
detail::tmat4x4<T> const & m,
|
detail::tmat4x4<T> const & m,
|
||||||
detail::tvec3<T> const & v);
|
detail::tvec3<T> const & v);
|
||||||
|
|
||||||
/// Builds a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees.
|
/// Builds a rotation 4 * 4 matrix created from an axis vector and an angle.
|
||||||
///
|
///
|
||||||
/// @param m Input matrix multiplied by this rotation matrix.
|
/// @param m Input matrix multiplied by this rotation matrix.
|
||||||
/// @param angle Rotation angle expressed in degrees.
|
/// @param angle Rotation angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
/// @param axis Rotation axis, recommanded to be normalized.
|
/// @param axis Rotation axis, recommanded to be normalized.
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
/// @see gtc_matrix_transform
|
/// @see gtc_matrix_transform
|
||||||
@ -172,7 +172,7 @@ namespace glm
|
|||||||
|
|
||||||
/// Creates a matrix for a symetric perspective-view frustum.
|
/// Creates a matrix for a symetric perspective-view frustum.
|
||||||
///
|
///
|
||||||
/// @param fovy
|
/// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
/// @param aspect
|
/// @param aspect
|
||||||
/// @param near
|
/// @param near
|
||||||
/// @param far
|
/// @param far
|
||||||
@ -187,7 +187,7 @@ namespace glm
|
|||||||
|
|
||||||
/// Builds a perspective projection matrix based on a field of view.
|
/// Builds a perspective projection matrix based on a field of view.
|
||||||
///
|
///
|
||||||
/// @param fov
|
/// @param fov Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
/// @param width
|
/// @param width
|
||||||
/// @param height
|
/// @param height
|
||||||
/// @param near
|
/// @param near
|
||||||
@ -204,7 +204,7 @@ namespace glm
|
|||||||
|
|
||||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite.
|
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite.
|
||||||
///
|
///
|
||||||
/// @param fovy
|
/// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
/// @param aspect
|
/// @param aspect
|
||||||
/// @param near
|
/// @param near
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
@ -215,7 +215,7 @@ namespace glm
|
|||||||
|
|
||||||
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
/// Creates a matrix for a symmetric perspective-view frustum with far plane at infinite for graphics hardware that doesn't support depth clamping.
|
||||||
///
|
///
|
||||||
/// @param fovy
|
/// @param fovy Expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
/// @param aspect
|
/// @param aspect
|
||||||
/// @param near
|
/// @param near
|
||||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||||
|
@ -48,7 +48,11 @@ namespace glm
|
|||||||
detail::tvec3<T> const & v
|
detail::tvec3<T> const & v
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T a = angle;
|
||||||
|
#else
|
||||||
T a = radians(angle);
|
T a = radians(angle);
|
||||||
|
#endif
|
||||||
T c = cos(a);
|
T c = cos(a);
|
||||||
T s = sin(a);
|
T s = sin(a);
|
||||||
|
|
||||||
@ -120,7 +124,11 @@ namespace glm
|
|||||||
detail::tvec3<T> const & v
|
detail::tvec3<T> const & v
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
T a = radians(angle);
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T const a = angle;
|
||||||
|
#else
|
||||||
|
T const a = radians(angle);
|
||||||
|
#endif
|
||||||
T c = cos(a);
|
T c = cos(a);
|
||||||
T s = sin(a);
|
T s = sin(a);
|
||||||
detail::tmat4x4<T> Result;
|
detail::tmat4x4<T> Result;
|
||||||
@ -253,7 +261,11 @@ namespace glm
|
|||||||
valType const & zFar
|
valType const & zFar
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
valType rad = fov;
|
||||||
|
#else
|
||||||
valType rad = glm::radians(fov);
|
valType rad = glm::radians(fov);
|
||||||
|
#endif
|
||||||
valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad);
|
valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad);
|
||||||
valType w = h * height / width;
|
valType w = h * height / width;
|
||||||
|
|
||||||
@ -274,7 +286,11 @@ namespace glm
|
|||||||
T zNear
|
T zNear
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
T range = tan(radians(fovy / T(2))) * zNear;
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T const range = tan(fovy / T(2)) * zNear;
|
||||||
|
#else
|
||||||
|
T const range = tan(radians(fovy / T(2))) * zNear;
|
||||||
|
#endif
|
||||||
T left = -range * aspect;
|
T left = -range * aspect;
|
||||||
T right = range * aspect;
|
T right = range * aspect;
|
||||||
T bottom = -range;
|
T bottom = -range;
|
||||||
@ -297,7 +313,11 @@ namespace glm
|
|||||||
T zNear
|
T zNear
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T range = tan(fovy / T(2)) * zNear;
|
||||||
|
#else
|
||||||
T range = tan(radians(fovy / T(2))) * zNear;
|
T range = tan(radians(fovy / T(2))) * zNear;
|
||||||
|
#endif
|
||||||
T left = -range * aspect;
|
T left = -range * aspect;
|
||||||
T right = range * aspect;
|
T right = range * aspect;
|
||||||
T bottom = -range;
|
T bottom = -range;
|
||||||
|
@ -195,7 +195,9 @@ namespace detail
|
|||||||
detail::tquat<T> inverse(
|
detail::tquat<T> inverse(
|
||||||
detail::tquat<T> const & q);
|
detail::tquat<T> const & q);
|
||||||
|
|
||||||
/// Rotates a quaternion from an vector of 3 components axis and an angle expressed in degrees.
|
/// Rotates a quaternion from an vector of 3 components axis and an angle.
|
||||||
|
///
|
||||||
|
/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
///
|
///
|
||||||
/// @see gtc_quaternion
|
/// @see gtc_quaternion
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -487,10 +487,14 @@ namespace detail
|
|||||||
Tmp.z *= oneOverLen;
|
Tmp.z *= oneOverLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename detail::tquat<T>::value_type AngleRad = radians(angle);
|
#ifdef GLM_FORCE_RADIANS
|
||||||
typename detail::tquat<T>::value_type fSin = sin(AngleRad * T(0.5));
|
typename detail::tquat<T>::value_type const AngleRad(angle);
|
||||||
|
#else
|
||||||
|
typename detail::tquat<T>::value_type const AngleRad = radians(angle);
|
||||||
|
#endif
|
||||||
|
typename detail::tquat<T>::value_type const Sin = sin(AngleRad * T(0.5));
|
||||||
|
|
||||||
return q * detail::tquat<T>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin);
|
return q * detail::tquat<T>(cos(AngleRad * T(0.5)), Tmp.x * Sin, Tmp.y * Sin, Tmp.z * Sin);
|
||||||
//return gtc::quaternion::cross(q, detail::tquat<T>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin));
|
//return gtc::quaternion::cross(q, detail::tquat<T>(cos(AngleRad * T(0.5)), Tmp.x * fSin, Tmp.y * fSin, Tmp.z * fSin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,29 +20,29 @@
|
|||||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
/// THE SOFTWARE.
|
/// THE SOFTWARE.
|
||||||
///
|
///
|
||||||
/// @ref gtx_reciprocal
|
/// @ref gtc_reciprocal
|
||||||
/// @file glm/gtx/reciprocal.hpp
|
/// @file glm/gtc/reciprocal.hpp
|
||||||
/// @date 2008-10-09 / 2011-06-07
|
/// @date 2008-10-09 / 2012-01-25
|
||||||
/// @author Christophe Riccio
|
/// @author Christophe Riccio
|
||||||
///
|
///
|
||||||
/// @see core (dependence)
|
/// @see core (dependence)
|
||||||
///
|
///
|
||||||
/// @defgroup gtx_reciprocal GLM_GTX_reciprocal: Reciprocal
|
/// @defgroup gtc_reciprocal GLM_GTC_reciprocal: Reciprocal
|
||||||
/// @ingroup gtx
|
/// @ingroup gtc
|
||||||
///
|
///
|
||||||
/// @brief Define secant, cosecant and cotangent functions.
|
/// @brief Define secant, cosecant and cotangent functions.
|
||||||
///
|
///
|
||||||
/// <glm/gtx/reciprocal.hpp> need to be included to use these functionalities.
|
/// <glm/gtc/reciprocal.hpp> need to be included to use these functionalities.
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef GLM_GTX_reciprocal
|
#ifndef GLM_GTC_reciprocal
|
||||||
#define GLM_GTX_reciprocal GLM_VERSION
|
#define GLM_GTC_reciprocal GLM_VERSION
|
||||||
|
|
||||||
// Dependency:
|
// Dependency:
|
||||||
#include "../glm.hpp"
|
#include "../glm.hpp"
|
||||||
|
|
||||||
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
|
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
|
||||||
# pragma message("GLM: GLM_GTX_reciprocal extension included")
|
# pragma message("GLM: GLM_GTC_reciprocal extension included")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace glm
|
namespace glm
|
||||||
@ -118,4 +118,4 @@ namespace glm
|
|||||||
|
|
||||||
#include "reciprocal.inl"
|
#include "reciprocal.inl"
|
||||||
|
|
||||||
#endif//GLM_GTX_reciprocal
|
#endif//GLM_GTC_reciprocal
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
|
// OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Created : 2008-10-09
|
// Created : 2008-10-09
|
||||||
// Updated : 2011-10-14
|
// Updated : 2012-01-25
|
||||||
// Licence : This source is under MIT License
|
// Licence : This source is under MIT License
|
||||||
// File : glm/gtx/reciprocal.inl
|
// File : glm/gtc/reciprocal.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include "../core/_vectorize.hpp"
|
#include "../core/_vectorize.hpp"
|
||||||
|
@ -15,14 +15,21 @@ namespace glm
|
|||||||
detail::tvec3<T> const & euclidean
|
detail::tvec3<T> const & euclidean
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
T length = length(euclidean);
|
T const Length(length(euclidean));
|
||||||
detail::tvec3<T> tmp = euclidean / length;
|
detail::tvec3<T> const tmp(euclidean / Length);
|
||||||
T xz_dist = sqrt(tmp.x * tmp.x + tmp.z * tmp.z);
|
T const xz_dist(sqrt(tmp.x * tmp.x + tmp.z * tmp.z));
|
||||||
|
|
||||||
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
return detail::tvec3<T>(
|
||||||
|
atan(xz_dist, tmp.y), // latitude
|
||||||
|
atan(tmp.x, tmp.z), // longitude
|
||||||
|
xz_dist); // xz distance
|
||||||
|
#else
|
||||||
return detail::tvec3<T>(
|
return detail::tvec3<T>(
|
||||||
degrees(atan(xz_dist, tmp.y)), // latitude
|
degrees(atan(xz_dist, tmp.y)), // latitude
|
||||||
degrees(atan(tmp.x, tmp.z)), // longitude
|
degrees(atan(tmp.x, tmp.z)), // longitude
|
||||||
xz_dist); // xz distance
|
xz_dist); // xz distance
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -31,8 +38,14 @@ namespace glm
|
|||||||
detail::tvec3<T> const & polar
|
detail::tvec3<T> const & polar
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
T latitude = radians(polar.x);
|
#ifdef GLM_FORCE_RADIANS
|
||||||
T longitude = radians(polar.y);
|
T const latitude(polar.x);
|
||||||
|
T const longitude(polar.y);
|
||||||
|
#else
|
||||||
|
T const latitude(radians(polar.x));
|
||||||
|
T const longitude(radians(polar.y));
|
||||||
|
#endif
|
||||||
|
|
||||||
return detail::tvec3<T>(
|
return detail::tvec3<T>(
|
||||||
cos(latitude) * sin(longitude),
|
cos(latitude) * sin(longitude),
|
||||||
sin(latitude),
|
sin(latitude),
|
||||||
|
@ -53,14 +53,16 @@ namespace glm
|
|||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
//! Compute a cross product between a quaternion and a vector.
|
//! Compute a cross product between a quaternion and a vector.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tvec3<valType> cross(
|
detail::tvec3<valType> cross(
|
||||||
detail::tquat<valType> const & q,
|
detail::tquat<valType> const & q,
|
||||||
detail::tvec3<valType> const & v);
|
detail::tvec3<valType> const & v);
|
||||||
|
|
||||||
//! Compute a cross product between a vector and a quaternion.
|
//! Compute a cross product between a vector and a quaternion.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tvec3<valType> cross(
|
detail::tvec3<valType> cross(
|
||||||
detail::tvec3<valType> const & v,
|
detail::tvec3<valType> const & v,
|
||||||
@ -68,7 +70,8 @@ namespace glm
|
|||||||
|
|
||||||
//! Compute a point on a path according squad equation.
|
//! Compute a point on a path according squad equation.
|
||||||
//! q1 and q2 are control points; s1 and s2 are intermediate control points.
|
//! q1 and q2 are control points; s1 and s2 are intermediate control points.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tquat<valType> squad(
|
detail::tquat<valType> squad(
|
||||||
detail::tquat<valType> const & q1,
|
detail::tquat<valType> const & q1,
|
||||||
@ -78,7 +81,8 @@ namespace glm
|
|||||||
valType const & h);
|
valType const & h);
|
||||||
|
|
||||||
//! Returns an intermediate control point for squad interpolation.
|
//! Returns an intermediate control point for squad interpolation.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tquat<valType> intermediate(
|
detail::tquat<valType> intermediate(
|
||||||
detail::tquat<valType> const & prev,
|
detail::tquat<valType> const & prev,
|
||||||
@ -86,59 +90,70 @@ namespace glm
|
|||||||
detail::tquat<valType> const & next);
|
detail::tquat<valType> const & next);
|
||||||
|
|
||||||
//! Returns a exp of a quaternion.
|
//! Returns a exp of a quaternion.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tquat<valType> exp(
|
detail::tquat<valType> exp(
|
||||||
detail::tquat<valType> const & q,
|
detail::tquat<valType> const & q,
|
||||||
valType const & exponent);
|
valType const & exponent);
|
||||||
|
|
||||||
//! Returns a log of a quaternion.
|
//! Returns a log of a quaternion.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tquat<valType> log(
|
detail::tquat<valType> log(
|
||||||
detail::tquat<valType> const & q);
|
detail::tquat<valType> const & q);
|
||||||
|
|
||||||
//! Returns x raised to the y power.
|
/// Returns x raised to the y power.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tquat<valType> pow(
|
detail::tquat<valType> pow(
|
||||||
detail::tquat<valType> const & x,
|
detail::tquat<valType> const & x,
|
||||||
valType const & y);
|
valType const & y);
|
||||||
|
|
||||||
//! Returns quarternion square root.
|
//! Returns quarternion square root.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
//template <typename valType>
|
//template <typename valType>
|
||||||
//detail::tquat<valType> sqrt(
|
//detail::tquat<valType> sqrt(
|
||||||
// detail::tquat<valType> const & q);
|
// detail::tquat<valType> const & q);
|
||||||
|
|
||||||
//! Rotates a 3 components vector by a quaternion.
|
//! Rotates a 3 components vector by a quaternion.
|
||||||
//! From GLM_GTX_transform extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tvec3<valType> rotate(
|
detail::tvec3<valType> rotate(
|
||||||
detail::tquat<valType> const & q,
|
detail::tquat<valType> const & q,
|
||||||
detail::tvec3<valType> const & v);
|
detail::tvec3<valType> const & v);
|
||||||
|
|
||||||
//! Rotates a 4 components vector by a quaternion.
|
/// Rotates a 4 components vector by a quaternion.
|
||||||
//! From GLM_GTX_transform extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tvec4<valType> rotate(
|
detail::tvec4<valType> rotate(
|
||||||
detail::tquat<valType> const & q,
|
detail::tquat<valType> const & q,
|
||||||
detail::tvec4<valType> const & v);
|
detail::tvec4<valType> const & v);
|
||||||
|
|
||||||
//! Returns the quaternion rotation angle.
|
/// Returns the quaternion rotation angle.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
valType angle(
|
valType angle(
|
||||||
detail::tquat<valType> const & x);
|
detail::tquat<valType> const & x);
|
||||||
|
|
||||||
//! Returns the q rotation axis.
|
/// Returns the q rotation axis.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tvec3<valType> axis(
|
detail::tvec3<valType> axis(
|
||||||
detail::tquat<valType> const & x);
|
detail::tquat<valType> const & x);
|
||||||
|
|
||||||
//! Build a quaternion from an angle and a normalized axis.
|
/// Build a quaternion from an angle and a normalized axis.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tquat<valType> angleAxis(
|
detail::tquat<valType> angleAxis(
|
||||||
valType const & angle,
|
valType const & angle,
|
||||||
@ -146,77 +161,92 @@ namespace glm
|
|||||||
valType const & y,
|
valType const & y,
|
||||||
valType const & z);
|
valType const & z);
|
||||||
|
|
||||||
//! Build a quaternion from an angle and a normalized axis.
|
/// Build a quaternion from an angle and a normalized axis.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
|
/// @param axis Axis of the quaternion, must be normalized.
|
||||||
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tquat<valType> angleAxis(
|
detail::tquat<valType> angleAxis(
|
||||||
valType const & angle,
|
valType const & angle,
|
||||||
detail::tvec3<valType> const & axis);
|
detail::tvec3<valType> const & axis);
|
||||||
|
|
||||||
//! Extract the real component of a quaternion.
|
/// Extract the real component of a quaternion.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
valType extractRealComponent(
|
valType extractRealComponent(
|
||||||
detail::tquat<valType> const & q);
|
detail::tquat<valType> const & q);
|
||||||
|
|
||||||
//! Returns roll value of euler angles in degrees.
|
/// Returns roll value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
valType roll(
|
valType roll(
|
||||||
detail::tquat<valType> const & x);
|
detail::tquat<valType> const & x);
|
||||||
|
|
||||||
//! Returns pitch value of euler angles in degrees.
|
/// Returns pitch value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
valType pitch(
|
valType pitch(
|
||||||
detail::tquat<valType> const & x);
|
detail::tquat<valType> const & x);
|
||||||
|
|
||||||
//! Returns yaw value of euler angles in degrees.
|
/// Returns yaw value of euler angles expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
valType yaw(
|
valType yaw(
|
||||||
detail::tquat<valType> const & x);
|
detail::tquat<valType> const & x);
|
||||||
|
|
||||||
//! Returns euler angles, yitch as x, yaw as y, roll as z.
|
/// Returns euler angles, yitch as x, yaw as y, roll as z.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tvec3<valType> eulerAngles(
|
detail::tvec3<valType> eulerAngles(
|
||||||
detail::tquat<valType> const & x);
|
detail::tquat<valType> const & x);
|
||||||
|
|
||||||
//! Converts a quaternion to a 3 * 3 matrix.
|
/// Converts a quaternion to a 3 * 3 matrix.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tmat3x3<valType> toMat3(
|
detail::tmat3x3<valType> toMat3(
|
||||||
detail::tquat<valType> const & x){return mat3_cast(x);}
|
detail::tquat<valType> const & x){return mat3_cast(x);}
|
||||||
|
|
||||||
//! Converts a quaternion to a 4 * 4 matrix.
|
/// Converts a quaternion to a 4 * 4 matrix.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tmat4x4<valType> toMat4(
|
detail::tmat4x4<valType> toMat4(
|
||||||
detail::tquat<valType> const & x){return mat4_cast(x);}
|
detail::tquat<valType> const & x){return mat4_cast(x);}
|
||||||
|
|
||||||
//! Converts a 3 * 3 matrix to a quaternion.
|
/// Converts a 3 * 3 matrix to a quaternion.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tquat<valType> toQuat(
|
detail::tquat<valType> toQuat(
|
||||||
detail::tmat3x3<valType> const & x){return quat_cast(x);}
|
detail::tmat3x3<valType> const & x){return quat_cast(x);}
|
||||||
|
|
||||||
//! Converts a 4 * 4 matrix to a quaternion.
|
/// Converts a 4 * 4 matrix to a quaternion.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tquat<valType> toQuat(
|
detail::tquat<valType> toQuat(
|
||||||
detail::tmat4x4<valType> const & x){return quat_cast(x);}
|
detail::tmat4x4<valType> const & x){return quat_cast(x);}
|
||||||
|
|
||||||
//! Quaternion interpolation using the rotation short path.
|
/// Quaternion interpolation using the rotation short path.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename T>
|
template <typename T>
|
||||||
detail::tquat<T> shortMix(
|
detail::tquat<T> shortMix(
|
||||||
detail::tquat<T> const & x,
|
detail::tquat<T> const & x,
|
||||||
detail::tquat<T> const & y,
|
detail::tquat<T> const & y,
|
||||||
T const & a);
|
T const & a);
|
||||||
|
|
||||||
//! Quaternion normalized linear interpolation.
|
/// Quaternion normalized linear interpolation.
|
||||||
//! From GLM_GTX_quaternion extension.
|
///
|
||||||
|
/// @see gtx_quaternion
|
||||||
template <typename T>
|
template <typename T>
|
||||||
detail::tquat<T> fastMix(
|
detail::tquat<T> fastMix(
|
||||||
detail::tquat<T> const & x,
|
detail::tquat<T> const & x,
|
||||||
|
@ -147,7 +147,11 @@ namespace glm
|
|||||||
detail::tquat<T> const & x
|
detail::tquat<T> const & x
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
return acos(x.w) * T(2);
|
||||||
|
#else
|
||||||
return glm::degrees(acos(x.w) * T(2));
|
return glm::degrees(acos(x.w) * T(2));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -184,7 +188,11 @@ namespace glm
|
|||||||
{
|
{
|
||||||
detail::tquat<valType> result;
|
detail::tquat<valType> result;
|
||||||
|
|
||||||
valType a = glm::radians(angle);
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
valType a(angle);
|
||||||
|
#else
|
||||||
|
valType a(glm::radians(angle));
|
||||||
|
#endif
|
||||||
valType s = glm::sin(a * valType(0.5));
|
valType s = glm::sin(a * valType(0.5));
|
||||||
|
|
||||||
result.w = glm::cos(a * valType(0.5));
|
result.w = glm::cos(a * valType(0.5));
|
||||||
@ -213,7 +221,11 @@ namespace glm
|
|||||||
detail::tquat<valType> const & q
|
detail::tquat<valType> const & q
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
return 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(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));
|
return glm::degrees(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));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
@ -222,7 +234,11 @@ namespace glm
|
|||||||
detail::tquat<valType> const & q
|
detail::tquat<valType> const & q
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
return 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(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));
|
return glm::degrees(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));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
@ -231,7 +247,11 @@ namespace glm
|
|||||||
detail::tquat<valType> const & q
|
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)));
|
return glm::degrees(asin(valType(-2) * (q.x * q.z - q.w * q.y)));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
|
@ -17,8 +17,13 @@ namespace glm
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec2<T> Result;
|
detail::tvec2<T> Result;
|
||||||
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T const Cos(cos(angle));
|
||||||
|
T const Sin(sin(angle));
|
||||||
|
#else
|
||||||
T const Cos = cos(radians(angle));
|
T const Cos = cos(radians(angle));
|
||||||
T const Sin = sin(radians(angle));
|
T const Sin = sin(radians(angle));
|
||||||
|
#endif
|
||||||
Result.x = v.x * Cos - v.y * Sin;
|
Result.x = v.x * Cos - v.y * Sin;
|
||||||
Result.y = v.x * Sin + v.y * Cos;
|
Result.y = v.x * Sin + v.y * Cos;
|
||||||
return Result;
|
return Result;
|
||||||
@ -64,9 +69,16 @@ namespace glm
|
|||||||
T const & angle
|
T const & angle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec3<T> Result = v;
|
detail::tvec3<T> Result(v);
|
||||||
const T Cos = cos(radians(angle));
|
|
||||||
const T Sin = sin(radians(angle));
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T const Cos(cos(angle));
|
||||||
|
T const Sin(sin(angle));
|
||||||
|
#else
|
||||||
|
T const Cos = cos(radians(angle));
|
||||||
|
T const Sin = sin(radians(angle));
|
||||||
|
#endif
|
||||||
|
|
||||||
Result.y = v.y * Cos - v.z * Sin;
|
Result.y = v.y * Cos - v.z * Sin;
|
||||||
Result.z = v.y * Sin + v.z * Cos;
|
Result.z = v.y * Sin + v.z * Cos;
|
||||||
return Result;
|
return Result;
|
||||||
@ -80,8 +92,15 @@ namespace glm
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec3<T> Result = v;
|
detail::tvec3<T> Result = v;
|
||||||
const T Cos = cos(radians(angle));
|
|
||||||
const T Sin = sin(radians(angle));
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T const Cos(cos(angle));
|
||||||
|
T const Sin(sin(angle));
|
||||||
|
#else
|
||||||
|
T const Cos(cos(radians(angle)));
|
||||||
|
T const Sin(sin(radians(angle)));
|
||||||
|
#endif
|
||||||
|
|
||||||
Result.x = v.x * Cos + v.z * Sin;
|
Result.x = v.x * Cos + v.z * Sin;
|
||||||
Result.z = -v.x * Sin + v.z * Cos;
|
Result.z = -v.x * Sin + v.z * Cos;
|
||||||
return Result;
|
return Result;
|
||||||
@ -95,8 +114,15 @@ namespace glm
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec3<T> Result = v;
|
detail::tvec3<T> Result = v;
|
||||||
const T Cos = cos(radians(angle));
|
|
||||||
const T Sin = sin(radians(angle));
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T const Cos(cos(angle));
|
||||||
|
T const Sin(sin(angle));
|
||||||
|
#else
|
||||||
|
T const Cos(cos(radians(angle)));
|
||||||
|
T const Sin(sin(radians(angle)));
|
||||||
|
#endif
|
||||||
|
|
||||||
Result.x = v.x * Cos - v.y * Sin;
|
Result.x = v.x * Cos - v.y * Sin;
|
||||||
Result.y = v.x * Sin + v.y * Cos;
|
Result.y = v.x * Sin + v.y * Cos;
|
||||||
return Result;
|
return Result;
|
||||||
@ -110,8 +136,15 @@ namespace glm
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec4<T> Result = v;
|
detail::tvec4<T> Result = v;
|
||||||
const T Cos = cos(radians(angle));
|
|
||||||
const T Sin = sin(radians(angle));
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T const Cos(cos(angle));
|
||||||
|
T const Sin(sin(angle));
|
||||||
|
#else
|
||||||
|
T const Cos(cos(radians(angle)));
|
||||||
|
T const Sin(sin(radians(angle)));
|
||||||
|
#endif
|
||||||
|
|
||||||
Result.y = v.y * Cos - v.z * Sin;
|
Result.y = v.y * Cos - v.z * Sin;
|
||||||
Result.z = v.y * Sin + v.z * Cos;
|
Result.z = v.y * Sin + v.z * Cos;
|
||||||
return Result;
|
return Result;
|
||||||
@ -125,8 +158,15 @@ namespace glm
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec4<T> Result = v;
|
detail::tvec4<T> Result = v;
|
||||||
const T Cos = cos(radians(angle));
|
|
||||||
const T Sin = sin(radians(angle));
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T const Cos(cos(angle));
|
||||||
|
T const Sin(sin(angle));
|
||||||
|
#else
|
||||||
|
T const Cos(cos(radians(angle)));
|
||||||
|
T const Sin(sin(radians(angle)));
|
||||||
|
#endif
|
||||||
|
|
||||||
Result.x = v.x * Cos + v.z * Sin;
|
Result.x = v.x * Cos + v.z * Sin;
|
||||||
Result.z = -v.x * Sin + v.z * Cos;
|
Result.z = -v.x * Sin + v.z * Cos;
|
||||||
return Result;
|
return Result;
|
||||||
@ -140,8 +180,15 @@ namespace glm
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec4<T> Result = v;
|
detail::tvec4<T> Result = v;
|
||||||
const T Cos = cos(radians(angle));
|
|
||||||
const T Sin = sin(radians(angle));
|
#ifdef GLM_FORCE_RADIANS
|
||||||
|
T const Cos(cos(angle));
|
||||||
|
T const Sin(sin(angle));
|
||||||
|
#else
|
||||||
|
T const Cos(cos(radians(angle)));
|
||||||
|
T const Sin(sin(radians(angle)));
|
||||||
|
#endif
|
||||||
|
|
||||||
Result.x = v.x * Cos - v.y * Sin;
|
Result.x = v.x * Cos - v.y * Sin;
|
||||||
Result.y = v.x * Sin + v.y * Cos;
|
Result.y = v.x * Sin + v.y * Cos;
|
||||||
return Result;
|
return Result;
|
||||||
|
@ -27,8 +27,12 @@ namespace glm
|
|||||||
detail::tvec2<valType> const & y
|
detail::tvec2<valType> const & y
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType Angle = glm::degrees(acos(dot(x, y)));
|
#ifdef GLM_FORCE_RADIANS
|
||||||
detail::tvec2<valType> TransformedVector = glm::rotate(x, Angle);
|
valType const Angle(acos(dot(x, y)));
|
||||||
|
#else
|
||||||
|
valType const Angle(glm::degrees(acos(dot(x, y))));
|
||||||
|
#endif
|
||||||
|
detail::tvec2<valType> const TransformedVector(glm::rotate(x, Angle));
|
||||||
if(all(equalEpsilon(y, TransformedVector, valType(0.01))))
|
if(all(equalEpsilon(y, TransformedVector, valType(0.01))))
|
||||||
return Angle;
|
return Angle;
|
||||||
else
|
else
|
||||||
@ -43,7 +47,7 @@ namespace glm
|
|||||||
detail::tvec3<valType> const & ref
|
detail::tvec3<valType> const & ref
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType Angle = glm::degrees(glm::acos(glm::dot(x, y)));
|
valType const Angle(glm::degrees(glm::acos(glm::dot(x, y))));
|
||||||
|
|
||||||
if(glm::dot(ref, glm::cross(x, y)) < valType(0))
|
if(glm::dot(ref, glm::cross(x, y)) < valType(0))
|
||||||
return -Angle;
|
return -Angle;
|
||||||
|
Loading…
Reference in New Issue
Block a user