Added a quation constructor taking two axis

This commit is contained in:
Christophe Riccio 2013-09-22 23:37:55 +02:00
parent a15201dc59
commit 1e69dfe30e
5 changed files with 49 additions and 27 deletions

View File

@ -70,7 +70,7 @@ namespace detail
tquat<U, Q> const & q);
GLM_FUNC_DECL explicit tquat(
T const & s,
glm::detail::tvec3<T, P> const & v);
tvec3<T, P> const & v);
GLM_FUNC_DECL explicit tquat(
T const & w,
T const & x,
@ -79,6 +79,15 @@ namespace detail
// 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.
GLM_FUNC_DECL explicit tquat(
tvec3<T, P> const & eulerAngles);

View File

@ -104,6 +104,18 @@ namespace detail
// 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>
GLM_FUNC_QUALIFIER tquat<T, P>::tquat
(

View File

@ -65,6 +65,7 @@ GLM 0.9.5.0: 2013-XX-XX
- Replaced GLM traits by STL traits when possible
- Allowed including individual core feature
- Increased unit tests completness
- Added creating of a quaternion from two vectors
================================================================================
GLM 0.9.4.6: 2013-09-20

View File

@ -577,17 +577,17 @@ int test_isnan()
double Zero_d = 0.0;
{
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::dvec3(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.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::dvec4(0.0 / Zero_d))) ? 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::vec3(0.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::vec4(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::vec3(0.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1;
}
return Error;
@ -601,25 +601,25 @@ int test_isinf()
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::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::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::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::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::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::vec4( 1.0f/Zero_f))) ? 0 : 1;
Error += true == glm::any(glm::isinf(glm::vec4(-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::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;
}
return Error;

View File

@ -11,9 +11,9 @@ using namespace glm;
int main()
{
f32 first = 1.046 ;
f32 second = 0.52 ;
f32 third = -0.785;
f32 first = 1.046f;
f32 second = 0.52f;
f32 third = -0.785f;
fmat4 rotationEuler = eulerAngleYXZ(first, second, third);