Updated to GLM 0.9.B

This commit is contained in:
Christophe Riccio
2010-04-29 11:56:52 +01:00
parent 7c7b1d0b3d
commit 05439738b8
266 changed files with 15552 additions and 8092 deletions

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-04-29
// Updated : 2009-04-29
@@ -54,39 +54,12 @@ namespace glm
//! From GLM_GTC_double_float extension.
typedef detail::tmat4x4<float> fmat4;
//! Vector of 2 double-precision floating-point numbers.
//! From GLM_GTC_double_float extension.
typedef detail::tvec2<double> dvec2;
//! Vector of 3 double-precision floating-point numbers.
//! From GLM_GTC_double_float extension.
typedef detail::tvec3<double> dvec3;
//! Vector of 4 double-precision floating-point numbers.
//! From GLM_GTC_double_float extension.
typedef detail::tvec4<double> dvec4;
//! 2 * 2 matrix of double-precision floating-point numbers.
//! From GLM_GTC_double_float extension.
typedef detail::tmat2x2<double> dmat2;
//! 3 * 3 matrix of double-precision floating-point numbers.
//! From GLM_GTC_double_float extension.
typedef detail::tmat3x3<double> dmat3;
//! 4 * 4 matrix of double-precision floating-point numbers.
//! From GLM_GTC_double_float extension.
typedef detail::tmat4x4<double> dmat4;
}//namespace double_float
}//namespace gtc
}//namespace glm
#define GLM_GTC_double_float namespace gtc::double_float
#ifndef GLM_GTC_GLOBAL
namespace glm {using GLM_GTC_double_float;}
#endif//GLM_GTC_GLOBAL
#include "double_float.inl"
namespace glm{using namespace gtc::double_float;}
#endif//glm_gtc_double_float

View File

@@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-04-29
// Updated : 2009-04-29
// Updated : 2010-02-07
// Licence : This source is under MIT License
// File : glm/gtc/half_float.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -25,26 +25,13 @@ namespace glm
template <>
struct tvec2<thalf>
{
//////////////////////////////////////
// Typedef (Implementation details)
enum ctor{null};
typedef thalf value_type;
typedef thalf & value_reference;
typedef thalf * value_pointer;
typedef tvec2<bool> bool_type;
typedef sizeType size_type;
typedef std::size_t size_type;
static size_type value_size();
static bool is_vector();
typedef tvec2<thalf> type;
typedef tvec2<thalf>* pointer;
typedef const tvec2<thalf>* const_pointer;
typedef const tvec2<thalf>*const const_pointer_const;
typedef tvec2<thalf>*const pointer_const;
typedef tvec2<thalf>& reference;
typedef const tvec2<thalf>& const_reference;
typedef const tvec2<thalf>& param_type;
typedef tvec2<bool> bool_type;
//////////////////////////////////////
// Data
@@ -57,12 +44,6 @@ namespace glm
thalf & operator[](size_type i);
thalf const & operator[](size_type i) const;
//////////////////////////////////////
// Address (Implementation details)
thalf const * _address() const{return (value_type*)(this);}
thalf * _address(){return (value_type*)(this);}
//////////////////////////////////////
// Implicit basic constructors
@@ -72,8 +53,12 @@ namespace glm
//////////////////////////////////////
// Explicit basic constructors
explicit tvec2(thalf s);
explicit tvec2(thalf s1, thalf s2);
explicit tvec2(ctor);
explicit tvec2(
thalf const & s);
explicit tvec2(
thalf const & s1,
thalf const & s2);
//////////////////////////////////////
// Swizzle constructors
@@ -85,10 +70,10 @@ namespace glm
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec2(U x);
explicit tvec2(U const & x);
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, typename V>
explicit tvec2(U x, V y);
explicit tvec2(U const & x, V const & y);
//////////////////////////////////////
// Convertion vector constructors
@@ -108,13 +93,13 @@ namespace glm
tvec2<thalf>& operator= (tvec2<thalf> const & v);
tvec2<thalf>& operator+=(thalf s);
tvec2<thalf>& operator+=(thalf const & s);
tvec2<thalf>& operator+=(tvec2<thalf> const & v);
tvec2<thalf>& operator-=(thalf s);
tvec2<thalf>& operator-=(thalf const & s);
tvec2<thalf>& operator-=(tvec2<thalf> const & v);
tvec2<thalf>& operator*=(thalf s);
tvec2<thalf>& operator*=(thalf const & s);
tvec2<thalf>& operator*=(tvec2<thalf> const & v);
tvec2<thalf>& operator/=(thalf s);
tvec2<thalf>& operator/=(thalf const & s);
tvec2<thalf>& operator/=(tvec2<thalf> const & v);
tvec2<thalf>& operator++();
tvec2<thalf>& operator--();
@@ -132,26 +117,13 @@ namespace glm
template <>
struct tvec3<thalf>
{
//////////////////////////////////////
// Typedef (Implementation details)
enum ctor{null};
typedef thalf value_type;
typedef thalf & value_reference;
typedef thalf * value_pointer;
typedef tvec3<bool> bool_type;
typedef glm::sizeType size_type;
typedef std::size_t size_type;
static size_type value_size();
static bool is_vector();
typedef tvec3<thalf> type;
typedef tvec3<thalf> * pointer;
typedef tvec3<thalf> const * const_pointer;
typedef tvec3<thalf> const * const const_pointer_const;
typedef tvec3<thalf> * const pointer_const;
typedef tvec3<thalf> & reference;
typedef tvec3<thalf> const & const_reference;
typedef tvec3<thalf> const & param_type;
typedef tvec3<bool> bool_type;
//////////////////////////////////////
// Data
@@ -164,12 +136,6 @@ namespace glm
thalf & operator[](size_type i);
thalf const & operator[](size_type i) const;
//////////////////////////////////////
// Address (Implementation details)
value_type const * _address() const{return (value_type*)(this);}
value_type * _address(){return (value_type*)(this);}
//////////////////////////////////////
// Implicit basic constructors
@@ -179,8 +145,13 @@ namespace glm
//////////////////////////////////////
// Explicit basic constructors
explicit tvec3(thalf s);
explicit tvec3(thalf s1, thalf s2, thalf s3);
explicit tvec3(ctor);
explicit tvec3(
thalf const & s);
explicit tvec3(
thalf const & s1,
thalf const & s2,
thalf const & s3);
//////////////////////////////////////
// Swizzle constructors
@@ -192,20 +163,20 @@ namespace glm
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec3(U x);
explicit tvec3(U const & x);
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U, typename V, typename W>
explicit tvec3(U x, V y, W z);
explicit tvec3(U const & x, V const & y, W const & z);
//////////////////////////////////////
// Convertion vector constructors
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec3(const tvec2<A>& v, B s);
explicit tvec3(tvec2<A> const & v, B const & s);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec3(A s, const tvec2<B>& v);
explicit tvec3(A const & s, tvec2<B> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec3(tvec3<U> const & v);
@@ -218,13 +189,13 @@ namespace glm
tvec3<thalf>& operator= (tvec3<thalf> const & v);
tvec3<thalf>& operator+=(thalf s);
tvec3<thalf>& operator+=(thalf const & s);
tvec3<thalf>& operator+=(tvec3<thalf> const & v);
tvec3<thalf>& operator-=(thalf s);
tvec3<thalf>& operator-=(thalf const & s);
tvec3<thalf>& operator-=(tvec3<thalf> const & v);
tvec3<thalf>& operator*=(thalf s);
tvec3<thalf>& operator*=(thalf const & s);
tvec3<thalf>& operator*=(tvec3<thalf> const & v);
tvec3<thalf>& operator/=(thalf s);
tvec3<thalf>& operator/=(thalf const & s);
tvec3<thalf>& operator/=(tvec3<thalf> const & v);
tvec3<thalf>& operator++();
tvec3<thalf>& operator--();
@@ -242,26 +213,13 @@ namespace glm
template <>
struct tvec4<thalf>
{
//////////////////////////////////////
// Typedef (Implementation details)
enum ctor{null};
typedef thalf value_type;
typedef thalf & value_reference;
typedef thalf * value_pointer;
typedef tvec4<bool> bool_type;
typedef glm::sizeType size_type;
typedef std::size_t size_type;
static size_type value_size();
static bool is_vector();
typedef tvec4<thalf> type;
typedef tvec4<thalf> * pointer;
typedef tvec4<thalf> const * const_pointer;
typedef tvec4<thalf> const * const const_pointer_const;
typedef tvec4<thalf> * const pointer_const;
typedef tvec4<thalf> & reference;
typedef tvec4<thalf> const & const_reference;
typedef tvec4<thalf> const & param_type;
typedef tvec4<bool> bool_type;
//////////////////////////////////////
// Data
@@ -274,12 +232,6 @@ namespace glm
thalf & operator[](size_type i);
thalf const & operator[](size_type i) const;
//////////////////////////////////////
// Address (Implementation details)
value_type const * _address() const{return (value_type*)(this);}
value_type * _address(){return (value_type*)(this);}
//////////////////////////////////////
// Implicit basic constructors
@@ -289,8 +241,14 @@ namespace glm
//////////////////////////////////////
// Explicit basic constructors
explicit tvec4(thalf s);
explicit tvec4(thalf s0, thalf s1, thalf s2, thalf s3);
explicit tvec4(ctor);
explicit tvec4(
thalf const & s);
explicit tvec4(
thalf const & s0,
thalf const & s1,
thalf const & s2,
thalf const & s3);
//////////////////////////////////////
// Swizzle constructors
@@ -302,48 +260,48 @@ namespace glm
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec4(U x);
explicit tvec4(U const & x);
//! Explicit converions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C, typename D>
explicit tvec4(A x, B y, C z, D w);
explicit tvec4(A const & x, B const & y, C const & z, D const & w);
//////////////////////////////////////
// Convertion vector constructors
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C>
explicit tvec4(const tvec2<A>& v, B s1, C s2);
explicit tvec4(tvec2<A> const & v, B const & s1, C const & s2);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C>
explicit tvec4(A s1, const tvec2<B>& v, C s2);
explicit tvec4(A const & s1, tvec2<B> const & v, C const & s2);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B, typename C>
explicit tvec4(A s1, B s2, const tvec2<C>& v);
explicit tvec4(A const & s1, B const & s2, tvec2<C> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec4(const tvec3<A>& v, B s);
explicit tvec4(tvec3<A> const & v, B const & s);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec4(A s, const tvec3<B>& v);
explicit tvec4(A const & s, tvec3<B> const & v);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename A, typename B>
explicit tvec4(const tvec2<A>& v1, const tvec2<B>& v2);
explicit tvec4(tvec2<A> const & v1, tvec2<B> const & v2);
//! Explicit conversions (From section 5.4.1 Conversion and scalar constructors of GLSL 1.30.08 specification)
template <typename U>
explicit tvec4(const tvec4<U>& v);
explicit tvec4(tvec4<U> const & v);
//////////////////////////////////////
// Unary arithmetic operators
tvec4<thalf>& operator= (tvec4<thalf> const & v);
tvec4<thalf>& operator+=(thalf s);
tvec4<thalf>& operator+=(thalf const & s);
tvec4<thalf>& operator+=(tvec4<thalf> const & v);
tvec4<thalf>& operator-=(thalf s);
tvec4<thalf>& operator-=(thalf const & s);
tvec4<thalf>& operator-=(tvec4<thalf> const & v);
tvec4<thalf>& operator*=(thalf s);
tvec4<thalf>& operator*=(thalf const & s);
tvec4<thalf>& operator*=(tvec4<thalf> const & v);
tvec4<thalf>& operator/=(thalf s);
tvec4<thalf>& operator/=(thalf const & s);
tvec4<thalf>& operator/=(tvec4<thalf> const & v);
tvec4<thalf>& operator++();
tvec4<thalf>& operator--();
@@ -397,11 +355,8 @@ namespace glm
}//namespace gtc
}//namespace glm
#define GLM_GTC_half_float namespace gtc::half_float
#ifndef GLM_GTC_GLOBAL
namespace glm {using GLM_GTC_half_float;}
#endif//GLM_GTC_GLOBAL
#include "half_float.inl"
namespace glm{using namespace gtc::half_float;}
#endif//glm_gtc_half_float

View File

@@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2005-12-21
// Updated : 2009-08-24
// Updated : 2010-02-07
// Licence : This source is under MIT licence
// File : glm/gtc/half_float.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -17,12 +17,7 @@ namespace detail{
inline tvec2<thalf>::size_type tvec2<thalf>::value_size()
{
return tvec2<thalf>::size_type(2);
}
inline bool tvec2<thalf>::is_vector()
{
return true;
return 2;
}
//////////////////////////////////////
@@ -30,15 +25,13 @@ inline bool tvec2<thalf>::is_vector()
inline thalf & tvec2<thalf>::operator[](tvec2<thalf>::size_type i)
{
assert( i >= tvec2<thalf>::size_type(0) &&
i < tvec2<thalf>::value_size());
assert(i >= tvec2<thalf>::size_type(0) && i < tvec2<thalf>::value_size());
return (&x)[i];
}
inline thalf const & tvec2<thalf>::operator[](tvec2<thalf>::size_type i) const
{
assert( i >= tvec2<thalf>::size_type(0) &&
i < tvec2<thalf>::value_size());
assert(i >= tvec2<thalf>::size_type(0) && i < tvec2<thalf>::value_size());
return (&x)[i];
}
@@ -50,7 +43,10 @@ inline tvec2<thalf>::tvec2() :
y(thalf(0.f))
{}
inline tvec2<thalf>::tvec2(tvec2<thalf> const & v) :
inline tvec2<thalf>::tvec2
(
tvec2<thalf> const & v
) :
x(v.x),
y(v.y)
{}
@@ -58,12 +54,19 @@ inline tvec2<thalf>::tvec2(tvec2<thalf> const & v) :
//////////////////////////////////////
// Explicit basic constructors
inline tvec2<thalf>::tvec2(thalf s) :
inline tvec2<thalf>::tvec2
(
thalf const & s
) :
x(s),
y(s)
{}
inline tvec2<thalf>::tvec2(thalf s1, thalf s2) :
inline tvec2<thalf>::tvec2
(
thalf const & s1,
thalf const & s2
) :
x(s1),
y(s2)
{}
@@ -71,7 +74,10 @@ inline tvec2<thalf>::tvec2(thalf s1, thalf s2) :
//////////////////////////////////////
// Swizzle constructors
inline tvec2<thalf>::tvec2(tref2<thalf> const & r) :
inline tvec2<thalf>::tvec2
(
tref2<thalf> const & r
) :
x(r.x),
y(r.y)
{}
@@ -80,13 +86,20 @@ inline tvec2<thalf>::tvec2(tref2<thalf> const & r) :
// Convertion scalar constructors
template <typename U>
inline tvec2<thalf>::tvec2(U x) :
inline tvec2<thalf>::tvec2
(
U const & x
) :
x(thalf(x)),
y(thalf(x))
{}
template <typename U, typename V>
inline tvec2<thalf>::tvec2(U x, V y) :
inline tvec2<thalf>::tvec2
(
U const & x,
V const & y
) :
x(thalf(x)),
y(thalf(y))
{}
@@ -95,19 +108,28 @@ inline tvec2<thalf>::tvec2(U x, V y) :
// Convertion vector constructors
template <typename U>
inline tvec2<thalf>::tvec2(tvec2<U> const & v) :
inline tvec2<thalf>::tvec2
(
tvec2<U> const & v
) :
x(thalf(v.x)),
y(thalf(v.y))
{}
template <typename U>
inline tvec2<thalf>::tvec2(tvec3<U> const & v) :
inline tvec2<thalf>::tvec2
(
tvec3<U> const & v
) :
x(thalf(v.x)),
y(thalf(v.y))
{}
template <typename U>
inline tvec2<thalf>::tvec2(tvec4<U> const & v) :
inline tvec2<thalf>::tvec2
(
tvec4<U> const & v
) :
x(thalf(v.x)),
y(thalf(v.y))
{}
@@ -115,70 +137,97 @@ inline tvec2<thalf>::tvec2(tvec4<U> const & v) :
//////////////////////////////////////
// Unary arithmetic operators
inline tvec2<thalf>& tvec2<thalf>::operator= (tvec2<thalf> const & v)
inline tvec2<thalf> & tvec2<thalf>::operator=
(
tvec2<thalf> const & v
)
{
this->x = v.x;
this->y = v.y;
return *this;
}
inline tvec2<thalf>& tvec2<thalf>::operator+=(thalf s)
inline tvec2<thalf> & tvec2<thalf>::operator+=
(
thalf const & s
)
{
this->x += s;
this->y += s;
return *this;
}
inline tvec2<thalf>& tvec2<thalf>::operator+=(tvec2<thalf> const & v)
inline tvec2<thalf> & tvec2<thalf>::operator+=
(
tvec2<thalf> const & v
)
{
this->x += v.x;
this->y += v.y;
return *this;
}
inline tvec2<thalf>& tvec2<thalf>::operator-=(thalf s)
inline tvec2<thalf> & tvec2<thalf>::operator-=
(
thalf const & s
)
{
this->x -= s;
this->y -= s;
return *this;
}
inline tvec2<thalf>& tvec2<thalf>::operator-=(tvec2<thalf> const & v)
inline tvec2<thalf> & tvec2<thalf>::operator-=
(
tvec2<thalf> const & v
)
{
this->x -= v.x;
this->y -= v.y;
return *this;
}
inline tvec2<thalf>& tvec2<thalf>::operator*=(thalf s)
inline tvec2<thalf>& tvec2<thalf>::operator*=
(
thalf const & s
)
{
this->x *= s;
this->y *= s;
return *this;
}
inline tvec2<thalf>& tvec2<thalf>::operator*=(tvec2<thalf> const & v)
inline tvec2<thalf> & tvec2<thalf>::operator*=
(
tvec2<thalf> const & v
)
{
this->x *= v.x;
this->y *= v.y;
return *this;
}
inline tvec2<thalf>& tvec2<thalf>::operator/=(thalf s)
inline tvec2<thalf> & tvec2<thalf>::operator/=
(
thalf const & s
)
{
this->x /= s;
this->y /= s;
return *this;
}
inline tvec2<thalf>& tvec2<thalf>::operator/=(tvec2<thalf> const & v)
inline tvec2<thalf> & tvec2<thalf>::operator/=
(
tvec2<thalf> const & v
)
{
this->x /= v.x;
this->y /= v.y;
return *this;
}
inline tvec2<thalf>& tvec2<thalf>::operator++()
inline tvec2<thalf> & tvec2<thalf>::operator++()
{
++this->x;
++this->y;
@@ -236,29 +285,28 @@ inline tref2<thalf> tvec2<thalf>::swizzle(comp x, comp y)
inline tvec3<thalf>::size_type tvec3<thalf>::value_size()
{
return tvec3<thalf>::size_type(3);
}
inline bool tvec3<thalf>::is_vector()
{
return true;
return 3;
}
//////////////////////////////////////
// Accesses
inline thalf & tvec3<thalf>::operator[](tvec3<thalf>::size_type i)
inline thalf & tvec3<thalf>::operator[]
(
tvec3<thalf>::size_type i
)
{
assert( i >= tvec3<thalf>::size_type(0) &&
i < tvec3<thalf>::value_size());
assert(i >= tvec3<thalf>::size_type(0) && i < tvec3<thalf>::value_size());
return (&x)[i];
}
inline thalf const & tvec3<thalf>::operator[](tvec3<thalf>::size_type i) const
inline thalf const & tvec3<thalf>::operator[]
(
tvec3<thalf>::size_type i
) const
{
assert( i >= tvec3<thalf>::size_type(0) &&
i < tvec3<thalf>::value_size());
assert(i >= tvec3<thalf>::size_type(0) && i < tvec3<thalf>::value_size());
return (&x)[i];
}
@@ -272,7 +320,10 @@ inline tvec3<thalf>::tvec3() :
z(thalf(0))
{}
inline tvec3<thalf>::tvec3(tvec3<thalf> const & v) :
inline tvec3<thalf>::tvec3
(
tvec3<thalf> const & v
) :
x(v.x),
y(v.y),
z(v.z)
@@ -281,13 +332,21 @@ inline tvec3<thalf>::tvec3(tvec3<thalf> const & v) :
//////////////////////////////////////
// Explicit basic constructors
inline tvec3<thalf>::tvec3(thalf s) :
inline tvec3<thalf>::tvec3
(
thalf const & s
) :
x(s),
y(s),
z(s)
{}
inline tvec3<thalf>::tvec3(thalf s0, thalf s1, thalf s2) :
inline tvec3<thalf>::tvec3
(
thalf const & s0,
thalf const & s1,
thalf const & s2
) :
x(s0),
y(s1),
z(s2)
@@ -296,7 +355,10 @@ inline tvec3<thalf>::tvec3(thalf s0, thalf s1, thalf s2) :
//////////////////////////////////////
// Swizzle constructors
inline tvec3<thalf>::tvec3(tref3<thalf> const & r) :
inline tvec3<thalf>::tvec3
(
tref3<thalf> const & r
) :
x(r.x),
y(r.y),
z(r.z)
@@ -306,14 +368,22 @@ inline tvec3<thalf>::tvec3(tref3<thalf> const & r) :
// Convertion scalar constructors
template <typename U>
inline tvec3<thalf>::tvec3(U x) :
inline tvec3<thalf>::tvec3
(
U const & x
) :
x(thalf(x)),
y(thalf(x)),
z(thalf(x))
{}
template <typename A, typename B, typename C>
inline tvec3<thalf>::tvec3(A x, B y, C z) :
inline tvec3<thalf>::tvec3
(
A const & x,
B const & y,
C const & z
) :
x(thalf(x)),
y(thalf(y)),
z(thalf(z))
@@ -323,28 +393,42 @@ inline tvec3<thalf>::tvec3(A x, B y, C z) :
// Convertion vector constructors
template <typename A, typename B>
inline tvec3<thalf>::tvec3(tvec2<A> const & v, B s) :
inline tvec3<thalf>::tvec3
(
tvec2<A> const & v,
B const & s
) :
x(thalf(v.x)),
y(thalf(v.y)),
z(thalf(s))
{}
template <typename A, typename B>
inline tvec3<thalf>::tvec3(A s, tvec2<B> const & v) :
inline tvec3<thalf>::tvec3
(
A const & s,
tvec2<B> const & v
) :
x(thalf(s)),
y(thalf(v.x)),
z(thalf(v.y))
{}
template <typename U>
inline tvec3<thalf>::tvec3(tvec3<U> const & v) :
inline tvec3<thalf>::tvec3
(
tvec3<U> const & v
) :
x(thalf(v.x)),
y(thalf(v.y)),
z(thalf(v.z))
{}
template <typename U>
inline tvec3<thalf>::tvec3(tvec4<U> const & v) :
inline tvec3<thalf>::tvec3
(
tvec4<U> const & v
) :
x(thalf(v.x)),
y(thalf(v.y)),
z(thalf(v.z))
@@ -353,7 +437,10 @@ inline tvec3<thalf>::tvec3(tvec4<U> const & v) :
//////////////////////////////////////
// Unary arithmetic operators
inline tvec3<thalf>& tvec3<thalf>::operator= (tvec3<thalf> const & v)
inline tvec3<thalf> & tvec3<thalf>::operator=
(
tvec3<thalf> const & v
)
{
this->x = v.x;
this->y = v.y;
@@ -361,7 +448,10 @@ inline tvec3<thalf>& tvec3<thalf>::operator= (tvec3<thalf> const & v)
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator+=(thalf s)
inline tvec3<thalf> & tvec3<thalf>::operator+=
(
thalf const & s
)
{
this->x += s;
this->y += s;
@@ -369,7 +459,10 @@ inline tvec3<thalf>& tvec3<thalf>::operator+=(thalf s)
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator+=(tvec3<thalf> const & v)
inline tvec3<thalf> & tvec3<thalf>::operator+=
(
tvec3<thalf> const & v
)
{
this->x += v.x;
this->y += v.y;
@@ -377,7 +470,10 @@ inline tvec3<thalf>& tvec3<thalf>::operator+=(tvec3<thalf> const & v)
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator-=(thalf s)
inline tvec3<thalf> & tvec3<thalf>::operator-=
(
thalf const & s
)
{
this->x -= s;
this->y -= s;
@@ -385,7 +481,10 @@ inline tvec3<thalf>& tvec3<thalf>::operator-=(thalf s)
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator-=(tvec3<thalf> const & v)
inline tvec3<thalf> & tvec3<thalf>::operator-=
(
tvec3<thalf> const & v
)
{
this->x -= v.x;
this->y -= v.y;
@@ -393,7 +492,10 @@ inline tvec3<thalf>& tvec3<thalf>::operator-=(tvec3<thalf> const & v)
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator*=(thalf s)
inline tvec3<thalf> & tvec3<thalf>::operator*=
(
thalf const & s
)
{
this->x *= s;
this->y *= s;
@@ -401,7 +503,10 @@ inline tvec3<thalf>& tvec3<thalf>::operator*=(thalf s)
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator*=(tvec3<thalf> const & v)
inline tvec3<thalf> & tvec3<thalf>::operator*=
(
tvec3<thalf> const & v
)
{
this->x *= v.x;
this->y *= v.y;
@@ -409,7 +514,10 @@ inline tvec3<thalf>& tvec3<thalf>::operator*=(tvec3<thalf> const & v)
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator/=(thalf s)
inline tvec3<thalf> & tvec3<thalf>::operator/=
(
thalf const & s
)
{
this->x /= s;
this->y /= s;
@@ -417,7 +525,10 @@ inline tvec3<thalf>& tvec3<thalf>::operator/=(thalf s)
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator/=(tvec3<thalf> const & v)
inline tvec3<thalf> & tvec3<thalf>::operator/=
(
tvec3<thalf> const & v
)
{
this->x /= v.x;
this->y /= v.y;
@@ -425,7 +536,7 @@ inline tvec3<thalf>& tvec3<thalf>::operator/=(tvec3<thalf> const & v)
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator++()
inline tvec3<thalf> & tvec3<thalf>::operator++()
{
++this->x;
++this->y;
@@ -433,7 +544,7 @@ inline tvec3<thalf>& tvec3<thalf>::operator++()
return *this;
}
inline tvec3<thalf>& tvec3<thalf>::operator--()
inline tvec3<thalf> & tvec3<thalf>::operator--()
{
--this->x;
--this->y;
@@ -486,29 +597,28 @@ inline tref3<thalf> tvec3<thalf>::swizzle(comp x, comp y, comp z)
inline tvec4<thalf>::size_type tvec4<thalf>::value_size()
{
return tvec4<thalf>::size_type(4);
}
inline bool tvec4<thalf>::is_vector()
{
return true;
return 4;
}
//////////////////////////////////////
// Accesses
inline thalf & tvec4<thalf>::operator[](tvec4<thalf>::size_type i)
inline thalf & tvec4<thalf>::operator[]
(
tvec4<thalf>::size_type i
)
{
assert( i >= tvec4<thalf>::size_type(0) &&
i < tvec4<thalf>::value_size());
assert(i >= tvec4<thalf>::size_type(0) && i < tvec4<thalf>::value_size());
return (&x)[i];
}
inline thalf const & tvec4<thalf>::operator[](tvec4<thalf>::size_type i) const
inline thalf const & tvec4<thalf>::operator[]
(
tvec4<thalf>::size_type i
) const
{
assert( i >= tvec4<thalf>::size_type(0) &&
i < tvec4<thalf>::value_size());
assert(i >= tvec4<thalf>::size_type(0) && i < tvec4<thalf>::value_size());
return (&x)[i];
}
@@ -523,7 +633,10 @@ inline tvec4<thalf>::tvec4() :
w(thalf(0))
{}
inline tvec4<thalf>::tvec4(tvec4<thalf> const & v) :
inline tvec4<thalf>::tvec4
(
tvec4<thalf> const & v
) :
x(v.x),
y(v.y),
z(v.z),
@@ -533,14 +646,23 @@ inline tvec4<thalf>::tvec4(tvec4<thalf> const & v) :
//////////////////////////////////////
// Explicit basic constructors
inline tvec4<thalf>::tvec4(thalf s) :
inline tvec4<thalf>::tvec4
(
thalf const & s
) :
x(s),
y(s),
z(s),
w(s)
{}
inline tvec4<thalf>::tvec4(thalf s1, thalf s2, thalf s3, thalf s4) :
inline tvec4<thalf>::tvec4
(
thalf const & s1,
thalf const & s2,
thalf const & s3,
thalf const & s4
) :
x(s1),
y(s2),
z(s3),
@@ -550,7 +672,10 @@ inline tvec4<thalf>::tvec4(thalf s1, thalf s2, thalf s3, thalf s4) :
//////////////////////////////////////
// Swizzle constructors
inline tvec4<thalf>::tvec4(tref4<thalf> const & r) :
inline tvec4<thalf>::tvec4
(
tref4<thalf> const & r
) :
x(r.x),
y(r.y),
z(r.z),
@@ -561,7 +686,10 @@ inline tvec4<thalf>::tvec4(tref4<thalf> const & r) :
// Convertion scalar constructors
template <typename U>
inline tvec4<thalf>::tvec4(U x) :
inline tvec4<thalf>::tvec4
(
U const & x
) :
x(thalf(x)),
y(thalf(x)),
z(thalf(x)),
@@ -569,7 +697,13 @@ inline tvec4<thalf>::tvec4(U x) :
{}
template <typename A, typename B, typename C, typename D>
inline tvec4<thalf>::tvec4(A x, B y, C z, D w) :
inline tvec4<thalf>::tvec4
(
A const & x,
B const & y,
C const & z,
D const & w
) :
x(thalf(x)),
y(thalf(y)),
z(thalf(z)),
@@ -580,7 +714,12 @@ inline tvec4<thalf>::tvec4(A x, B y, C z, D w) :
// Convertion vector constructors
template <typename A, typename B, typename C>
inline tvec4<thalf>::tvec4(const tvec2<A>& v, B s1, C s2) :
inline tvec4<thalf>::tvec4
(
tvec2<A> const & v,
B const & s1,
C const & s2
) :
x(thalf(v.x)),
y(thalf(v.y)),
z(thalf(s1)),
@@ -588,7 +727,12 @@ inline tvec4<thalf>::tvec4(const tvec2<A>& v, B s1, C s2) :
{}
template <typename A, typename B, typename C>
inline tvec4<thalf>::tvec4(A s1, const tvec2<B>& v, C s2) :
inline tvec4<thalf>::tvec4
(
A const & s1,
tvec2<B> const & v,
C const & s2
) :
x(thalf(s1)),
y(thalf(v.x)),
z(thalf(v.y)),
@@ -596,7 +740,12 @@ inline tvec4<thalf>::tvec4(A s1, const tvec2<B>& v, C s2) :
{}
template <typename A, typename B, typename C>
inline tvec4<thalf>::tvec4(A s1, B s2, const tvec2<C>& v) :
inline tvec4<thalf>::tvec4
(
A const & s1,
B const & s2,
tvec2<C> const & v
) :
x(thalf(s1)),
y(thalf(s2)),
z(thalf(v.x)),
@@ -604,7 +753,11 @@ inline tvec4<thalf>::tvec4(A s1, B s2, const tvec2<C>& v) :
{}
template <typename A, typename B>
inline tvec4<thalf>::tvec4(const tvec3<A>& v, B s) :
inline tvec4<thalf>::tvec4
(
tvec3<A> const & v,
B const & s
) :
x(thalf(v.x)),
y(thalf(v.y)),
z(thalf(v.z)),
@@ -612,7 +765,11 @@ inline tvec4<thalf>::tvec4(const tvec3<A>& v, B s) :
{}
template <typename A, typename B>
inline tvec4<thalf>::tvec4(A s, const tvec3<B>& v) :
inline tvec4<thalf>::tvec4
(
A const & s,
tvec3<B> const & v
) :
x(thalf(s)),
y(thalf(v.x)),
z(thalf(v.y)),
@@ -620,7 +777,11 @@ inline tvec4<thalf>::tvec4(A s, const tvec3<B>& v) :
{}
template <typename A, typename B>
inline tvec4<thalf>::tvec4(const tvec2<A>& v1, const tvec2<B>& v2) :
inline tvec4<thalf>::tvec4
(
tvec2<A> const & v1,
tvec2<B> const & v2
) :
x(thalf(v1.x)),
y(thalf(v1.y)),
z(thalf(v2.x)),
@@ -628,7 +789,10 @@ inline tvec4<thalf>::tvec4(const tvec2<A>& v1, const tvec2<B>& v2) :
{}
template <typename U>
inline tvec4<thalf>::tvec4(const tvec4<U>& v) :
inline tvec4<thalf>::tvec4
(
tvec4<U> const & v
) :
x(thalf(v.x)),
y(thalf(v.y)),
z(thalf(v.z)),
@@ -638,7 +802,10 @@ inline tvec4<thalf>::tvec4(const tvec4<U>& v) :
//////////////////////////////////////
// Unary arithmetic operators
inline tvec4<thalf>& tvec4<thalf>::operator= (tvec4<thalf> const & v)
inline tvec4<thalf>& tvec4<thalf>::operator=
(
tvec4<thalf> const & v
)
{
this->x = v.x;
this->y = v.y;
@@ -647,7 +814,10 @@ inline tvec4<thalf>& tvec4<thalf>::operator= (tvec4<thalf> const & v)
return *this;
}
inline tvec4<thalf>& tvec4<thalf>::operator+=(thalf s)
inline tvec4<thalf>& tvec4<thalf>::operator+=
(
thalf const & s
)
{
this->x += s;
this->y += s;
@@ -656,7 +826,10 @@ inline tvec4<thalf>& tvec4<thalf>::operator+=(thalf s)
return *this;
}
inline tvec4<thalf>& tvec4<thalf>::operator+=(tvec4<thalf> const & v)
inline tvec4<thalf>& tvec4<thalf>::operator+=
(
tvec4<thalf> const & v
)
{
this->x += v.x;
this->y += v.y;
@@ -665,7 +838,10 @@ inline tvec4<thalf>& tvec4<thalf>::operator+=(tvec4<thalf> const & v)
return *this;
}
inline tvec4<thalf>& tvec4<thalf>::operator-=(thalf s)
inline tvec4<thalf>& tvec4<thalf>::operator-=
(
thalf const & s
)
{
this->x -= s;
this->y -= s;
@@ -674,7 +850,10 @@ inline tvec4<thalf>& tvec4<thalf>::operator-=(thalf s)
return *this;
}
inline tvec4<thalf>& tvec4<thalf>::operator-=(tvec4<thalf> const & v)
inline tvec4<thalf>& tvec4<thalf>::operator-=
(
tvec4<thalf> const & v
)
{
this->x -= v.x;
this->y -= v.y;
@@ -683,7 +862,10 @@ inline tvec4<thalf>& tvec4<thalf>::operator-=(tvec4<thalf> const & v)
return *this;
}
inline tvec4<thalf>& tvec4<thalf>::operator*=(thalf s)
inline tvec4<thalf>& tvec4<thalf>::operator*=
(
thalf const & s
)
{
this->x *= s;
this->y *= s;
@@ -692,7 +874,10 @@ inline tvec4<thalf>& tvec4<thalf>::operator*=(thalf s)
return *this;
}
inline tvec4<thalf>& tvec4<thalf>::operator*=(tvec4<thalf> const & v)
inline tvec4<thalf>& tvec4<thalf>::operator*=
(
tvec4<thalf> const & v
)
{
this->x *= v.x;
this->y *= v.y;
@@ -701,7 +886,10 @@ inline tvec4<thalf>& tvec4<thalf>::operator*=(tvec4<thalf> const & v)
return *this;
}
inline tvec4<thalf>& tvec4<thalf>::operator/=(thalf s)
inline tvec4<thalf>& tvec4<thalf>::operator/=
(
thalf const & s
)
{
this->x /= s;
this->y /= s;
@@ -710,7 +898,10 @@ inline tvec4<thalf>& tvec4<thalf>::operator/=(thalf s)
return *this;
}
inline tvec4<thalf>& tvec4<thalf>::operator/=(tvec4<thalf> const & v)
inline tvec4<thalf>& tvec4<thalf>::operator/=
(
tvec4<thalf> const & v
)
{
this->x /= v.x;
this->y /= v.y;

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-04-29
// Updated : 2009-04-29
@@ -26,11 +26,8 @@ namespace matrix_operation
}//namespace gtc
}//namespace glm
#define GLM_GTC_matrix_operation namespace gtc::matrix_operation
#ifndef GLM_GTC_GLOBAL
namespace glm {using GLM_GTC_matrix_operation;}
#endif//GLM_GTC_GLOBAL
#include "matrix_operation.inl"
namespace glm{using namespace gtc::matrix_operation;}
#endif//glm_gtc_matrix_operation

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-04-29
// Updated : 2009-04-29

View File

@@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-04-29
// Updated : 2009-04-29
// Updated : 2010-02-07
// Licence : This source is under MIT License
// File : glm/gtc/matrix_projection.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -32,71 +32,68 @@ namespace glm
//! Creates a matrix for projecting two-dimensional coordinates onto the screen.
//! From GLM_GTC_matrix_projection extension.
template <typename valType>
detail::tmat4x4<valType> ortho(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top);
template <typename T>
detail::tmat4x4<T> ortho(
T const & left,
T const & right,
T const & bottom,
T const & top);
//! Creates a matrix for an orthographic parallel viewing volume.
//! From GLM_GTC_matrix_projection extension.
template <typename valType>
detail::tmat4x4<valType> ortho(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top,
valType const & zNear,
valType const & zFar);
template <typename T>
detail::tmat4x4<T> ortho(
T const & left,
T const & right,
T const & bottom,
T const & top,
T const & zNear,
T const & zFar);
//! Creates a frustum matrix.
//! From GLM_GTC_matrix_projection extension.
template <typename valType>
detail::tmat4x4<valType> frustum(
valType const & left,
valType const & right,
valType const & bottom,
valType const & top,
valType const & nearVal,
valType const & farVal);
template <typename T>
detail::tmat4x4<T> frustum(
T const & left,
T const & right,
T const & bottom,
T const & top,
T const & nearVal,
T const & farVal);
//! Creates a matrix for a symetric perspective-view frustum.
//! From GLM_GTC_matrix_projection extension.
template <typename valType>
detail::tmat4x4<valType> perspective(
valType const & fovy,
valType const & aspect,
valType const & zNear,
valType const & zFar);
template <typename T>
detail::tmat4x4<T> perspective(
T const & fovy,
T const & aspect,
T const & zNear,
T const & zFar);
//! Map the specified object coordinates (obj.x, obj.y, obj.z) into window coordinates.
//! From GLM_GTC_matrix_projection extension.
template <typename valTypeT, typename valTypeU>
detail::tvec3<valTypeT> project(
detail::tvec3<valTypeT> const & obj,
detail::tmat4x4<valTypeT> const & model,
detail::tmat4x4<valTypeT> const & proj,
detail::tvec4<valTypeU> const & viewport);
template <typename T, typename U>
detail::tvec3<T> project(
detail::tvec3<T> const & obj,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport);
//! Map the specified window coordinates (win.x, win.y, win.z) into object coordinates.
//! From GLM_GTC_matrix_projection extension.
template <typename valTypeT, typename valTypeU>
detail::tvec3<valTypeT> unProject(
detail::tvec3<valTypeT> const & win,
detail::tmat4x4<valTypeT> const & model,
detail::tmat4x4<valTypeT> const & proj,
detail::tvec4<valTypeU> const & viewport);
template <typename T, typename U>
detail::tvec3<T> unProject(
detail::tvec3<T> const & win,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport);
}//namespace matrix_projection
}//namespace gtc
}//namespace glm
#define GLM_GTC_matrix_projection namespace gtc::matrix_projection
#ifndef GLM_GTC_GLOBAL
namespace glm {using GLM_GTC_matrix_projection;}
#endif//GLM_GTC_GLOBAL
#include "matrix_projection.inl"
namespace glm{using namespace gtc::matrix_projection;}
#endif//glm_gtc_matrix_projection

View File

@@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-04-29
// Updated : 2009-04-29
// Updated : 2010-02-07
// Licence : This source is under MIT License
// File : glm/gtc/matrix_projection.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -88,43 +88,43 @@ namespace matrix_projection
return Result;
}
template <typename valTypeT, typename valTypeU>
inline detail::tvec3<valTypeT> project(
detail::tvec3<valTypeT> const & obj,
detail::tmat4x4<valTypeT> const & model,
detail::tmat4x4<valTypeT> const & proj,
detail::tvec4<valTypeU> const & viewport)
template <typename T, typename U>
inline detail::tvec3<T> project(
detail::tvec3<T> const & obj,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport)
{
detail::tvec4<valTypeT> tmp = detail::tvec4<valTypeT>(obj, valTypeT(1));
detail::tvec4<T> tmp = detail::tvec4<T>(obj, T(1));
tmp = model * tmp;
tmp = proj * tmp;
tmp /= tmp.w;
tmp = tmp * valTypeT(0.5) + valTypeT(0.5);
tmp[0] = tmp[0] * valTypeT(viewport[2]) + valTypeT(viewport[0]);
tmp[1] = tmp[1] * valTypeT(viewport[3]) + valTypeT(viewport[1]);
tmp = tmp * T(0.5) + T(0.5);
tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]);
tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]);
return detail::tvec3<valTypeT>(tmp);
return detail::tvec3<T>(tmp);
}
template <typename valTypeT, typename valTypeU>
inline detail::tvec3<valTypeT> unProject(
detail::tvec3<valTypeT> const & win,
detail::tmat4x4<valTypeT> const & model,
detail::tmat4x4<valTypeT> const & proj,
detail::tvec4<valTypeU> const & viewport)
template <typename T, typename U>
inline detail::tvec3<T> unProject(
detail::tvec3<T> const & win,
detail::tmat4x4<T> const & model,
detail::tmat4x4<T> const & proj,
detail::tvec4<U> const & viewport)
{
detail::tmat4x4<valTypeT> inverse = glm::inverse(proj * model);
detail::tmat4x4<T> inverse = glm::inverse(proj * model);
detail::tvec4<valTypeT> tmp = detail::tvec4<valTypeT>(win, valTypeT(1));
tmp.x = (tmp.x - valTypeT(viewport[0])) / valTypeT(viewport[2]);
tmp.y = (tmp.y - valTypeT(viewport[1])) / valTypeT(viewport[3]);
tmp = tmp * valTypeT(2) - valTypeT(1);
detail::tvec4<T> tmp = detail::tvec4<T>(win, T(1));
tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]);
tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]);
tmp = tmp * T(2) - T(1);
detail::tvec4<valTypeT> obj = inverse * tmp;
detail::tvec4<T> obj = inverse * tmp;
obj /= obj.w;
return detail::tvec3<valTypeT>(obj);
return detail::tvec3<T>(obj);
}
}//namespace matrix_projection

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-04-29
// Updated : 2009-04-29
@@ -32,35 +32,32 @@ namespace glm
//! Builds a translation 4 * 4 matrix created from a vector of 3 components.
//! From GLM_GTC_matrix_transform extension.
template <typename valType>
detail::tmat4x4<valType> translate(
detail::tmat4x4<valType> const & m,
detail::tvec3<valType> const & v);
template <typename T>
detail::tmat4x4<T> translate(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v);
//! Builds a rotation 4 * 4 matrix created from an axis vector and an angle expressed in degrees.
//! From GLM_GTC_matrix_transform extension.
template <typename valType>
detail::tmat4x4<valType> rotate(
detail::tmat4x4<valType> const & m,
valType const & angle,
detail::tvec3<valType> const & v);
template <typename T>
detail::tmat4x4<T> rotate(
detail::tmat4x4<T> const & m,
T const & angle,
detail::tvec3<T> const & v);
//! Builds a scale 4 * 4 matrix created from 3 scalars.
//! From GLM_GTC_matrix_transform extension.
template <typename valType>
detail::tmat4x4<valType> scale(
detail::tmat4x4<valType> const & m,
detail::tvec3<valType> const & v);
template <typename T>
detail::tmat4x4<T> scale(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v);
}//namespace matrix_transform
}//namespace gtc
}//namespace glm
#define GLM_GTC_matrix_transform namespace gtc::matrix_transform
#ifndef GLM_GTC_GLOBAL
namespace glm {using GLM_GTC_matrix_transform;}
#endif//GLM_GTC_GLOBAL
#include "matrix_transform.inl"
namespace glm{using namespace gtc::matrix_transform;}
#endif//glm_gtc_matrix_transform

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-04-29
// Updated : 2009-04-29
@@ -11,31 +11,35 @@ namespace glm{
namespace gtc{
namespace matrix_transform
{
template <typename valType>
inline detail::tmat4x4<valType> translate(
detail::tmat4x4<valType> const & m,
detail::tvec3<valType> const & v)
template <typename T>
inline detail::tmat4x4<T> translate
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
detail::tmat4x4<valType> Result(m);
detail::tmat4x4<T> Result(m);
Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3];
return Result;
}
template <typename valType>
inline detail::tmat4x4<valType> rotate(
detail::tmat4x4<valType> const & m,
valType const & angle,
detail::tvec3<valType> const & v)
template <typename T>
inline detail::tmat4x4<T> rotate
(
detail::tmat4x4<T> const & m,
T const & angle,
detail::tvec3<T> const & v
)
{
valType a = radians(angle);
valType c = cos(a);
valType s = sin(a);
T a = radians(angle);
T c = cos(a);
T s = sin(a);
detail::tvec3<valType> axis = normalize(v);
detail::tvec3<T> axis = normalize(v);
detail::tvec3<valType> temp = (valType(1) - c) * axis;
detail::tvec3<T> temp = (T(1) - c) * axis;
detail::tmat4x4<valType> Rotate(detail::tmat4x4<valType>::null);
detail::tmat4x4<T> Rotate(detail::tmat4x4<T>::null);
Rotate[0][0] = c + temp[0] * axis[0];
Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2];
Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1];
@@ -48,7 +52,7 @@ namespace matrix_transform
Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0];
Rotate[2][2] = c + temp[2] * axis[2];
detail::tmat4x4<valType> Result(detail::tmat4x4<valType>::null);
detail::tmat4x4<T> Result(detail::tmat4x4<T>::null);
Result[0] = m[0] * Rotate[0][0] + m[1] * Rotate[0][1] + m[2] * Rotate[0][2];
Result[1] = m[0] * Rotate[1][0] + m[1] * Rotate[1][1] + m[2] * Rotate[1][2];
Result[2] = m[0] * Rotate[2][0] + m[1] * Rotate[2][1] + m[2] * Rotate[2][2];
@@ -56,12 +60,14 @@ namespace matrix_transform
return Result;
}
template <typename valType>
inline detail::tmat4x4<valType> scale(
detail::tmat4x4<valType> const & m,
detail::tvec3<valType> const & v)
template <typename T>
inline detail::tmat4x4<T> scale
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
detail::tmat4x4<valType> Result(detail::tmat4x4<valType>::null);
detail::tmat4x4<T> Result(detail::tmat4x4<T>::null);
Result[0] = m[0] * v[0];
Result[1] = m[1] * v[1];
Result[2] = m[2] * v[2];
@@ -69,13 +75,15 @@ namespace matrix_transform
return Result;
}
template <typename valType>
inline detail::tmat4x4<valType> translate_slow(
detail::tmat4x4<valType> const & m,
detail::tvec3<valType> const & v)
template <typename T>
inline detail::tmat4x4<T> translate_slow
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
detail::tmat4x4<valType> Result(valType(1));
Result[3] = detail::tvec4<valType>(v, valType(1));
detail::tmat4x4<T> Result(T(1));
Result[3] = detail::tvec4<T>(v, T(1));
return m * Result;
//detail::tmat4x4<valType> Result(m);
@@ -87,18 +95,20 @@ namespace matrix_transform
//return Result;
}
template <typename valType>
inline detail::tmat4x4<valType> rotate_slow(
detail::tmat4x4<valType> const & m,
valType const & angle,
detail::tvec3<valType> const & v)
template <typename T>
inline detail::tmat4x4<T> rotate_slow
(
detail::tmat4x4<T> const & m,
T const & angle,
detail::tvec3<T> const & v
)
{
valType a = radians(angle);
valType c = cos(a);
valType s = sin(a);
detail::tmat4x4<valType> Result;
T a = radians(angle);
T c = cos(a);
T s = sin(a);
detail::tmat4x4<T> Result;
detail::tvec3<valType> axis = normalize(v);
detail::tvec3<T> axis = normalize(v);
Result[0][0] = c + (1 - c) * axis.x * axis.x;
Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z;
@@ -115,16 +125,18 @@ namespace matrix_transform
Result[2][2] = c + (1 - c) * axis.z * axis.z;
Result[2][3] = 0;
Result[3] = detail::tvec4<valType>(0, 0, 0, 1);
Result[3] = detail::tvec4<T>(0, 0, 0, 1);
return m * Result;
}
template <typename valType>
inline detail::tmat4x4<valType> scale_slow(
detail::tmat4x4<valType> const & m,
detail::tvec3<valType> const & v)
template <typename T>
inline detail::tmat4x4<T> scale_slow
(
detail::tmat4x4<T> const & m,
detail::tvec3<T> const & v
)
{
detail::tmat4x4<valType> Result(valType(1));
detail::tmat4x4<T> Result(T(1));
Result[0][0] = v.x;
Result[1][1] = v.y;
Result[2][2] = v.z;

View File

@@ -1,13 +1,15 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-05-21
// Updated : 2009-06-04
// Updated : 2010-02-04
// Licence : This source is under MIT License
// File : glm/gtc/quaternion.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
// - GLM_GTC_half_float
// - GLM_GTC_double_float
///////////////////////////////////////////////////////////////////////////////////////////////////
// ToDo:
// - Study constructors with angles and axis
@@ -19,6 +21,8 @@
// Dependency:
#include "../glm.hpp"
#include "../gtc/half_float.hpp"
#include "../gtc/double_float.hpp"
namespace glm
{
@@ -30,71 +34,82 @@ namespace glm
{
//! \brief Template for quaternion.
//! From GLM_GTC_quaternion extension.
template <typename valType>
class tquat
template <typename T>
struct tquat// : public genType<T, tquat>
{
typedef T value_type;
public:
valType x, y, z, w;
value_type x, y, z, w;
// Constructors
tquat();
explicit tquat(valType const & s, tvec3<valType> const & v);
explicit tquat(valType const & w, valType const & x, valType const & y, valType const & z);
explicit tquat(
value_type const & s,
tvec3<T> const & v);
explicit tquat(
value_type const & w,
value_type const & x,
value_type const & y,
value_type const & z);
// Convertions
//explicit tquat(valType const & pitch, valType const & yaw, valType const & roll);
//! pitch, yaw, roll
explicit tquat(tvec3<valType> const & eulerAngles);
explicit tquat(tmat3x3<valType> const & m);
explicit tquat(tmat4x4<valType> const & m);
explicit tquat(
tvec3<T> const & eulerAngles);
explicit tquat(
tmat3x3<T> const & m);
explicit tquat(
tmat4x4<T> const & m);
// Accesses
valType& operator[](int i);
valType operator[](int i) const;
value_type & operator[](int i);
value_type const & operator[](int i) const;
// Operators
tquat<valType>& operator*=(valType const & s);
tquat<valType>& operator/=(valType const & s);
tquat<T> & operator*=(value_type const & s);
tquat<T> & operator/=(value_type const & s);
};
template <typename valType>
detail::tquat<valType> operator- (
detail::tquat<valType> const & q);
template <typename T>
detail::tquat<T> operator- (
detail::tquat<T> const & q);
template <typename valType>
detail::tvec3<valType> operator* (
detail::tquat<valType> const & q,
detail::tvec3<valType> const & v);
template <typename T>
detail::tvec3<T> operator* (
detail::tquat<T> const & q,
detail::tvec3<T> const & v);
template <typename valType>
detail::tvec3<valType> operator* (
detail::tvec3<valType> const & v,
detail::tquat<valType> const & q);
template <typename T>
detail::tvec3<T> operator* (
detail::tvec3<T> const & v,
detail::tquat<T> const & q);
template <typename valType>
detail::tvec4<valType> operator* (
detail::tquat<valType> const & q,
detail::tvec4<valType> const & v);
template <typename T>
detail::tvec4<T> operator* (
detail::tquat<T> const & q,
detail::tvec4<T> const & v);
template <typename valType>
detail::tvec4<valType> operator* (
detail::tvec4<valType> const & v,
detail::tquat<valType> const & q);
template <typename T>
detail::tvec4<T> operator* (
detail::tvec4<T> const & v,
detail::tquat<T> const & q);
template <typename valType>
detail::tquat<valType> operator* (
detail::tquat<valType> const & q,
valType const & s);
template <typename T>
detail::tquat<T> operator* (
detail::tquat<T> const & q,
typename detail::tquat<T>::value_type const & s);
template <typename valType>
detail::tquat<valType> operator* (
valType const & s,
detail::tquat<valType> const & q);
template <typename T>
detail::tquat<T> operator* (
typename detail::tquat<T>::value_type const & s,
detail::tquat<T> const & q);
template <typename valType>
detail::tquat<valType> operator/ (
detail::tquat<valType> const & q,
valType const & s);
template <typename T>
detail::tquat<T> operator/ (
detail::tquat<T> const & q,
typename detail::tquat<T>::value_type const & s);
} //namespace detail
@@ -104,95 +119,104 @@ namespace glm
{
//! Returns the length of the quaternion x.
//! From GLM_GTC_quaternion extension.
template <typename valType>
valType length(
detail::tquat<valType> const & q);
template <typename T>
typename detail::tquat<T>::value_type length(
detail::tquat<T> const & q);
//! Returns the normalized quaternion of from x.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tquat<valType> normalize(
detail::tquat<valType> const & q);
template <typename T>
detail::tquat<T> normalize(
detail::tquat<T> const & q);
//! Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
//! From GLM_GTC_quaternion extension.
template <typename valType>
valType dot(
detail::tquat<valType> const & q1,
detail::tquat<valType> const & q2);
template <typename T>
typename detail::tquat<T>::value_type dot(
detail::tquat<T> const & q1,
detail::tquat<T> const & q2);
//! Returns the cross product of q1 and q2.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tquat<valType> cross(
detail::tquat<valType> const & q1,
detail::tquat<valType> const & q2);
template <typename T>
detail::tquat<T> cross(
detail::tquat<T> const & q1,
detail::tquat<T> const & q2);
//! Returns a LERP interpolated quaternion of x and y according a.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tquat<valType> mix(
detail::tquat<valType> const & x,
detail::tquat<valType> const & y,
valType const & a);
template <typename T>
detail::tquat<T> mix(
detail::tquat<T> const & x,
detail::tquat<T> const & y,
typename detail::tquat<T>::value_type const & a);
//! Returns the q conjugate.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tquat<valType> conjugate(
detail::tquat<valType> const & q);
template <typename T>
detail::tquat<T> conjugate(
detail::tquat<T> const & q);
//! Returns the q inverse.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tquat<valType> inverse(
detail::tquat<valType> const & q);
template <typename T>
detail::tquat<T> inverse(
detail::tquat<T> const & q);
//! Rotates a quaternion from an vector of 3 components axis and an angle expressed in degrees.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tquat<valType> rotate(
detail::tquat<valType> const & q,
valType const & angle,
detail::tvec3<valType> const & v);
template <typename T>
detail::tquat<T> rotate(
detail::tquat<T> const & q,
typename detail::tquat<T>::value_type const & angle,
detail::tvec3<T> const & v);
//! Converts a quaternion to a 3 * 3 matrix.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tmat3x3<valType> mat3_cast(
detail::tquat<valType> const & x);
template <typename T>
detail::tmat3x3<T> mat3_cast(
detail::tquat<T> const & x);
//! Converts a quaternion to a 4 * 4 matrix.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tmat4x4<valType> mat4_cast(
detail::tquat<valType> const & x);
template <typename T>
detail::tmat4x4<T> mat4_cast(
detail::tquat<T> const & x);
//! Converts a 3 * 3 matrix to a quaternion.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tquat<valType> quat_cast(
detail::tmat3x3<valType> const & x);
template <typename T>
detail::tquat<T> quat_cast(
detail::tmat3x3<T> const & x);
//! Converts a 4 * 4 matrix to a quaternion.
//! From GLM_GTC_quaternion extension.
template <typename valType>
detail::tquat<valType> quat_cast(
detail::tmat4x4<valType> const & x);
template <typename T>
detail::tquat<T> quat_cast(
detail::tmat4x4<T> const & x);
//! Quaternion of floating-point numbers.
//! From GLM_GTC_quaternion extension.
typedef detail::tquat<float> quat;
//! Quaternion of half-precision floating-point numbers.
//! From GLM_GTC_quaternion extension.
typedef detail::tquat<detail::thalf> hquat;
//! Quaternion of single-precision floating-point numbers.
//! From GLM_GTC_quaternion extension.
typedef detail::tquat<float> fquat;
//! Quaternion of double-precision floating-point numbers.
//! From GLM_GTC_quaternion extension.
typedef detail::tquat<double> dquat;
}//namespace quaternion
}//namespace gtc
} //namespace glm
#define GLM_GTC_quaternion namespace gtc::quaternion
#ifndef GLM_GTC_GLOBAL
namespace glm {using GLM_GTC_quaternion;}
#endif//GLM_GTC_GLOBAL
#include "quaternion.inl"
namespace glm{using namespace gtc::quaternion;}
#endif//glm_gtc_quaternion

View File

@@ -1,8 +1,8 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-05-21
// Updated : 2009-06-04
// Updated : 2010-02-04
// Licence : This source is under MIT License
// File : glm/gtc/quaternion.inl
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -12,19 +12,19 @@
namespace glm{
namespace detail{
template <typename valType>
inline tquat<valType>::tquat() :
template <typename T>
inline tquat<T>::tquat() :
x(0),
y(0),
z(0),
w(1)
{}
template <typename valType>
inline tquat<valType>::tquat
template <typename T>
inline tquat<T>::tquat
(
valType const & s,
tvec3<valType> const & v
value_type const & s,
tvec3<T> const & v
) :
x(v.x),
y(v.y),
@@ -32,13 +32,13 @@ namespace detail{
w(s)
{}
template <typename valType>
inline tquat<valType>::tquat
template <typename T>
inline tquat<T>::tquat
(
valType const & w,
valType const & x,
valType const & y,
valType const & z
value_type const & w,
value_type const & x,
value_type const & y,
value_type const & z
) :
x(x),
y(y),
@@ -67,14 +67,14 @@ namespace detail{
// this->z = c.x * c.y * s.z - s.x * s.y * c.z;
//}
template <typename valType>
inline tquat<valType>::tquat
template <typename T>
inline tquat<T>::tquat
(
tvec3<valType> const & eulerAngle
tvec3<T> const & eulerAngle
)
{
tvec3<valType> c = glm::cos(eulerAngle * valType(0.5));
tvec3<valType> s = glm::sin(eulerAngle * valType(0.5));
tvec3<T> c = glm::cos(eulerAngle * value_type(0.5));
tvec3<T> s = glm::sin(eulerAngle * value_type(0.5));
this->w = c.x * c.y * c.z + s.x * s.y * s.z;
this->x = s.x * c.y * c.z - c.x * s.y * s.z;
@@ -82,19 +82,19 @@ namespace detail{
this->z = c.x * c.y * s.z - s.x * s.y * c.z;
}
template <typename valType>
inline tquat<valType>::tquat
template <typename T>
inline tquat<T>::tquat
(
tmat3x3<valType> const & m
tmat3x3<T> const & m
)
{
*this = toQuat(m);
}
template <typename valType>
inline tquat<valType>::tquat
template <typename T>
inline tquat<T>::tquat
(
tmat4x4<valType> const & m
tmat4x4<T> const & m
)
{
*this = toQuat(m);
@@ -103,14 +103,14 @@ namespace detail{
//////////////////////////////////////////////////////////////
// tquat<T> accesses
template <typename valType>
inline valType& tquat<valType>::operator [] (int i)
template <typename T>
inline typename tquat<T>::value_type & tquat<T>::operator [] (int i)
{
return (&x)[i];
}
template <typename valType>
inline valType tquat<valType>::operator [] (int i) const
template <typename T>
inline typename tquat<T>::value_type const & tquat<T>::operator [] (int i) const
{
return (&x)[i];
}
@@ -118,10 +118,10 @@ namespace detail{
//////////////////////////////////////////////////////////////
// tquat<valType> operators
template <typename valType>
inline tquat<valType>& tquat<valType>::operator *=
template <typename T>
inline tquat<T> & tquat<T>::operator *=
(
valType const & s
value_type const & s
)
{
this->w *= s;
@@ -131,10 +131,10 @@ namespace detail{
return *this;
}
template <typename valType>
inline tquat<valType>& tquat<valType>::operator /=
template <typename T>
inline tquat<T> & tquat<T>::operator /=
(
valType const & s
value_type const & s
)
{
this->w /= s;
@@ -147,92 +147,94 @@ namespace detail{
//////////////////////////////////////////////////////////////
// tquat<valType> external operators
template <typename valType>
inline detail::tquat<valType> operator-
template <typename T>
inline detail::tquat<T> operator-
(
detail::tquat<valType> const & q
detail::tquat<T> const & q
)
{
return detail::tquat<valType>(-q.w, -q.x, -q.y, -q.z);
return detail::tquat<T>(-q.w, -q.x, -q.y, -q.z);
}
// Transformation
template <typename valType>
inline detail::tvec3<valType> operator*
template <typename T>
inline detail::tvec3<T> operator*
(
detail::tquat<valType> const & q,
detail::tvec3<valType> const & v
detail::tquat<T> const & q,
detail::tvec3<T> const & v
)
{
detail::tvec3<valType> uv, uuv;
detail::tvec3<valType> QuatVector(q.x, q.y, q.z);
typename detail::tquat<T>::value_type Two(2);
detail::tvec3<T> uv, uuv;
detail::tvec3<T> QuatVector(q.x, q.y, q.z);
uv = glm::cross(QuatVector, v);
uuv = glm::cross(QuatVector, uv);
uv *= (valType(2) * q.w);
uuv *= valType(2);
uv *= (Two * q.w);
uuv *= Two;
return v + uv + uuv;
}
template <typename valType>
inline detail::tvec3<valType> operator*
template <typename T>
inline detail::tvec3<T> operator*
(
detail::tvec3<valType> const & v,
detail::tquat<valType> const & q
detail::tvec3<T> const & v,
detail::tquat<T> const & q
)
{
return gtc::quaternion::inverse(q) * v;
}
template <typename valType>
inline detail::tvec4<valType> operator*
template <typename T>
inline detail::tvec4<T> operator*
(
detail::tquat<valType> const & q,
detail::tvec4<valType> const & v
detail::tquat<T> const & q,
detail::tvec4<T> const & v
)
{
return detail::tvec4<valType>(q * detail::tvec3<valType>(v), v.w);
return detail::tvec4<T>(q * detail::tvec3<T>(v), v.w);
}
template <typename valType>
inline detail::tvec4<valType> operator*
template <typename T>
inline detail::tvec4<T> operator*
(
detail::tvec4<valType> const & v,
detail::tquat<valType> const & q
detail::tvec4<T> const & v,
detail::tquat<T> const & q
)
{
return gtc::quaternion::inverse(q) * v;
}
template <typename valType>
inline detail::tquat<valType> operator*
template <typename T>
inline detail::tquat<T> operator*
(
detail::tquat<valType> const & q,
valType const & s
detail::tquat<T> const & q,
typename detail::tquat<T>::value_type const & s
)
{
return detail::tquat<valType>(
return detail::tquat<T>(
q.w * s, q.x * s, q.y * s, q.z * s);
}
template <typename valType>
inline detail::tquat<valType> operator*
template <typename T>
inline detail::tquat<T> operator*
(
valType const & s,
detail::tquat<valType> const & q
typename detail::tquat<T>::value_type const & s,
detail::tquat<T> const & q
)
{
return q * s;
}
template <typename valType>
inline detail::tquat<valType> operator/
template <typename T>
inline detail::tquat<T> operator/
(
detail::tquat<valType> const & q,
valType const & s
detail::tquat<T> const & q,
typename detail::tquat<T>::value_type const & s
)
{
return detail::tquat<valType>(
return detail::tquat<T>(
q.w / s, q.x / s, q.y / s, q.z / s);
}
@@ -242,13 +244,13 @@ namespace gtc{
namespace quaternion{
////////////////////////////////////////////////////////
template <typename valType>
inline valType length
template <typename T>
inline typename detail::tquat<T>::value_type length
(
detail::tquat<valType> const & q
detail::tquat<T> const & q
)
{
return static_cast<valType>(glm::sqrt(dot(q, q)));
return glm::sqrt(dot(q, q));
}
template <typename T>
@@ -257,31 +259,31 @@ namespace quaternion{
detail::tquat<T> const & q
)
{
T len = static_cast<T>(length(q));
if(len <= 0) // Problem
typename detail::tquat<T>::value_type len = length(q);
if(len <= typename detail::tquat<T>::value_type(0)) // Problem
return detail::tquat<T>(1, 0, 0, 0);
T oneOverLen = 1 / len;
typename detail::tquat<T>::value_type oneOverLen = typename detail::tquat<T>::value_type(1) / len;
return detail::tquat<T>(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen);
}
template <typename valType>
inline valType dot
template <typename T>
inline typename detail::tquat<T>::value_type dot
(
detail::tquat<valType> const & q1,
detail::tquat<valType> const & q2
detail::tquat<T> const & q1,
detail::tquat<T> const & q2
)
{
return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
}
template <typename valType>
inline detail::tquat<valType> cross
template <typename T>
inline detail::tquat<T> cross
(
detail::tquat<valType> const & q1,
detail::tquat<valType> const & q2
detail::tquat<T> const & q1,
detail::tquat<T> const & q2
)
{
return detail::tquat<valType>(
return detail::tquat<T>(
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z,
q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z,
@@ -293,15 +295,15 @@ namespace quaternion{
(
detail::tquat<T> const & x,
detail::tquat<T> const & y,
T const & a
typename detail::tquat<T>::value_type const & a
)
{
if(a <= T(0)) return x;
if(a >= T(1)) return y;
if(a <= typename detail::tquat<T>::value_type(0)) return x;
if(a >= typename detail::tquat<T>::value_type(1)) return y;
float fCos = dot(x, y);
detail::tquat<T> y2(y); //BUG!!! tquat<T> y2;
if(fCos < T(0))
if(fCos < typename detail::tquat<T>::value_type(0))
{
y2 = -y;
fCos = -fCos;
@@ -309,18 +311,18 @@ namespace quaternion{
//if(fCos > 1.0f) // problem
float k0, k1;
if(fCos > T(0.9999))
if(fCos > typename detail::tquat<T>::value_type(0.9999))
{
k0 = T(1) - a;
k1 = T(0) + a; //BUG!!! 1.0f + a;
k0 = typename detail::tquat<T>::value_type(1) - a;
k1 = typename detail::tquat<T>::value_type(0) + a; //BUG!!! 1.0f + a;
}
else
{
T fSin = sqrt(T(1) - fCos * fCos);
T fAngle = atan(fSin, fCos);
T fOneOverSin = T(1) / fSin;
k0 = sin((T(1) - a) * fAngle) * fOneOverSin;
k1 = sin((T(0) + a) * fAngle) * fOneOverSin;
typename detail::tquat<T>::value_type fSin = sqrt(T(1) - fCos * fCos);
typename detail::tquat<T>::value_type fAngle = atan(fSin, fCos);
typename detail::tquat<T>::value_type fOneOverSin = T(1) / fSin;
k0 = sin((typename detail::tquat<T>::value_type(1) - a) * fAngle) * fOneOverSin;
k1 = sin((typename detail::tquat<T>::value_type(0) + a) * fAngle) * fOneOverSin;
}
return detail::tquat<T>(
@@ -330,57 +332,57 @@ namespace quaternion{
k0 * x.z + k1 * y2.z);
}
template <typename valType>
inline detail::tquat<valType> conjugate
template <typename T>
inline detail::tquat<T> conjugate
(
detail::tquat<valType> const & q
detail::tquat<T> const & q
)
{
return detail::tquat<valType>(q.w, -q.x, -q.y, -q.z);
return detail::tquat<T>(q.w, -q.x, -q.y, -q.z);
}
template <typename valType>
inline detail::tquat<valType> inverse
template <typename T>
inline detail::tquat<T> inverse
(
detail::tquat<valType> const & q
detail::tquat<T> const & q
)
{
return gtc::quaternion::conjugate(q) / gtc::quaternion::length(q);
}
template <typename valType>
inline detail::tquat<valType> rotate
template <typename T>
inline detail::tquat<T> rotate
(
detail::tquat<valType> const & q,
valType const & angle,
detail::tvec3<valType> const & v
detail::tquat<T> const & q,
typename detail::tquat<T>::value_type const & angle,
detail::tvec3<T> const & v
)
{
detail::tvec3<valType> Tmp = v;
detail::tvec3<T> Tmp = v;
// Axis of rotation must be normalised
valType len = glm::core::function::geometric::length(Tmp);
if(abs(len - valType(1)) > valType(0.001))
typename detail::tquat<T>::value_type len = glm::core::function::geometric::length(Tmp);
if(abs(len - typename detail::tquat<T>::value_type(1)) > typename detail::tquat<T>::value_type(0.001))
{
valType oneOverLen = valType(1) / len;
T oneOverLen = T(1) / len;
Tmp.x *= oneOverLen;
Tmp.y *= oneOverLen;
Tmp.z *= oneOverLen;
}
valType AngleRad = radians(angle);
valType fSin = sin(AngleRad * valType(0.5));
typename detail::tquat<T>::value_type AngleRad = radians(angle);
typename detail::tquat<T>::value_type fSin = sin(AngleRad * T(0.5));
return gtc::quaternion::cross(q, detail::tquat<valType>(cos(AngleRad * valType(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));
}
template <typename valType>
inline detail::tmat3x3<valType> mat3_cast
template <typename T>
inline detail::tmat3x3<T> mat3_cast
(
detail::tquat<valType> const & q
detail::tquat<T> const & q
)
{
detail::tmat3x3<valType> Result(valType(1));
detail::tmat3x3<T> Result(typename detail::tquat<T>::value_type(1));
Result[0][0] = 1 - 2 * q.y * q.y - 2 * q.z * q.z;
Result[0][1] = 2 * q.x * q.y + 2 * q.w * q.z;
Result[0][2] = 2 * q.x * q.z - 2 * q.w * q.y;
@@ -395,13 +397,13 @@ namespace quaternion{
return Result;
}
template <typename valType>
inline detail::tmat4x4<valType> mat4_cast
template <typename T>
inline detail::tmat4x4<T> mat4_cast
(
detail::tquat<valType> const & q
detail::tquat<T> const & q
)
{
return detail::tmat4x4<valType>(mat3_cast(q));
return detail::tmat4x4<T>(mat3_cast(q));
}
template <typename T>
@@ -410,13 +412,13 @@ namespace quaternion{
detail::tmat3x3<T> const & m
)
{
T fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2];
T fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2];
T fourZSquaredMinus1 = m[2][2] - m[0][0] - m[1][1];
T fourWSquaredMinus1 = m[0][0] + m[1][1] + m[2][2];
typename detail::tquat<T>::value_type fourXSquaredMinus1 = m[0][0] - m[1][1] - m[2][2];
typename detail::tquat<T>::value_type fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2];
typename detail::tquat<T>::value_type fourZSquaredMinus1 = m[2][2] - m[0][0] - m[1][1];
typename detail::tquat<T>::value_type fourWSquaredMinus1 = m[0][0] + m[1][1] + m[2][2];
int biggestIndex = 0;
T fourBiggestSquaredMinus1 = fourWSquaredMinus1;
typename detail::tquat<T>::value_type fourBiggestSquaredMinus1 = fourWSquaredMinus1;
if(fourXSquaredMinus1 > fourBiggestSquaredMinus1)
{
fourBiggestSquaredMinus1 = fourXSquaredMinus1;
@@ -433,8 +435,8 @@ namespace quaternion{
biggestIndex = 3;
}
T biggestVal = sqrt(fourBiggestSquaredMinus1 + T(1)) * T(0.5);
T mult = T(0.25) / biggestVal;
typename detail::tquat<T>::value_type biggestVal = sqrt(fourBiggestSquaredMinus1 + typename detail::tquat<T>::value_type(1)) * typename detail::tquat<T>::value_type(0.5);
typename detail::tquat<T>::value_type mult = typename detail::tquat<T>::value_type(0.25) / biggestVal;
detail::tquat<T> Result;
switch(biggestIndex)
@@ -467,13 +469,13 @@ namespace quaternion{
return Result;
}
template <typename valType>
inline detail::tquat<valType> quat_cast
template <typename T>
inline detail::tquat<T> quat_cast
(
detail::tmat4x4<valType> const & m4
detail::tmat4x4<T> const & m4
)
{
return quat_cast(detail::tmat3x3<valType>(m4));
return quat_cast(detail::tmat3x3<T>(m4));
}
}//namespace quaternion

39
glm/gtc/swizzle.hpp Normal file
View File

@@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-02-20
// Updated : 2010-02-20
// Licence : This source is under MIT License
// File : glm/gtc/swizzle.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////
// Dependency:
// - GLM core
///////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef glm_gtc_swizzle
#define glm_gtc_closest_point
// Dependency:
#include "../glm.hpp"
namespace glm
{
namespace test{
void main_gtc_swizzle();
}//namespace test
namespace gtc{
//! GLM_GTC_swizzle extension
namespace glm_gtc_swizzle{
}//namespace closest_point
}//namespace gtc
}//namespace glm
#include "swizzle.inl"
namespace glm{using namespace gtc::swizzle;}
#endif//glm_gtc_swizzle

62
glm/gtc/swizzle.inl Normal file
View File

@@ -0,0 +1,62 @@
namespace glm{
namespace gtc{
namespace glm_gtc_swizzle
{
template <typename T>
inline typename tvec4<T>::value_type swizzle
(
detail::tvec4<T> const & v,
comp x
) const
{
return v[x];
}
template <typename T>
inline tvec2<T> tvec4<T>::swizzle
(
detail::tvec4<T> const & v,
comp x, comp y
) const
{
return tvec2<T>(
(*this)[x],
(*this)[y]);
}
template <typename T>
inline tvec3<T> tvec4<T>::swizzle
(
detail::tvec4<T> const & v,
comp x, comp y, comp z
) const
{
return tvec3<T>(
(*this)[x],
(*this)[y],
(*this)[z]);
}
template <typename T>
inline tvec4<T> tvec4<T>::swizzle
(
detail::tvec4<T> const & v,
comp x, comp y, comp z, comp w
) const
{
return tvec4<T>(v[x], v[y], v[z], v[w]);
}
template <typename T>
inline tref4<T> swizzle
(
detail::tvec4<T> const & v,
comp x, comp y, comp z, comp w
)
{
return tref4<T>(v[x], v[y], v[z], v[w]);
}
}//namespace glm_gtc_swizzle
}//namespace gtc
}//namespace glm

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-06-04
// Updated : 2009-06-04
@@ -193,12 +193,8 @@ namespace glm
}//namespace gtc
}//namespace glm
#define GLM_GTC_type_precision namespace gtc::type_precision
#ifndef GLM_GTC_GLOBAL
namespace glm {using GLM_GTC_type_precision;}
#endif//GLM_GTC_GLOBAL
#include "type_precision.inl"
namespace glm{using namespace gtc::type_precision;}
#endif//glm_gtc_type_precision

View File

@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2009-06-14
// Updated : 2009-06-14