Added a quation constructor taking two axis
This commit is contained in:
parent
a15201dc59
commit
1e69dfe30e
@ -70,7 +70,7 @@ namespace detail
|
|||||||
tquat<U, Q> const & q);
|
tquat<U, Q> const & q);
|
||||||
GLM_FUNC_DECL explicit tquat(
|
GLM_FUNC_DECL explicit tquat(
|
||||||
T const & s,
|
T const & s,
|
||||||
glm::detail::tvec3<T, P> const & v);
|
tvec3<T, P> const & v);
|
||||||
GLM_FUNC_DECL explicit tquat(
|
GLM_FUNC_DECL explicit tquat(
|
||||||
T const & w,
|
T const & w,
|
||||||
T const & x,
|
T const & x,
|
||||||
@ -79,6 +79,15 @@ namespace detail
|
|||||||
|
|
||||||
// Convertions
|
// Convertions
|
||||||
|
|
||||||
|
/// Create a quaternion from two normalized axis
|
||||||
|
///
|
||||||
|
/// @param u A first normalized axis
|
||||||
|
/// @param v A second normalized axis
|
||||||
|
/// @see gtc_quaternion
|
||||||
|
/// @see http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
|
||||||
|
GLM_FUNC_DECL explicit tquat(
|
||||||
|
detail::tvec3<T, P> const & u,
|
||||||
|
detail::tvec3<T, P> const & v);
|
||||||
/// Build a quaternion from euler angles (pitch, yaw, roll), in radians.
|
/// Build a quaternion from euler angles (pitch, yaw, roll), in radians.
|
||||||
GLM_FUNC_DECL explicit tquat(
|
GLM_FUNC_DECL explicit tquat(
|
||||||
tvec3<T, P> const & eulerAngles);
|
tvec3<T, P> const & eulerAngles);
|
||||||
|
@ -104,6 +104,18 @@ namespace detail
|
|||||||
// this->z = c.x * c.y * s.z - s.x * s.y * c.z;
|
// this->z = c.x * c.y * s.z - s.x * s.y * c.z;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
template <typename T, precision P>
|
||||||
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||||
|
(
|
||||||
|
detail::tvec3<T, P> const & u,
|
||||||
|
detail::tvec3<T, P> const & v
|
||||||
|
)
|
||||||
|
{
|
||||||
|
detail::tvec3<T, P> w = cross(u, v);
|
||||||
|
detail::tquat<T, P> q(T(1) + dot(u, v), w.x, w.y, w.z);
|
||||||
|
*this = normalize(q);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T, precision P>
|
||||||
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
|
||||||
(
|
(
|
||||||
|
@ -65,6 +65,7 @@ GLM 0.9.5.0: 2013-XX-XX
|
|||||||
- Replaced GLM traits by STL traits when possible
|
- Replaced GLM traits by STL traits when possible
|
||||||
- Allowed including individual core feature
|
- Allowed including individual core feature
|
||||||
- Increased unit tests completness
|
- Increased unit tests completness
|
||||||
|
- Added creating of a quaternion from two vectors
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
GLM 0.9.4.6: 2013-09-20
|
GLM 0.9.4.6: 2013-09-20
|
||||||
|
@ -577,17 +577,17 @@ int test_isnan()
|
|||||||
double Zero_d = 0.0;
|
double Zero_d = 0.0;
|
||||||
|
|
||||||
{
|
{
|
||||||
Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1;
|
Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isnan(glm::dvec2(0.0 / Zero_d))) ? 0 : 1;
|
Error += true == glm::any(glm::isnan(glm::dvec2(0.0 / Zero_d))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isnan(glm::dvec3(0.0 / Zero_d))) ? 0 : 1;
|
Error += true == glm::any(glm::isnan(glm::dvec3(0.0 / Zero_d))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isnan(glm::dvec4(0.0 / Zero_d))) ? 0 : 1;
|
Error += true == glm::any(glm::isnan(glm::dvec4(0.0 / Zero_d))) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1;
|
Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1;
|
Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1;
|
Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1;
|
Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
@ -601,25 +601,25 @@ int test_isinf()
|
|||||||
double Zero_d = 0.0;
|
double Zero_d = 0.0;
|
||||||
|
|
||||||
{
|
{
|
||||||
Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1;
|
Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1;
|
||||||
Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1;
|
Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1;
|
Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1;
|
||||||
Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1;
|
Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1;
|
||||||
Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1;
|
Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
|
@ -11,9 +11,9 @@ using namespace glm;
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
f32 first = 1.046 ;
|
f32 first = 1.046f;
|
||||||
f32 second = 0.52 ;
|
f32 second = 0.52f;
|
||||||
f32 third = -0.785;
|
f32 third = -0.785f;
|
||||||
|
|
||||||
fmat4 rotationEuler = eulerAngleYXZ(first, second, third);
|
fmat4 rotationEuler = eulerAngleYXZ(first, second, third);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user