Browse Source

Promoted angle axis interaction with quaternion

Christophe Riccio 13 years ago
parent
commit
cb017c5bca
4 changed files with 98 additions and 98 deletions
  1. 37 0
      glm/gtc/quaternion.hpp
  2. 61 0
      glm/gtc/quaternion.inl
  3. 0 37
      glm/gtx/quaternion.hpp
  4. 0 61
      glm/gtx/quaternion.inl

+ 37 - 0
glm/gtc/quaternion.hpp

@@ -241,6 +241,43 @@ namespace detail
 	detail::tquat<T> quat_cast(
 		detail::tmat4x4<T> const & x);
 
+    /// Returns the quaternion rotation angle. 
+	///
+	/// @see gtc_quaternion
+	template <typename valType> 
+	valType angle(
+		detail::tquat<valType> const & x);
+
+	/// Returns the q rotation axis. 
+	///
+	/// @see gtc_quaternion
+	template <typename valType> 
+	detail::tvec3<valType> axis(
+		detail::tquat<valType> const & x);
+
+	/// Build a quaternion from an angle and a normalized axis. 
+	///
+	/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
+	///
+	/// @see gtc_quaternion
+	template <typename valType> 
+	detail::tquat<valType> angleAxis(
+		valType const & angle, 
+		valType const & x, 
+		valType const & y, 
+		valType const & z);
+
+    /// Build a quaternion from an angle and a normalized axis.
+	///
+	/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
+	/// @param axis Axis of the quaternion, must be normalized. 
+	///
+	/// @see gtc_quaternion
+	template <typename valType> 
+	detail::tquat<valType> angleAxis(
+		valType const & angle, 
+		detail::tvec3<valType> const & axis);
+
 	/// Quaternion of floating-point numbers. 
 	/// 
 	/// @see gtc_quaternion

+ 61 - 0
glm/gtc/quaternion.inl

@@ -615,4 +615,65 @@ namespace detail
 		return quat_cast(detail::tmat3x3<T>(m4));
     }
 
+	template <typename T> 
+	GLM_FUNC_QUALIFIER T angle
+	(
+		detail::tquat<T> const & x
+	)
+	{
+#ifdef GLM_FORCE_RADIANS
+		return acos(x.w) * T(2);
+#else
+		return glm::degrees(acos(x.w) * T(2));
+#endif
+	}
+
+	template <typename T> 
+	GLM_FUNC_QUALIFIER detail::tvec3<T> axis
+	(
+		detail::tquat<T> const & x
+	)
+	{
+		T tmp1 = T(1) - x.w * x.w;
+		if(tmp1 <= T(0))
+			return detail::tvec3<T>(0, 0, 1);
+		T tmp2 = T(1) / sqrt(tmp1);
+		return detail::tvec3<T>(x.x * tmp2, x.y * tmp2, x.z * tmp2);
+	}
+
+	template <typename valType> 
+	GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
+	(
+		valType const & angle, 
+		valType const & x, 
+		valType const & y, 
+		valType const & z
+	)
+	{
+		return angleAxis(angle, detail::tvec3<valType>(x, y, z));
+	}
+
+	template <typename valType> 
+	GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
+	(
+		valType const & angle, 
+		detail::tvec3<valType> const & v
+	)
+	{
+		detail::tquat<valType> result;
+
+#ifdef GLM_FORCE_RADIANS
+		valType a(angle);
+#else
+		valType a(glm::radians(angle));
+#endif
+		valType s = glm::sin(a * valType(0.5));
+
+		result.w = glm::cos(a * valType(0.5));
+		result.x = v.x * s;
+		result.y = v.y * s;
+		result.z = v.z * s;
+		return result;
+	}
+
 }//namespace glm

+ 0 - 37
glm/gtx/quaternion.hpp

@@ -134,43 +134,6 @@ namespace glm
 	detail::tvec4<valType> rotate(
 		detail::tquat<valType> const & q, 
 		detail::tvec4<valType> const & v);
-		
-    /// Returns the quaternion rotation angle. 
-	///
-	/// @see gtx_quaternion
-	template <typename valType> 
-	valType angle(
-		detail::tquat<valType> const & x);
-
-	/// Returns the q rotation axis. 
-	///
-	/// @see gtx_quaternion
-	template <typename valType> 
-	detail::tvec3<valType> axis(
-		detail::tquat<valType> const & x);
-
-	/// Build a quaternion from an angle and a normalized axis. 
-	///
-	/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
-	///
-	/// @see gtx_quaternion
-	template <typename valType> 
-	detail::tquat<valType> angleAxis(
-		valType const & angle, 
-		valType const & x, 
-		valType const & y, 
-		valType const & z);
-
-    /// Build a quaternion from an angle and a normalized axis.
-	///
-	/// @param angle Angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
-	/// @param axis Axis of the quaternion, must be normalized. 
-	///
-	/// @see gtx_quaternion
-	template <typename valType> 
-	detail::tquat<valType> angleAxis(
-		valType const & angle, 
-		detail::tvec3<valType> const & axis);
 
 	/// Extract the real component of a quaternion.
 	///

+ 0 - 61
glm/gtx/quaternion.inl

@@ -141,67 +141,6 @@ namespace glm
 		return q * v;
 	}
 
-	template <typename T> 
-	GLM_FUNC_QUALIFIER T angle
-	(
-		detail::tquat<T> const & x
-	)
-	{
-#ifdef GLM_FORCE_RADIANS
-		return acos(x.w) * T(2);
-#else
-		return glm::degrees(acos(x.w) * T(2));
-#endif
-	}
-
-	template <typename T> 
-	GLM_FUNC_QUALIFIER detail::tvec3<T> axis
-	(
-		detail::tquat<T> const & x
-	)
-	{
-		T tmp1 = T(1) - x.w * x.w;
-		if(tmp1 <= T(0))
-			return detail::tvec3<T>(0, 0, 1);
-		T tmp2 = T(1) / sqrt(tmp1);
-		return detail::tvec3<T>(x.x * tmp2, x.y * tmp2, x.z * tmp2);
-	}
-
-	template <typename valType> 
-	GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
-	(
-		valType const & angle, 
-		valType const & x, 
-		valType const & y, 
-		valType const & z
-	)
-	{
-		return angleAxis(angle, detail::tvec3<valType>(x, y, z));
-	}
-
-	template <typename valType> 
-	GLM_FUNC_QUALIFIER detail::tquat<valType> angleAxis
-	(
-		valType const & angle, 
-		detail::tvec3<valType> const & v
-	)
-	{
-		detail::tquat<valType> result;
-
-#ifdef GLM_FORCE_RADIANS
-		valType a(angle);
-#else
-		valType a(glm::radians(angle));
-#endif
-		valType s = glm::sin(a * valType(0.5));
-
-		result.w = glm::cos(a * valType(0.5));
-		result.x = v.x * s;
-		result.y = v.y * s;
-		result.z = v.z * s;
-		return result;
-	}
-
 	template <typename T> 
 	GLM_FUNC_QUALIFIER T extractRealComponent
 	(