mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 11:24:35 +00:00
194 lines
18 KiB
HTML
194 lines
18 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<title>GLM: quaternion.hpp Source File</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
|
|
</head>
|
|
<body>
|
|
<!-- Generated by Doxygen 1.6.1 -->
|
|
<div class="navigation" id="top">
|
|
<div class="tabs">
|
|
<ul>
|
|
<li><a href="index.html"><span>Main Page</span></a></li>
|
|
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
|
|
<li class="current"><a href="files.html"><span>Files</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<div class="tabs">
|
|
<ul>
|
|
<li><a href="files.html"><span>File List</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<h1>quaternion.hpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
|
|
<a name="l00002"></a>00002 <span class="comment">// OpenGL Mathematics Copyright (c) 2005 - 2009 G-Truc Creation (www.g-truc.net)</span>
|
|
<a name="l00004"></a>00004 <span class="comment"></span><span class="comment">// Created : 2009-05-21</span>
|
|
<a name="l00005"></a>00005 <span class="comment">// Updated : 2009-06-04</span>
|
|
<a name="l00006"></a>00006 <span class="comment">// Licence : This source is under MIT License</span>
|
|
<a name="l00007"></a>00007 <span class="comment">// File : glm/gtc/quaternion.hpp</span>
|
|
<a name="l00009"></a>00009 <span class="comment"></span><span class="comment">// Dependency:</span>
|
|
<a name="l00010"></a>00010 <span class="comment">// - GLM core</span>
|
|
<a name="l00012"></a>00012 <span class="comment"></span><span class="comment">// ToDo:</span>
|
|
<a name="l00013"></a>00013 <span class="comment">// - Study constructors with angles and axis</span>
|
|
<a name="l00014"></a>00014 <span class="comment">// - Study constructors with vec3 that are the imaginary component of quaternion</span>
|
|
<a name="l00016"></a>00016 <span class="comment"></span>
|
|
<a name="l00017"></a>00017 <span class="preprocessor">#ifndef glm_gtc_quaternion</span>
|
|
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="preprocessor">#define glm_gtc_quaternion</span>
|
|
<a name="l00019"></a>00019 <span class="preprocessor"></span>
|
|
<a name="l00020"></a>00020 <span class="comment">// Dependency:</span>
|
|
<a name="l00021"></a>00021 <span class="preprocessor">#include "../glm.hpp"</span>
|
|
<a name="l00022"></a>00022
|
|
<a name="l00023"></a>00023 <span class="keyword">namespace </span>glm
|
|
<a name="l00024"></a>00024 {
|
|
<a name="l00025"></a>00025 <span class="keyword">namespace </span>test{
|
|
<a name="l00026"></a>00026 <span class="keywordtype">bool</span> main_gtc_quaternion();
|
|
<a name="l00027"></a>00027 }<span class="comment">//namespace test</span>
|
|
<a name="l00028"></a>00028
|
|
<a name="l00029"></a>00029 <span class="keyword">namespace </span>detail
|
|
<a name="l00030"></a>00030 {
|
|
<a name="l00033"></a>00033 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00034"></a>00034 <span class="keyword">class </span>tquat
|
|
<a name="l00035"></a>00035 {
|
|
<a name="l00036"></a>00036 <span class="keyword">public</span>:
|
|
<a name="l00037"></a>00037 valType x, y, z, w;
|
|
<a name="l00038"></a>00038
|
|
<a name="l00039"></a>00039 <span class="comment">// Constructors</span>
|
|
<a name="l00040"></a>00040 tquat();
|
|
<a name="l00041"></a>00041 <span class="keyword">explicit</span> tquat(valType <span class="keyword">const</span> & s, tvec3<valType> <span class="keyword">const</span> & v);
|
|
<a name="l00042"></a>00042 <span class="keyword">explicit</span> tquat(valType <span class="keyword">const</span> & w, valType <span class="keyword">const</span> & x, valType <span class="keyword">const</span> & y, valType <span class="keyword">const</span> & z);
|
|
<a name="l00043"></a>00043
|
|
<a name="l00044"></a>00044 <span class="comment">// Convertions</span>
|
|
<a name="l00045"></a>00045 <span class="comment">//explicit tquat(valType const & pitch, valType const & yaw, valType const & roll);</span>
|
|
<a name="l00047"></a>00047 <span class="comment"></span> <span class="keyword">explicit</span> tquat(tvec3<valType> <span class="keyword">const</span> & eulerAngles);
|
|
<a name="l00048"></a>00048 <span class="keyword">explicit</span> tquat(tmat3x3<valType> <span class="keyword">const</span> & m);
|
|
<a name="l00049"></a>00049 <span class="keyword">explicit</span> tquat(tmat4x4<valType> <span class="keyword">const</span> & m);
|
|
<a name="l00050"></a>00050
|
|
<a name="l00051"></a>00051 <span class="comment">// Accesses</span>
|
|
<a name="l00052"></a>00052 valType& operator[](<span class="keywordtype">int</span> i);
|
|
<a name="l00053"></a>00053 valType operator[](<span class="keywordtype">int</span> i) <span class="keyword">const</span>;
|
|
<a name="l00054"></a>00054
|
|
<a name="l00055"></a>00055 <span class="comment">// Operators</span>
|
|
<a name="l00056"></a>00056 tquat<valType>& operator*=(valType <span class="keyword">const</span> & s);
|
|
<a name="l00057"></a>00057 tquat<valType>& operator/=(valType <span class="keyword">const</span> & s);
|
|
<a name="l00058"></a>00058 };
|
|
<a name="l00059"></a>00059
|
|
<a name="l00060"></a>00060 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00061"></a>00061 detail::tquat<valType> operator- (
|
|
<a name="l00062"></a>00062 detail::tquat<valType> <span class="keyword">const</span> & q);
|
|
<a name="l00063"></a>00063
|
|
<a name="l00064"></a>00064 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00065"></a>00065 detail::tvec3<valType> operator* (
|
|
<a name="l00066"></a>00066 detail::tquat<valType> <span class="keyword">const</span> & q,
|
|
<a name="l00067"></a>00067 detail::tvec3<valType> <span class="keyword">const</span> & v);
|
|
<a name="l00068"></a>00068
|
|
<a name="l00069"></a>00069 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00070"></a>00070 detail::tvec3<valType> operator* (
|
|
<a name="l00071"></a>00071 detail::tvec3<valType> <span class="keyword">const</span> & v,
|
|
<a name="l00072"></a>00072 detail::tquat<valType> <span class="keyword">const</span> & q);
|
|
<a name="l00073"></a>00073
|
|
<a name="l00074"></a>00074 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00075"></a>00075 detail::tvec4<valType> operator* (
|
|
<a name="l00076"></a>00076 detail::tquat<valType> <span class="keyword">const</span> & q,
|
|
<a name="l00077"></a>00077 detail::tvec4<valType> <span class="keyword">const</span> & v);
|
|
<a name="l00078"></a>00078
|
|
<a name="l00079"></a>00079 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00080"></a>00080 detail::tvec4<valType> operator* (
|
|
<a name="l00081"></a>00081 detail::tvec4<valType> <span class="keyword">const</span> & v,
|
|
<a name="l00082"></a>00082 detail::tquat<valType> <span class="keyword">const</span> & q);
|
|
<a name="l00083"></a>00083
|
|
<a name="l00084"></a>00084 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00085"></a>00085 detail::tquat<valType> operator* (
|
|
<a name="l00086"></a>00086 detail::tquat<valType> <span class="keyword">const</span> & q,
|
|
<a name="l00087"></a>00087 valType <span class="keyword">const</span> & s);
|
|
<a name="l00088"></a>00088
|
|
<a name="l00089"></a>00089 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00090"></a>00090 detail::tquat<valType> operator* (
|
|
<a name="l00091"></a>00091 valType <span class="keyword">const</span> & s,
|
|
<a name="l00092"></a>00092 detail::tquat<valType> <span class="keyword">const</span> & q);
|
|
<a name="l00093"></a>00093
|
|
<a name="l00094"></a>00094 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00095"></a>00095 detail::tquat<valType> operator/ (
|
|
<a name="l00096"></a>00096 detail::tquat<valType> <span class="keyword">const</span> & q,
|
|
<a name="l00097"></a>00097 valType <span class="keyword">const</span> & s);
|
|
<a name="l00098"></a>00098
|
|
<a name="l00099"></a>00099 } <span class="comment">//namespace detail</span>
|
|
<a name="l00100"></a>00100
|
|
<a name="l00101"></a>00101 <span class="keyword">namespace </span>gtc{
|
|
<a name="l00103"></a><a class="code" href="a00148.html">00103</a> <span class="keyword">namespace </span>quaternion
|
|
<a name="l00104"></a>00104 {
|
|
<a name="l00107"></a>00107 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00108"></a>00108 valType <a class="code" href="a00148.html#ab5b9ba59887e95689e75a578debed0c3" title="Returns the length of the quaternion x.">length</a>(
|
|
<a name="l00109"></a>00109 detail::tquat<valType> <span class="keyword">const</span> & q);
|
|
<a name="l00110"></a>00110
|
|
<a name="l00113"></a>00113 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00114"></a>00114 detail::tquat<valType> <a class="code" href="a00148.html#ad0ae9c01fe65d0e739178f67cab4e2bc" title="Returns the normalized quaternion of from x.">normalize</a>(
|
|
<a name="l00115"></a>00115 detail::tquat<valType> <span class="keyword">const</span> & q);
|
|
<a name="l00116"></a>00116
|
|
<a name="l00119"></a>00119 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00120"></a>00120 valType <a class="code" href="a00148.html#ad4495643e2d2da6b1a82c4e545356c13" title="Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + .">dot</a>(
|
|
<a name="l00121"></a>00121 detail::tquat<valType> <span class="keyword">const</span> & q1,
|
|
<a name="l00122"></a>00122 detail::tquat<valType> <span class="keyword">const</span> & q2);
|
|
<a name="l00123"></a>00123
|
|
<a name="l00126"></a>00126 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00127"></a>00127 detail::tquat<valType> <a class="code" href="a00148.html#a34ad81954b70e0b945f465ba48d95b02" title="Returns the cross product of q1 and q2.">cross</a>(
|
|
<a name="l00128"></a>00128 detail::tquat<valType> <span class="keyword">const</span> & q1,
|
|
<a name="l00129"></a>00129 detail::tquat<valType> <span class="keyword">const</span> & q2);
|
|
<a name="l00130"></a>00130
|
|
<a name="l00133"></a>00133 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00134"></a>00134 detail::tquat<valType> <a class="code" href="a00148.html#a776318ba7199fdef77b40b54528ef3f0" title="Returns a LERP interpolated quaternion of x and y according a.">mix</a>(
|
|
<a name="l00135"></a>00135 detail::tquat<valType> <span class="keyword">const</span> & x,
|
|
<a name="l00136"></a>00136 detail::tquat<valType> <span class="keyword">const</span> & y,
|
|
<a name="l00137"></a>00137 valType <span class="keyword">const</span> & a);
|
|
<a name="l00138"></a>00138
|
|
<a name="l00141"></a>00141 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00142"></a>00142 detail::tquat<valType> <a class="code" href="a00148.html#aef383347c7c121fb498bf98c9f3cd773" title="Returns the q conjugate.">conjugate</a>(
|
|
<a name="l00143"></a>00143 detail::tquat<valType> <span class="keyword">const</span> & q);
|
|
<a name="l00144"></a>00144
|
|
<a name="l00147"></a>00147 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00148"></a>00148 detail::tquat<valType> <a class="code" href="a00148.html#ad5838ef9535da0aab26e4c556bd5eab2" title="Returns the q inverse.">inverse</a>(
|
|
<a name="l00149"></a>00149 detail::tquat<valType> <span class="keyword">const</span> & q);
|
|
<a name="l00150"></a>00150
|
|
<a name="l00153"></a>00153 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00154"></a>00154 detail::tquat<valType> <a class="code" href="a00148.html#af35cd64eff7074f1a6706f80c4060e6a" title="Rotates a quaternion from an vector of 3 components axis and an angle expressed in...">rotate</a>(
|
|
<a name="l00155"></a>00155 detail::tquat<valType> <span class="keyword">const</span> & q,
|
|
<a name="l00156"></a>00156 valType <span class="keyword">const</span> & angle,
|
|
<a name="l00157"></a>00157 detail::tvec3<valType> <span class="keyword">const</span> & v);
|
|
<a name="l00158"></a>00158
|
|
<a name="l00161"></a>00161 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00162"></a>00162 detail::tmat3x3<valType> <a class="code" href="a00148.html#a3f6d3a2eec09de0c3d191a6b5235a744" title="Converts a quaternion to a 3 * 3 matrix.">mat3_cast</a>(
|
|
<a name="l00163"></a>00163 detail::tquat<valType> <span class="keyword">const</span> & x);
|
|
<a name="l00164"></a>00164
|
|
<a name="l00167"></a>00167 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00168"></a>00168 detail::tmat4x4<valType> <a class="code" href="a00148.html#a09599c3024ab423b26d4c1b440893cb8" title="Converts a quaternion to a 4 * 4 matrix.">mat4_cast</a>(
|
|
<a name="l00169"></a>00169 detail::tquat<valType> <span class="keyword">const</span> & x);
|
|
<a name="l00170"></a>00170
|
|
<a name="l00173"></a>00173 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00174"></a>00174 detail::tquat<valType> <a class="code" href="a00148.html#a619b445502abad1cc98207919116e7fd" title="Converts a 3 * 3 matrix to a quaternion.">quat_cast</a>(
|
|
<a name="l00175"></a>00175 detail::tmat3x3<valType> <span class="keyword">const</span> & x);
|
|
<a name="l00176"></a>00176
|
|
<a name="l00179"></a>00179 <span class="keyword">template</span> <<span class="keyword">typename</span> valType>
|
|
<a name="l00180"></a>00180 detail::tquat<valType> <a class="code" href="a00148.html#a619b445502abad1cc98207919116e7fd" title="Converts a 3 * 3 matrix to a quaternion.">quat_cast</a>(
|
|
<a name="l00181"></a>00181 detail::tmat4x4<valType> <span class="keyword">const</span> & x);
|
|
<a name="l00182"></a>00182
|
|
<a name="l00185"></a><a class="code" href="a00148.html#a60408579db470456070a3336295625a7">00185</a> <span class="keyword">typedef</span> detail::tquat<float> <a class="code" href="a00148.html#a60408579db470456070a3336295625a7" title="Quaternion of floating-point numbers.">quat</a>;
|
|
<a name="l00186"></a>00186
|
|
<a name="l00187"></a>00187 }<span class="comment">//namespace quaternion</span>
|
|
<a name="l00188"></a>00188 }<span class="comment">//namespace gtc</span>
|
|
<a name="l00189"></a>00189 } <span class="comment">//namespace glm</span>
|
|
<a name="l00190"></a>00190
|
|
<a name="l00191"></a>00191 <span class="preprocessor">#define GLM_GTC_quaternion namespace gtc::quaternion</span>
|
|
<a name="l00192"></a>00192 <span class="preprocessor"></span><span class="preprocessor">#ifndef GLM_GTC_GLOBAL</span>
|
|
<a name="l00193"></a>00193 <span class="preprocessor"></span><span class="keyword">namespace </span>glm {<span class="keyword">using</span> GLM_GTC_quaternion;}
|
|
<a name="l00194"></a>00194 <span class="preprocessor">#endif//GLM_GTC_GLOBAL</span>
|
|
<a name="l00195"></a>00195 <span class="preprocessor"></span>
|
|
<a name="l00196"></a>00196 <span class="preprocessor">#include "quaternion.inl"</span>
|
|
<a name="l00197"></a>00197
|
|
<a name="l00198"></a>00198 <span class="preprocessor">#endif//glm_gtc_quaternion</span>
|
|
</pre></div></div>
|
|
<hr size="1"/><address style="text-align: right;"><small>Generated on Mon Nov 16 11:23:23 2009 for GLM by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
|
|
</body>
|
|
</html>
|