Index: /trunk/nv/interface/interpolation_raw.hh
===================================================================
--- /trunk/nv/interface/interpolation_raw.hh	(revision 458)
+++ /trunk/nv/interface/interpolation_raw.hh	(revision 459)
@@ -150,5 +150,5 @@
 	{
 		quat& r = *( reinterpret_cast<quat*>( data ) );
-		r = quat_cast( r33 * mat3_cast( r ) * ri33 );
+		r = math::quat_cast( r33 * mat3_cast( r ) * ri33 );
 	}
 	inline void transform_key_scale( void* data, float scale )
@@ -162,5 +162,5 @@
 		t = transform( 
 			r33 * t.get_position() * scale,
-			quat_cast( r33 * mat3_cast( t.get_orientation() ) * ri33 )
+			math::quat_cast( r33 * math::mat3_cast( t.get_orientation() ) * ri33 )
 		);
 	}
Index: /trunk/nv/stl/math/common.hh
===================================================================
--- /trunk/nv/stl/math/common.hh	(revision 458)
+++ /trunk/nv/stl/math/common.hh	(revision 459)
@@ -25,6 +25,4 @@
 #include <nv/base/cmath.hh>
 #include <glm/glm.hpp>
-#include <glm/gtc/quaternion.hpp>
-#include <glm/gtx/vector_angle.hpp>
 
 namespace nv
@@ -67,5 +65,4 @@
 		template < typename T > using tmat3 = ::glm::detail::tmat3x3<T, glm::precision::highp>;
 		template < typename T > using tmat4 = ::glm::detail::tmat4x4<T, glm::precision::highp>;
-		template < typename T > using tquat = ::glm::detail::tmat4x4<T, glm::precision::highp>;
 #else
 		template < typename T > using tvec2 = ::glm::tvec2<T>;
@@ -75,17 +72,12 @@
 		template < typename T > using tmat3 = ::glm::tmat3x3<T>;
 		template < typename T > using tmat4 = ::glm::tmat4x4<T>;
-		template < typename T > using tquat = ::glm::tquat<T, glm::highp>;
 #endif
-
-		typedef glm::quat quat;
 
 		template < typename T > struct is_vec : false_type {};
 		template < typename T > struct is_mat : false_type {};
-		template < typename T > struct is_quat : false_type {};
 
 		template < typename T > struct is_fp : is_floating_point< T > {};
 		template < typename T > struct is_fp_vec : false_type {};
 		template < typename T > struct is_fp_mat : false_type {};
-		template < typename T > struct is_fp_quat : false_type {};
 
 		template < typename T > struct is_bool_vec : false_type {};
@@ -97,5 +89,4 @@
 		template < typename T > struct is_mat < tmat3< T > > : true_type {};
 		template < typename T > struct is_mat < tmat4< T > > : true_type {};
-		template < typename T > struct is_quat< tquat< T > > : true_type {};
 
 		template < typename T > struct is_fp     < tvec2< T > > : is_floating_point< T > {};
@@ -108,5 +99,4 @@
 		template < typename T > struct is_fp_mat < tmat3< T > > : is_floating_point< T > {};
 		template < typename T > struct is_fp_mat < tmat4< T > > : is_floating_point< T > {};
-		template < typename T > struct is_fp_quat< tquat< T > > : is_floating_point< T > {};
 
 		template <> struct is_bool_vec < tvec2< bool > > : true_type {};
@@ -232,8 +222,4 @@
 	typedef math::tmat4< float > mat4;
 
-	typedef math::quat quat;
-
-
-
 	template < typename T > 
 	struct make_unsigned< math::tvec2< T > >
Index: /trunk/nv/stl/math/quaternion.hh
===================================================================
--- /trunk/nv/stl/math/quaternion.hh	(revision 458)
+++ /trunk/nv/stl/math/quaternion.hh	(revision 459)
@@ -24,4 +24,97 @@
 	namespace math
 	{
+
+		template <typename T>
+		struct tquat
+		{
+			typedef tquat<T> type;
+			typedef T value_type;
+		public:
+			T x, y, z, w;
+
+			typedef int length_type;
+
+			constexpr length_type length() const { return 4; }
+			inline T& operator[]( length_type i )
+			{
+				NV_ASSERT( i >= 0 && i < 4, "index out of range" );
+				return ( &x )[i]
+			}
+			inline const T& operator[]( length_type i ) const
+			{
+				NV_ASSERT( i >= 0 && i < 4, "index out of range" );
+				return ( &x )[i]
+			}
+
+			constexpr tquat() 
+				: x( 0 ), y( 0 ), z( 0 ), w( 0 ) {};
+			constexpr tquat( const tquat<T>& q ) 
+				: x( q.x ), y( q.y ), z( q.z ), w( q.w ) {}
+			
+			inline explicit tquat( ctor ) {}
+			constexpr explicit tquat( const T& s, const tvec3<T>& v )
+				: x( v.x ), y( v.y ), z( v.z ), w( s ) {}
+			constexpr tquat( const T& aw, const T& ax, const T& ay, const T& az )
+				: x( ax ), y( ay ), z( az ), w( aw ) {}
+
+			inline explicit operator tmat3<T>();
+			inline explicit operator tmat4<T>();
+			inline explicit tquat( const tvec3<T>& u, const tvec3<T>& v );
+			inline explicit tquat( const tvec3<T>& euler );
+			inline explicit tquat( const tmat3<T>& m );
+			inline explicit tquat( const tmat4<T>& m );
+
+			inline tquat<T>& operator=( const tquat<T>& q )
+			{
+				this->w = q.w;
+				this->x = q.x;
+				this->y = q.y;
+				this->z = q.z;
+				return *this;
+			}
+			inline tquat<T>& operator+=( const tquat<T>& q )
+			{
+				this->w += q.w;
+				this->x += q.x;
+				this->y += q.y;
+				this->z += q.z;
+				return *this;
+			}
+			inline tquat<T>& operator*=( const tquat<T>& q )
+			{
+				this->w = w * q.w - x * q.x - y * q.y - z * q.z;
+				this->x = w * q.x + x * q.w + y * q.z - z * q.y;
+				this->y = w * q.y + y * q.w + z * q.x - x * q.z;
+				this->z = w * q.z + z * q.w + x * q.y - y * q.x;
+				return *this;
+			}
+			inline tquat<T>& operator*=( T s )
+			{
+				this->w *= s;
+				this->x *= s;
+				this->y *= s;
+				this->z *= s;
+				return *this;
+			}
+
+			inline tquat<T>& operator/=( T s )
+			{
+				this->w /= s;
+				this->x /= s;
+				this->y /= s;
+				this->z /= s;
+				return *this;
+			}
+
+		};
+
+		typedef tquat< f32 > quat;
+
+		template < typename T > struct is_fp_quat : false_type {};
+		template < typename T > struct is_quat : false_type {};
+
+		template < typename T > struct is_quat< tquat< T > > : true_type {};
+		template < typename T > struct is_fp_quat< tquat< T > > : is_floating_point< T > {};
+
 		namespace detail
 		{
@@ -39,4 +132,9 @@
 		}
 
+		template < typename T, typename enable_if< is_fp_quat<T>::value >::type* = nullptr >
+		inline value_type_t<T> dot( const T& a, const T& b )
+		{
+			return detail::dot_impl< T >::get( a, b );
+		}
 
 		template < typename T >
@@ -355,6 +453,129 @@
 		}
 
+		template < typename T >
+		inline tquat<T>::operator tmat3<T>()
+		{
+			return mat3_cast( *this );
+		}
+
+		template < typename T >
+		inline tquat<T>::operator tmat4<T>()
+		{
+			return mat4_cast( *this );
+		}
+
+		template < typename T >
+		inline tquat<T>::tquat( const tvec3<T>& u, const tvec3<T>& v )
+		{
+			const tvec3<T> lw( cross( u, v ) );
+			T dot_result = detail::dot_impl< tvec3<T> >::get( u, v );
+			tquat<T> q( T( 1 ) + dot_result, lw.x, lw.y, lw.z );
+			*this = normalize( q );
+		}
+
+		template < typename T >
+		inline tquat<T>::tquat( const tvec3<T>& euler )
+		{
+			tvec3<T> c = math::cos( euler * T( 0.5 ) );
+			tvec3<T> s = math::sin( euler * T( 0.5 ) );
+
+			w = c.x * c.y * c.z + s.x * s.y * s.z;
+			x = s.x * c.y * c.z - c.x * s.y * s.z;
+			y = c.x * s.y * c.z + s.x * c.y * s.z;
+			z = c.x * c.y * s.z - s.x * s.y * c.z;
+		}
+
+		template < typename T >
+		inline tquat<T>::tquat( const tmat3<T>& m )
+		{
+			*this = quat_cast( m );
+		}
+
+		template < typename T >
+		inline tquat<T>::tquat( const tmat4<T>& m )
+		{
+			*this = quat_cast( m );
+		}
+
+		template < typename T >
+		inline tquat<T> operator-( const tquat<T>& q )
+		{
+			return tquat<T>( -q.w, -q.x, -q.y, -q.z );
+		}
+
+		template < typename T >
+		inline tquat<T> operator+( const tquat<T>& q, const tquat<T>& p )
+		{
+			return tquat<T>( q ) += p;
+		}
+
+		template < typename T >
+		inline tquat<T> operator*( const tquat<T>& q, const tquat<T>& p )
+		{
+			return tquat<T>( q ) *= p;
+		}
+
+		template < typename T >
+		inline tvec3<T> operator*( const tquat<T>& q, const tvec3<T>& v )
+		{
+			tvec3<T> qvec( q.x, q.y, q.z );
+			tvec3<T> uv( math::cross( qvec, v ) );
+			tvec3<T> uuv( math::cross( qvec, uv ) );
+
+			return v + ( ( uv * q.w ) + uuv ) * static_cast<T>( 2 );
+		}
+
+		template < typename T >
+		inline tvec3<T> operator*( const tvec3<T> & v, const tquat<T>& q )
+		{
+			return math::inverse( q ) * v;
+		}
+
+		template < typename T >
+		inline tvec4<T> operator*( const tquat<T>& q, const tvec4<T>& v )
+		{
+			return tvec4<T>( q * tvec3<T>( v ), v.w );
+		}
+
+		template < typename T >
+		inline tvec4<T> operator*( const tvec4<T>& v, const tquat<T>& q )
+		{
+			return math::inverse( q ) * v;
+		}
+
+		template < typename T >
+		inline tquat<T> operator*( const tquat<T>& q, T s )
+		{
+			return tquat<T>( q.w * s, q.x * s, q.y * s, q.z * s );
+		}
+
+		template < typename T >
+		inline tquat<T> operator*( T s, const tquat<T>& q )
+		{
+			return q * s;
+		}
+
+		template < typename T >
+		inline tquat<T> operator/( const tquat<T>& q, T s )
+		{
+			return tquat<T>( q.w / s, q.x / s, q.y / s, q.z / s );
+		}
+
+		template < typename T >
+		inline bool operator==( const tquat<T>& q1, const tquat<T>& q2 )
+		{
+			return ( q1.x == q2.x ) && ( q1.y == q2.y ) && ( q1.z == q2.z ) && ( q1.w == q2.w );
+		}
+
+		template < typename T >
+		inline bool operator!=( const tquat<T>& q1, const tquat<T>& q2 )
+		{
+			return ( q1.x != q2.x ) || ( q1.y != q2.y ) || ( q1.z != q2.z ) || ( q1.w != q2.w );
+		}
+
 	}
 
+	typedef math::quat quat;
+
 }
 
