/////////////////////////////////////////////////////////////////////////////////// /// OpenGL Mathematics (glm.g-truc.net) /// /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) /// Permission is hereby granted, free of charge, to any person obtaining a copy /// of this software and associated documentation files (the "Software"), to deal /// in the Software without restriction, including without limitation the rights /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell /// copies of the Software, and to permit persons to whom the Software is /// furnished to do so, subject to the following conditions: /// /// The above copyright notice and this permission notice shall be included in /// all copies or substantial portions of the Software. /// /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN /// THE SOFTWARE. /// /// @ref gtc_quaternion /// @file glm/gtc/quaternion.hpp /// @date 2009-05-21 / 2011-06-05 /// @author Christophe Riccio /// /// @see core (dependence) /// @see gtc_half_float (dependence) /// /// @defgroup gtc_quaternion GLM_GTC_quaternion: Quaternion types and functions /// @ingroup gtc /// /// @brief Defines a templated quaternion type and several quaternion operations. /// /// need to be included to use these functionalities. /////////////////////////////////////////////////////////////////////////////////// #ifndef GLM_GTC_quaternion #define GLM_GTC_quaternion GLM_VERSION // Dependency: #include "../glm.hpp" #include "../gtc/half_float.hpp" #if(defined(GLM_MESSAGES) && !defined(glm_ext)) # pragma message("GLM: GLM_GTC_quaternion extension included") #endif namespace glm{ namespace detail { /// @brief Template for quaternion. /// @see gtc_quaternion /// @ingroup gtc_quaternion template struct tquat// : public genType { enum ctor{null}; typedef T value_type; typedef std::size_t size_type; public: value_type x, y, z, w; GLM_FUNC_DECL size_type length() const; // Constructors tquat(); explicit tquat( value_type const & s, glm::detail::tvec3 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); //! Build a quaternion from euler angles (pitch, yaw, roll), in radians. explicit tquat( tvec3 const & eulerAngles); explicit tquat( tmat3x3 const & m); explicit tquat( tmat4x4 const & m); // Accesses value_type & operator[](int i); value_type const & operator[](int i) const; // Operators tquat & operator*=(value_type const & s); tquat & operator/=(value_type const & s); }; template detail::tquat operator- ( detail::tquat const & q); template detail::tquat operator+ ( detail::tquat const & q, detail::tquat const & p); template detail::tquat operator* ( detail::tquat const & q, detail::tquat const & p); template detail::tvec3 operator* ( detail::tquat const & q, detail::tvec3 const & v); template detail::tvec3 operator* ( detail::tvec3 const & v, detail::tquat const & q); template detail::tvec4 operator* ( detail::tquat const & q, detail::tvec4 const & v); template detail::tvec4 operator* ( detail::tvec4 const & v, detail::tquat const & q); template detail::tquat operator* ( detail::tquat const & q, typename detail::tquat::value_type const & s); template detail::tquat operator* ( typename detail::tquat::value_type const & s, detail::tquat const & q); template detail::tquat operator/ ( detail::tquat const & q, typename detail::tquat::value_type const & s); } //namespace detail /// @addtogroup gtc_quaternion /// @{ /// Returns the length of the quaternion. /// /// @see gtc_quaternion template T length( detail::tquat const & q); /// Returns the normalized quaternion. /// /// @see gtc_quaternion template detail::tquat normalize( detail::tquat const & q); /// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ... /// /// @see gtc_quaternion template T dot( detail::tquat const & q1, detail::tquat const & q2); /// Returns a SLERP interpolated quaternion of x and y according a. /// /// @see gtc_quaternion template detail::tquat mix( detail::tquat const & x, detail::tquat const & y, T const & a); /// Returns the q conjugate. /// /// @see gtc_quaternion template detail::tquat conjugate( detail::tquat const & q); /// Returns the q inverse. /// /// @see gtc_quaternion template detail::tquat inverse( detail::tquat const & q); /// Rotates a quaternion from an vector of 3 components axis and an angle expressed in degrees. /// /// @see gtc_quaternion template detail::tquat rotate( detail::tquat const & q, typename detail::tquat::value_type const & angle, detail::tvec3 const & v); /// Returns euler angles, yitch as x, yaw as y, roll as z. /// /// @see gtc_quaternion template detail::tvec3 eulerAngles( detail::tquat const & x); /// Converts a quaternion to a 3 * 3 matrix. /// /// @see gtc_quaternion template detail::tmat3x3 mat3_cast( detail::tquat const & x); /// Converts a quaternion to a 4 * 4 matrix. /// /// @see gtc_quaternion template detail::tmat4x4 mat4_cast( detail::tquat const & x); /// Converts a 3 * 3 matrix to a quaternion. /// /// @see gtc_quaternion template detail::tquat quat_cast( detail::tmat3x3 const & x); /// Converts a 4 * 4 matrix to a quaternion. /// /// @see gtc_quaternion template detail::tquat quat_cast( detail::tmat4x4 const & x); /// Quaternion of floating-point numbers. /// /// @see gtc_quaternion typedef detail::tquat quat; /// Quaternion of half-precision floating-point numbers. /// /// @see gtc_quaternion typedef detail::tquat hquat; /// Quaternion of single-precision floating-point numbers. /// /// @see gtc_quaternion typedef detail::tquat fquat; /// Quaternion of double-precision floating-point numbers. /// /// @see gtc_quaternion typedef detail::tquat dquat; /// Quaternion of low precision floating-point numbers. /// /// @see gtc_quaternion typedef detail::tquat lowp_quat; /// Quaternion of medium precision floating-point numbers. /// /// @see gtc_quaternion typedef detail::tquat mediump_quat; /// Quaternion of high precision floating-point numbers. /// /// @see gtc_quaternion typedef detail::tquat highp_quat; /// @} } //namespace glm #include "quaternion.inl" #endif//GLM_GTC_quaternion