Jason McKesson avatar Jason McKesson committed e87e1fc

Added quaternion multiplication to GLM.

Comments (0)

Files changed (4)

glm-0.9.0.7/glm/gtc/quaternion.hpp

 			detail::tquat<T> const & q, 
 			typename detail::tquat<T>::value_type const & s);
 
+		template <typename valType>
+		detail::tquat<valType> operator *(
+			const detail::tquat<valType> &lhs, const detail::tquat<valType> &rhs);
+
 	} //namespace detail
 
 	namespace gtc{
 		//! From GLM_GTC_quaternion extension.
 		typedef detail::tquat<double>	dquat;
 
+
     }//namespace quaternion
     }//namespace gtc
 } //namespace glm

glm-0.9.0.7/glm/gtc/quaternion.inl

 		return (q1.x != q2.x) || (q1.y != q2.y) || (q1.z != q2.z) || (q1.w != q2.w);
 	}
 
+	template <typename valType>
+	inline detail::tquat<valType> operator *(
+		const detail::tquat<valType> &lhs, const detail::tquat<valType> &rhs)
+	{
+		detail::tquat<valType> ret;
+		ret.w = lhs.w*rhs.w - (lhs.x*rhs.x) - (lhs.y*rhs.y) - (lhs.z*rhs.z);
+		ret.x = lhs.w*rhs.x + lhs.x*rhs.w + lhs.y*rhs.z - lhs.z*rhs.y;
+		ret.y = lhs.w*rhs.y + lhs.y*rhs.w + lhs.z*rhs.x - lhs.x*rhs.z;
+		ret.z = lhs.w*rhs.z + lhs.z*rhs.w + lhs.x*rhs.y - lhs.y*rhs.x;
+
+		return ret;
+	}
 }//namespace detail
 
 namespace gtc{

glm-0.9.0.7/glm/gtx/quaternion.hpp

 		detail::tquat<valType> toQuat(
 			detail::tmat4x4<valType> const & x){return gtc::quaternion::quat_cast(x);}
 
+		template <typename valType>
+		detail::tquat<valType> multiply(
+			const detail::tquat<valType> &lhs, const detail::tquat<valType> &rhs);
+
+
     }//namespace quaternion
     }//namespace gtx
 } //namespace glm

glm-0.9.0.7/glm/gtx/quaternion.inl

         return detail::tvec3<valType>(pitch(x), yaw(x), roll(x));
     }
 
+	template <typename valType>
+	inline detail::tquat<valType> multiply(
+		const detail::tquat<valType> &lhs, const detail::tquat<valType> &rhs)
+	{
+		detail::tquat<valType> ret;
+		ret.w = lhs.w*rhs.w - (lhs.x*rhs.x) - (lhs.y*rhs.y) - (lhs.z*rhs.z);
+		ret.x = lhs.w*rhs.x + lhs.x*rhs.w + lhs.y*rhs.z - lhs.z*rhs.y;
+		ret.y = lhs.w*rhs.y + lhs.y*rhs.w + lhs.z*rhs.x - lhs.x*rhs.z;
+		ret.z = lhs.w*rhs.z + lhs.z*rhs.w + lhs.x*rhs.y - lhs.y*rhs.x;
+
+		return ret;
+	}
+
+
 }//namespace quaternion
 }//namespace gtx
 }//namespace glm
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.