1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Quaternions (Rotations)</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="Cogl 2.0 Reference Manual">
8 <link rel="up" href="cogl-utilities.html" title="Utilities">
9 <link rel="prev" href="cogl-2.0-experimental-3-Component-Vectors.html" title="3 Component Vectors">
10 <link rel="next" href="cogl-2.0-experimental-Common-Types.html" title="Common Types">
11 <meta name="generator" content="GTK-Doc V1.18.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
17 <td><a accesskey="p" href="cogl-2.0-experimental-3-Component-Vectors.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="cogl-utilities.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">Cogl 2.0 Reference Manual</th>
21 <td><a accesskey="n" href="cogl-2.0-experimental-Common-Types.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#cogl-2.0-experimental-Quaternions-(Rotations).synopsis" class="shortcut">Top</a>
26 <a href="#cogl-2.0-experimental-Quaternions-(Rotations).description" class="shortcut">Description</a>
29 <div class="refentry">
30 <a name="cogl-2.0-experimental-Quaternions-(Rotations)"></a><div class="titlepage"></div>
31 <div class="refnamediv"><table width="100%"><tr>
33 <h2><span class="refentrytitle"><a name="cogl-2.0-experimental-Quaternions-(Rotations).top_of_page"></a>Quaternions (Rotations)</span></h2>
34 <p>Quaternions (Rotations) — Functions for initializing and manipulating
37 <td valign="top" align="right"></td>
39 <div class="refsynopsisdiv">
40 <a name="cogl-2.0-experimental-Quaternions-(Rotations).synopsis"></a><h2>Synopsis</h2>
41 <pre class="synopsis"> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion">CoglQuaternion</a>;
42 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-init-identity" title="cogl_quaternion_init_identity ()">cogl_quaternion_init_identity</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);
43 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-init" title="cogl_quaternion_init ()">cogl_quaternion_init</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
44 <em class="parameter"><code><span class="type">float</span> angle</code></em>,
45 <em class="parameter"><code><span class="type">float</span> x</code></em>,
46 <em class="parameter"><code><span class="type">float</span> y</code></em>,
47 <em class="parameter"><code><span class="type">float</span> z</code></em>);
48 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-init-from-angle-vector" title="cogl_quaternion_init_from_angle_vector ()">cogl_quaternion_init_from_angle_vector</a>
49 (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
50 <em class="parameter"><code><span class="type">float</span> angle</code></em>,
51 <em class="parameter"><code>const <span class="type">float</span> *axis3f</code></em>);
52 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-init-from-array" title="cogl_quaternion_init_from_array ()">cogl_quaternion_init_from_array</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
53 <em class="parameter"><code>const <span class="type">float</span> *array</code></em>);
54 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-init-from-x-rotation" title="cogl_quaternion_init_from_x_rotation ()">cogl_quaternion_init_from_x_rotation</a>
55 (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
56 <em class="parameter"><code><span class="type">float</span> angle</code></em>);
57 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-init-from-y-rotation" title="cogl_quaternion_init_from_y_rotation ()">cogl_quaternion_init_from_y_rotation</a>
58 (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
59 <em class="parameter"><code><span class="type">float</span> angle</code></em>);
60 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-init-from-z-rotation" title="cogl_quaternion_init_from_z_rotation ()">cogl_quaternion_init_from_z_rotation</a>
61 (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
62 <em class="parameter"><code><span class="type">float</span> angle</code></em>);
63 <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-equal" title="cogl_quaternion_equal ()">cogl_quaternion_equal</a> (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a> v1</code></em>,
64 <em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a> v2</code></em>);
65 <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="returnvalue">CoglQuaternion</span></a> * <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-copy" title="cogl_quaternion_copy ()">cogl_quaternion_copy</a> (<em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *src</code></em>);
66 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-free" title="cogl_quaternion_free ()">cogl_quaternion_free</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);
67 <span class="returnvalue">float</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-get-rotation-angle" title="cogl_quaternion_get_rotation_angle ()">cogl_quaternion_get_rotation_angle</a> (<em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);
68 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-get-rotation-axis" title="cogl_quaternion_get_rotation_axis ()">cogl_quaternion_get_rotation_axis</a> (<em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
69 <em class="parameter"><code><span class="type">float</span> *vector3</code></em>);
70 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-normalize" title="cogl_quaternion_normalize ()">cogl_quaternion_normalize</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);
71 <span class="returnvalue">float</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-dot-product" title="cogl_quaternion_dot_product ()">cogl_quaternion_dot_product</a> (<em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *a</code></em>,
72 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *b</code></em>);
73 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-invert" title="cogl_quaternion_invert ()">cogl_quaternion_invert</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);
74 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-multiply" title="cogl_quaternion_multiply ()">cogl_quaternion_multiply</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *result</code></em>,
75 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *left</code></em>,
76 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *right</code></em>);
77 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-pow" title="cogl_quaternion_pow ()">cogl_quaternion_pow</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
78 <em class="parameter"><code><span class="type">float</span> exponent</code></em>);
79 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-slerp" title="cogl_quaternion_slerp ()">cogl_quaternion_slerp</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *result</code></em>,
80 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *a</code></em>,
81 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *b</code></em>,
82 <em class="parameter"><code><span class="type">float</span> t</code></em>);
83 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-nlerp" title="cogl_quaternion_nlerp ()">cogl_quaternion_nlerp</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *result</code></em>,
84 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *a</code></em>,
85 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *b</code></em>,
86 <em class="parameter"><code><span class="type">float</span> t</code></em>);
87 <span class="returnvalue">void</span> <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-squad" title="cogl_quaternion_squad ()">cogl_quaternion_squad</a> (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *result</code></em>,
88 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *prev</code></em>,
89 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *a</code></em>,
90 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *b</code></em>,
91 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *next</code></em>,
92 <em class="parameter"><code><span class="type">float</span> t</code></em>);
93 const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="returnvalue">CoglQuaternion</span></a> * <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-get-static-identity-quaternion" title="cogl_get_static_identity_quaternion ()">cogl_get_static_identity_quaternion</a>
94 (<em class="parameter"><code><span class="type">void</span></code></em>);
95 const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="returnvalue">CoglQuaternion</span></a> * <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-get-static-zero-quaternion" title="cogl_get_static_zero_quaternion ()">cogl_get_static_zero_quaternion</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
98 <div class="refsect1">
99 <a name="cogl-2.0-experimental-Quaternions-(Rotations).description"></a><h2>Description</h2>
101 Quaternions have become a standard form for representing 3D
102 rotations and have some nice properties when compared with other
103 representation such as (roll,pitch,yaw) Euler angles. They can be
104 used to interpolate between different rotations and they don't
105 suffer from a problem called "Gimbal lock" where two of the axis of
106 rotation may become aligned and you loose a degree of freedom.
107 (<a class="ulink" href="http://en.wikipedia.org/wiki/Gimbal_lock" target="_top">http://en.wikipedia.org/wiki/Gimbal_lock</a>).
110 <div class="refsect1">
111 <a name="cogl-2.0-experimental-Quaternions-(Rotations).details"></a><h2>Details</h2>
112 <div class="refsect2">
113 <a name="CoglQuaternion"></a><h3>CoglQuaternion</h3>
114 <pre class="programlisting">typedef struct {
128 A quaternion is comprised of a scalar component and a 3D vector
129 component. The scalar component is normally referred to as w and the
130 vector might either be referred to as v or a (for axis) or expanded
131 with the individual components: (x, y, z) A full quaternion would
132 then be written as <span style="color: red"><pre>[w (x, y, z)]</pre></span>.
135 Quaternions can be considered to represent an axis and angle
136 pair although sadly these numbers are buried somewhat under some
140 For the curious you can see here that a given axis (a) and angle (𝜃)
141 pair are represented in a quaternion as follows:
143 <div class="informalexample">
144 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
147 <td class="listing_lines" align="right"><pre>1</pre></td>
148 <td class="listing_code"><pre class="programlisting"><span class="symbol">[</span><span class="normal">w</span><span class="symbol">=</span><span class="function">cos</span><span class="symbol">(</span><span class="normal">𝜃</span><span class="symbol">/</span><span class="number">2</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">(</span><span class="normal"> x</span><span class="symbol">=</span><span class="function">sin</span><span class="symbol">(</span><span class="normal">𝜃</span><span class="symbol">/</span><span class="number">2</span><span class="symbol">)*</span><span class="normal">a</span><span class="symbol">.</span><span class="normal">x</span><span class="symbol">,</span><span class="normal"> y</span><span class="symbol">=</span><span class="function">sin</span><span class="symbol">(</span><span class="normal">𝜃</span><span class="symbol">/</span><span class="number">2</span><span class="symbol">)*</span><span class="normal">a</span><span class="symbol">.</span><span class="normal">y</span><span class="symbol">,</span><span class="normal"> z</span><span class="symbol">=</span><span class="function">sin</span><span class="symbol">(</span><span class="normal">𝜃</span><span class="symbol">/</span><span class="number">2</span><span class="symbol">)*</span><span class="normal">a</span><span class="symbol">.</span><span class="normal">x </span><span class="symbol">)]</span></pre></td>
158 When using Quaternions to represent spatial orientations for 3D
159 graphics it's always assumed you have a unit quaternion. The
160 magnitude of a quaternion is defined as:
162 <div class="informalexample">
163 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
166 <td class="listing_lines" align="right"><pre>1</pre></td>
167 <td class="listing_code"><pre class="programlisting"><span class="function">sqrt</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">w² </span><span class="symbol">+</span><span class="normal"> x² </span><span class="symbol">+</span><span class="normal"> y² </span><span class="symbol">+</span><span class="normal"> z²</span><span class="symbol">)</span></pre></td>
174 and a unit quaternion satisfies this equation:
176 <div class="informalexample">
177 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
180 <td class="listing_lines" align="right"><pre>1</pre></td>
181 <td class="listing_code"><pre class="programlisting"><span class="normal">w² </span><span class="symbol">+</span><span class="normal"> x² </span><span class="symbol">+</span><span class="normal"> y² </span><span class="symbol">+</span><span class="normal"> z² </span><span class="symbol">=</span><span class="normal"> </span><span class="number">1</span></pre></td>
190 Thankfully most of the time we don't actually have to worry about
191 the maths that goes on behind the scenes but if you are curious to
192 learn more here are some external references:
196 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
197 <li class="listitem"><a class="ulink" href="http://mathworld.wolfram.com/Quaternion.html" target="_top">http://mathworld.wolfram.com/Quaternion.html</a></li>
198 <li class="listitem"><a class="ulink" href="http://www.gamedev.net/reference/articles/article1095.asp" target="_top">http://www.gamedev.net/reference/articles/article1095.asp</a></li>
199 <li class="listitem"><a class="ulink" href="http://www.cprogramming.com/tutorial/3d/quaternions.html" target="_top">http://www.cprogramming.com/tutorial/3d/quaternions.html</a></li>
200 <li class="listitem"><a class="ulink" href="http://www.isner.com/tutorials/quatSpells/quaternion_spells_12.htm" target="_top">http://www.isner.com/tutorials/quatSpells/quaternion_spells_12.htm</a></li>
201 <li class="listitem">
202 3D Maths Primer for Graphics and Game Development ISBN-10: 1556229119
204 <li class="listitem"><a class="ulink" href="http://www.cs.caltech.edu/courses/cs171/quatut.pdf" target="_top">http://www.cs.caltech.edu/courses/cs171/quatut.pdf</a></li>
205 <li class="listitem"><a class="ulink" href="http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56" target="_top">http://www.j3d.org/matrix_faq/matrfaq_latest.html#Q56</a></li>
210 @w: based on the angle of rotation it is cos(𝜃/2)
211 @x: based on the angle of rotation and x component of the axis of
212 rotation it is sin(𝜃/2)*axis.x
213 @y: based on the angle of rotation and y component of the axis of
214 rotation it is sin(𝜃/2)*axis.y
215 @z: based on the angle of rotation and z component of the axis of
216 rotation it is sin(𝜃/2)*axis.z
220 <div class="refsect2">
221 <a name="cogl-quaternion-init-identity"></a><h3>cogl_quaternion_init_identity ()</h3>
222 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_init_identity (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);</pre>
224 Initializes the quaternion with the canonical quaternion identity
225 [1 (0, 0, 0)] which represents no rotation. Multiplying a
226 quaternion with this identity leaves the quaternion unchanged.
229 You might also want to consider using
230 <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-get-static-identity-quaternion" title="cogl_get_static_identity_quaternion ()"><code class="function">cogl_get_static_identity_quaternion()</code></a>.
232 <div class="variablelist"><table border="0">
233 <col align="left" valign="top">
235 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
236 <td>An uninitialized <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
240 <p class="since">Since 2.0</p>
243 <div class="refsect2">
244 <a name="cogl-quaternion-init"></a><h3>cogl_quaternion_init ()</h3>
245 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_init (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
246 <em class="parameter"><code><span class="type">float</span> angle</code></em>,
247 <em class="parameter"><code><span class="type">float</span> x</code></em>,
248 <em class="parameter"><code><span class="type">float</span> y</code></em>,
249 <em class="parameter"><code><span class="type">float</span> z</code></em>);</pre>
251 Initializes a quaternion that rotates <em class="parameter"><code>angle</code></em> degrees around the
252 axis vector (<em class="parameter"><code>x</code></em>, <em class="parameter"><code>y</code></em>, <em class="parameter"><code>z</code></em>). The axis vector does not need to be
255 <div class="variablelist"><table border="0">
256 <col align="left" valign="top">
259 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
260 <td>An uninitialized <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
264 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
265 <td>The angle you want to rotate around the given axis</td>
268 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
269 <td>The x component of your axis vector about which you want to
273 <td><p><span class="term"><em class="parameter"><code>y</code></em> :</span></p></td>
274 <td>The y component of your axis vector about which you want to
278 <td><p><span class="term"><em class="parameter"><code>z</code></em> :</span></p></td>
279 <td>The z component of your axis vector about which you want to
283 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
284 <td>A normalized, unit quaternion representing an orientation
285 rotated <em class="parameter"><code>angle</code></em> degrees around the axis vector (<em class="parameter"><code>x</code></em>, <em class="parameter"><code>y</code></em>, <em class="parameter"><code>z</code></em>)</td>
289 <p class="since">Since 2.0</p>
292 <div class="refsect2">
293 <a name="cogl-quaternion-init-from-angle-vector"></a><h3>cogl_quaternion_init_from_angle_vector ()</h3>
294 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_init_from_angle_vector
295 (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
296 <em class="parameter"><code><span class="type">float</span> angle</code></em>,
297 <em class="parameter"><code>const <span class="type">float</span> *axis3f</code></em>);</pre>
299 Initializes a quaternion that rotates <em class="parameter"><code>angle</code></em> degrees around the
300 given <em class="parameter"><code>axis</code></em> vector. The axis vector does not need to be
303 <div class="variablelist"><table border="0">
304 <col align="left" valign="top">
307 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
308 <td>An uninitialized <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
312 <td><p><span class="term"><em class="parameter"><code>axis3f</code></em> :</span></p></td>
313 <td>your 3 component axis vector about which you want to rotate.</td>
316 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
317 <td>A normalized, unit quaternion representing an orientation
318 rotated <em class="parameter"><code>angle</code></em> degrees around the given <em class="parameter"><code>axis</code></em> vector.</td>
322 <p class="since">Since 2.0</p>
325 <div class="refsect2">
326 <a name="cogl-quaternion-init-from-array"></a><h3>cogl_quaternion_init_from_array ()</h3>
327 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_init_from_array (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
328 <em class="parameter"><code>const <span class="type">float</span> *array</code></em>);</pre>
330 Initializes a [w (x, y,z)] quaternion directly from an array of 4
333 <div class="variablelist"><table border="0">
334 <col align="left" valign="top">
337 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
338 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
342 <td><p><span class="term"><em class="parameter"><code>array</code></em> :</span></p></td>
343 <td>An array of 4 floats (x,y,z),w</td>
347 <p class="since">Since 2.0</p>
350 <div class="refsect2">
351 <a name="cogl-quaternion-init-from-x-rotation"></a><h3>cogl_quaternion_init_from_x_rotation ()</h3>
352 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_init_from_x_rotation
353 (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
354 <em class="parameter"><code><span class="type">float</span> angle</code></em>);</pre>
356 XXX: check which direction this rotates
358 <div class="variablelist"><table border="0">
359 <col align="left" valign="top">
362 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
363 <td>An uninitialized <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
367 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
368 <td>The angle to rotate around the x axis</td>
372 <p class="since">Since 2.0</p>
375 <div class="refsect2">
376 <a name="cogl-quaternion-init-from-y-rotation"></a><h3>cogl_quaternion_init_from_y_rotation ()</h3>
377 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_init_from_y_rotation
378 (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
379 <em class="parameter"><code><span class="type">float</span> angle</code></em>);</pre>
380 <div class="variablelist"><table border="0">
381 <col align="left" valign="top">
384 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
385 <td>An uninitialized <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
389 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
390 <td>The angle to rotate around the y axis</td>
394 <p class="since">Since 2.0</p>
397 <div class="refsect2">
398 <a name="cogl-quaternion-init-from-z-rotation"></a><h3>cogl_quaternion_init_from_z_rotation ()</h3>
399 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_init_from_z_rotation
400 (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
401 <em class="parameter"><code><span class="type">float</span> angle</code></em>);</pre>
402 <div class="variablelist"><table border="0">
403 <col align="left" valign="top">
406 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
407 <td>An uninitialized <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
411 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
412 <td>The angle to rotate around the y axis</td>
416 <p class="since">Since 2.0</p>
419 <div class="refsect2">
420 <a name="cogl-quaternion-equal"></a><h3>cogl_quaternion_equal ()</h3>
421 <pre class="programlisting"><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a> cogl_quaternion_equal (<em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a> v1</code></em>,
422 <em class="parameter"><code><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a> v2</code></em>);</pre>
424 Compares that all the components of quaternions <em class="parameter"><code>a</code></em> and <em class="parameter"><code>b</code></em> are
428 An epsilon value is not used to compare the float components, but
429 the == operator is at least used so that 0 and -0 are considered
432 <div class="variablelist"><table border="0">
433 <col align="left" valign="top">
436 <td><p><span class="term"><em class="parameter"><code>v1</code></em> :</span></p></td>
437 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
441 <td><p><span class="term"><em class="parameter"><code>v2</code></em> :</span></p></td>
442 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
446 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
448 <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the quaternions are equal else <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a>.</td>
452 <p class="since">Since 2.0</p>
455 <div class="refsect2">
456 <a name="cogl-quaternion-copy"></a><h3>cogl_quaternion_copy ()</h3>
457 <pre class="programlisting"><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="returnvalue">CoglQuaternion</span></a> * cogl_quaternion_copy (<em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *src</code></em>);</pre>
459 Allocates a new <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> on the stack and initializes it with
460 the same values as <em class="parameter"><code>src</code></em>.
462 <div class="variablelist"><table border="0">
463 <col align="left" valign="top">
466 <td><p><span class="term"><em class="parameter"><code>src</code></em> :</span></p></td>
467 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
471 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
472 <td>A newly allocated <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> which should be freed
473 using <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-free" title="cogl_quaternion_free ()"><code class="function">cogl_quaternion_free()</code></a>
478 <p class="since">Since 2.0</p>
481 <div class="refsect2">
482 <a name="cogl-quaternion-free"></a><h3>cogl_quaternion_free ()</h3>
483 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_free (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);</pre>
485 Frees a <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> that was previously allocated via
486 <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-copy" title="cogl_quaternion_copy ()"><code class="function">cogl_quaternion_copy()</code></a>.
488 <div class="variablelist"><table border="0">
489 <col align="left" valign="top">
491 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
492 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
496 <p class="since">Since 2.0</p>
499 <div class="refsect2">
500 <a name="cogl-quaternion-get-rotation-angle"></a><h3>cogl_quaternion_get_rotation_angle ()</h3>
501 <pre class="programlisting"><span class="returnvalue">float</span> cogl_quaternion_get_rotation_angle (<em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);</pre>
502 <div class="variablelist"><table border="0">
503 <col align="left" valign="top">
505 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
506 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
510 <p class="since">Since 2.0</p>
513 <div class="refsect2">
514 <a name="cogl-quaternion-get-rotation-axis"></a><h3>cogl_quaternion_get_rotation_axis ()</h3>
515 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_get_rotation_axis (<em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
516 <em class="parameter"><code><span class="type">float</span> *vector3</code></em>);</pre>
517 <div class="variablelist"><table border="0">
518 <col align="left" valign="top">
520 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
521 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
525 <p class="since">Since 2.0</p>
528 <div class="refsect2">
529 <a name="cogl-quaternion-normalize"></a><h3>cogl_quaternion_normalize ()</h3>
530 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_normalize (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);</pre>
531 <div class="variablelist"><table border="0">
532 <col align="left" valign="top">
534 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
535 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
539 <p class="since">Since 2.0</p>
542 <div class="refsect2">
543 <a name="cogl-quaternion-dot-product"></a><h3>cogl_quaternion_dot_product ()</h3>
544 <pre class="programlisting"><span class="returnvalue">float</span> cogl_quaternion_dot_product (<em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *a</code></em>,
545 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *b</code></em>);</pre>
546 <div class="variablelist"><table border="0">
547 <col align="left" valign="top">
550 <td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
551 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
555 <td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td>
556 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
561 <p class="since">Since 2.0</p>
564 <div class="refsect2">
565 <a name="cogl-quaternion-invert"></a><h3>cogl_quaternion_invert ()</h3>
566 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_invert (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>);</pre>
567 <div class="variablelist"><table border="0">
568 <col align="left" valign="top">
570 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
571 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
575 <p class="since">Since 2.0</p>
578 <div class="refsect2">
579 <a name="cogl-quaternion-multiply"></a><h3>cogl_quaternion_multiply ()</h3>
580 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_multiply (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *result</code></em>,
581 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *left</code></em>,
582 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *right</code></em>);</pre>
584 This combines the rotations of two quaternions into <em class="parameter"><code>result</code></em>. The
585 operation is not commutative so the order is important because AxB
586 != BxA. Cogl follows the standard convention for quaternions here
587 so the rotations are applied <em class="parameter"><code>right</code></em> to <em class="parameter"><code>left</code></em>. This is similar to the
588 combining of matrices.
590 <div class="variablelist"><table border="0">
591 <col align="left" valign="top">
594 <td><p><span class="term"><em class="parameter"><code>result</code></em> :</span></p></td>
595 <td>The destination <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
599 <td><p><span class="term"><em class="parameter"><code>left</code></em> :</span></p></td>
600 <td>The second <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> rotation to apply</td>
603 <td><p><span class="term"><em class="parameter"><code>right</code></em> :</span></p></td>
604 <td>The first <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> rotation to apply</td>
608 <p class="since">Since 2.0</p>
611 <div class="refsect2">
612 <a name="cogl-quaternion-pow"></a><h3>cogl_quaternion_pow ()</h3>
613 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_pow (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *quaternion</code></em>,
614 <em class="parameter"><code><span class="type">float</span> exponent</code></em>);</pre>
615 <div class="variablelist"><table border="0">
616 <col align="left" valign="top">
618 <td><p><span class="term"><em class="parameter"><code>quaternion</code></em> :</span></p></td>
619 <td>A <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
623 <p class="since">Since 2.0</p>
626 <div class="refsect2">
627 <a name="cogl-quaternion-slerp"></a><h3>cogl_quaternion_slerp ()</h3>
628 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_slerp (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *result</code></em>,
629 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *a</code></em>,
630 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *b</code></em>,
631 <em class="parameter"><code><span class="type">float</span> t</code></em>);</pre>
633 Performs a spherical linear interpolation between two quaternions.
638 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
639 <li class="listitem">
642 <li class="listitem">
643 constant velocity: Yes
645 <li class="listitem">
646 torque minimal (travels along the surface of the 4-sphere): Yes
648 <li class="listitem">
649 more expensive than <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-nlerp" title="cogl_quaternion_nlerp ()"><code class="function">cogl_quaternion_nlerp()</code></a>
656 <div class="refsect2">
657 <a name="cogl-quaternion-nlerp"></a><h3>cogl_quaternion_nlerp ()</h3>
658 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_nlerp (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *result</code></em>,
659 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *a</code></em>,
660 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *b</code></em>,
661 <em class="parameter"><code><span class="type">float</span> t</code></em>);</pre>
663 Performs a normalized linear interpolation between two quaternions.
664 That is it does a linear interpolation of the quaternion components
665 and then normalizes the result. This will follow the shortest arc
666 between the two orientations (just like the <code class="function">slerp()</code> function) but
667 will not progress at a constant speed. Unlike <code class="function">slerp()</code> nlerp is
668 commutative which is useful if you are blending animations
669 together. (I.e. nlerp (tmp, a, b) followed by nlerp (result, tmp,
670 d) is the same as nlerp (tmp, a, d) followed by nlerp (result, tmp,
671 b)). Finally nlerp is cheaper than slerp so it can be a good choice
672 if you don't need the constant speed property of the <code class="function">slerp()</code> function.
677 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
678 <li class="listitem">
681 <li class="listitem">
682 constant velocity: No
684 <li class="listitem">
685 torque minimal (travels along the surface of the 4-sphere): Yes
687 <li class="listitem">
688 faster than <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#cogl-quaternion-slerp" title="cogl_quaternion_slerp ()"><code class="function">cogl_quaternion_slerp()</code></a>
693 <div class="variablelist"><table border="0">
694 <col align="left" valign="top">
697 <td><p><span class="term"><em class="parameter"><code>result</code></em> :</span></p></td>
698 <td>The destination <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
702 <td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
703 <td>The first <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
707 <td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td>
708 <td>The second <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a>
712 <td><p><span class="term"><em class="parameter"><code>t</code></em> :</span></p></td>
713 <td>The factor in the range [0,1] used to interpolate between
714 quaterion <em class="parameter"><code>a</code></em> and <em class="parameter"><code>b</code></em>.</td>
720 <div class="refsect2">
721 <a name="cogl-quaternion-squad"></a><h3>cogl_quaternion_squad ()</h3>
722 <pre class="programlisting"><span class="returnvalue">void</span> cogl_quaternion_squad (<em class="parameter"><code><a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *result</code></em>,
723 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *prev</code></em>,
724 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *a</code></em>,
725 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *b</code></em>,
726 <em class="parameter"><code>const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="type">CoglQuaternion</span></a> *next</code></em>,
727 <em class="parameter"><code><span class="type">float</span> t</code></em>);</pre>
728 <p class="since">Since 2.0</p>
731 <div class="refsect2">
732 <a name="cogl-get-static-identity-quaternion"></a><h3>cogl_get_static_identity_quaternion ()</h3>
733 <pre class="programlisting">const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="returnvalue">CoglQuaternion</span></a> * cogl_get_static_identity_quaternion
734 (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
736 Returns a pointer to a singleton quaternion constant describing the
737 canonical identity [1 (0, 0, 0)] which represents no rotation.
740 If you multiply a quaternion with the identity quaternion you will
741 get back the same value as the original quaternion.
743 <div class="variablelist"><table border="0">
744 <col align="left" valign="top">
746 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
747 <td>A pointer to an identity quaternion</td>
750 <p class="since">Since 2.0</p>
753 <div class="refsect2">
754 <a name="cogl-get-static-zero-quaternion"></a><h3>cogl_get_static_zero_quaternion ()</h3>
755 <pre class="programlisting">const <a class="link" href="cogl-2.0-experimental-Quaternions-(Rotations).html#CoglQuaternion" title="CoglQuaternion"><span class="returnvalue">CoglQuaternion</span></a> * cogl_get_static_zero_quaternion (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
756 <div class="variablelist"><table border="0">
757 <col align="left" valign="top">
759 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
760 <td>a pointer to a singleton quaternion constant describing a
761 rotation of 180 degrees around a degenerate axis:
765 <p class="since">Since 2.0</p>
771 Generated by GTK-Doc V1.18.1</div>