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>Fixed Point API</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="Cogl Reference Manual">
8 <link rel="up" href="ch01.html" title="Cogl - a modern 3D graphics API">
9 <link rel="prev" href="cogl-Bitmaps.html" title="Bitmaps">
10 <link rel="next" href="cogl-GType-Integration-API.html" title="GType Integration API">
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-Bitmaps.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="ch01.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 Reference Manual</th>
21 <td><a accesskey="n" href="cogl-GType-Integration-API.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-Fixed-Point-API.synopsis" class="shortcut">Top</a>
26 <a href="#cogl-Fixed-Point-API.description" class="shortcut">Description</a>
29 <div class="refentry">
30 <a name="cogl-Fixed-Point-API"></a><div class="titlepage"></div>
31 <div class="refnamediv"><table width="100%"><tr>
33 <h2><span class="refentrytitle"><a name="cogl-Fixed-Point-API.top_of_page"></a>Fixed Point API</span></h2>
34 <p>Fixed Point API — Fixed Point API</p>
36 <td valign="top" align="right"></td>
38 <div class="refsynopsisdiv">
39 <a name="cogl-Fixed-Point-API.synopsis"></a><h2>Synopsis</h2>
40 <pre class="synopsis">typedef <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed">CoglFixed</a>;
41 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-BITS:CAPS" title="COGL_FIXED_BITS">COGL_FIXED_BITS</a>
42 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-Q:CAPS" title="COGL_FIXED_Q">COGL_FIXED_Q</a>
43 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-MAX:CAPS" title="COGL_FIXED_MAX">COGL_FIXED_MAX</a>
44 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-MIN:CAPS" title="COGL_FIXED_MIN">COGL_FIXED_MIN</a>
46 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-FROM-FLOAT:CAPS" title="COGL_FIXED_FROM_FLOAT()">COGL_FIXED_FROM_FLOAT</a> (x)
47 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-TO-FLOAT:CAPS" title="COGL_FIXED_TO_FLOAT()">COGL_FIXED_TO_FLOAT</a> (x)
48 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-FROM-INT:CAPS" title="COGL_FIXED_FROM_INT()">COGL_FIXED_FROM_INT</a> (x)
49 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-TO-INT:CAPS" title="COGL_FIXED_TO_INT()">COGL_FIXED_TO_INT</a> (x)
50 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-FROM-DOUBLE:CAPS" title="COGL_FIXED_FROM_DOUBLE()">COGL_FIXED_FROM_DOUBLE</a> (x)
51 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-TO-DOUBLE:CAPS" title="COGL_FIXED_TO_DOUBLE()">COGL_FIXED_TO_DOUBLE</a> (x)
52 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FLOAT-TO-INT:CAPS" title="COGL_FLOAT_TO_INT()">COGL_FLOAT_TO_INT</a> (x)
53 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FLOAT-TO-UINT:CAPS" title="COGL_FLOAT_TO_UINT()">COGL_FLOAT_TO_UINT</a> (x)
55 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-EPSILON:CAPS" title="COGL_FIXED_EPSILON">COGL_FIXED_EPSILON</a>
56 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-1:CAPS" title="COGL_FIXED_1">COGL_FIXED_1</a>
57 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-0-5:CAPS" title="COGL_FIXED_0_5">COGL_FIXED_0_5</a>
58 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-30:CAPS" title="COGL_FIXED_30">COGL_FIXED_30</a>
59 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-45:CAPS" title="COGL_FIXED_45">COGL_FIXED_45</a>
60 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-60:CAPS" title="COGL_FIXED_60">COGL_FIXED_60</a>
61 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-90:CAPS" title="COGL_FIXED_90">COGL_FIXED_90</a>
62 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-120:CAPS" title="COGL_FIXED_120">COGL_FIXED_120</a>
63 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-180:CAPS" title="COGL_FIXED_180">COGL_FIXED_180</a>
64 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-240:CAPS" title="COGL_FIXED_240">COGL_FIXED_240</a>
65 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-255:CAPS" title="COGL_FIXED_255">COGL_FIXED_255</a>
66 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-270:CAPS" title="COGL_FIXED_270">COGL_FIXED_270</a>
67 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-360:CAPS" title="COGL_FIXED_360">COGL_FIXED_360</a>
69 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-MUL:CAPS" title="COGL_FIXED_MUL()">COGL_FIXED_MUL</a> (a,
71 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-DIV:CAPS" title="COGL_FIXED_DIV()">COGL_FIXED_DIV</a> (a,
73 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-MUL-DIV:CAPS" title="COGL_FIXED_MUL_DIV()">COGL_FIXED_MUL_DIV</a> (a,
76 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-FAST-DIV:CAPS" title="COGL_FIXED_FAST_DIV()">COGL_FIXED_FAST_DIV</a> (a,
78 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-FAST-MUL:CAPS" title="COGL_FIXED_FAST_MUL()">COGL_FIXED_FAST_MUL</a> (a,
80 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-FRACTION:CAPS" title="COGL_FIXED_FRACTION()">COGL_FIXED_FRACTION</a> (x)
81 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-FLOOR:CAPS" title="COGL_FIXED_FLOOR()">COGL_FIXED_FLOOR</a> (x)
82 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-CEIL:CAPS" title="COGL_FIXED_CEIL()">COGL_FIXED_CEIL</a> (x)
84 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-2-PI:CAPS" title="COGL_FIXED_2_PI">COGL_FIXED_2_PI</a>
85 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-PI:CAPS" title="COGL_FIXED_PI">COGL_FIXED_PI</a>
86 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-PI-2:CAPS" title="COGL_FIXED_PI_2">COGL_FIXED_PI_2</a>
87 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-PI-4:CAPS" title="COGL_FIXED_PI_4">COGL_FIXED_PI_4</a>
88 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-RADIANS-TO-DEGREES:CAPS" title="COGL_RADIANS_TO_DEGREES">COGL_RADIANS_TO_DEGREES</a>
90 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-SQRTI-ARG-10-PERCENT:CAPS" title="COGL_SQRTI_ARG_10_PERCENT">COGL_SQRTI_ARG_10_PERCENT</a>
91 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-SQRTI-ARG-5-PERCENT:CAPS" title="COGL_SQRTI_ARG_5_PERCENT">COGL_SQRTI_ARG_5_PERCENT</a>
92 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-SQRTI-ARG-MAX:CAPS" title="COGL_SQRTI_ARG_MAX">COGL_SQRTI_ARG_MAX</a>
93 <span class="returnvalue">int</span> <a class="link" href="cogl-Fixed-Point-API.html#cogl-sqrti" title="cogl_sqrti ()">cogl_sqrti</a> (<em class="parameter"><code><span class="type">int</span> x</code></em>);
95 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-atan2" title="cogl_fixed_atan2 ()">cogl_fixed_atan2</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>,
96 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> b</code></em>);
97 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-atan" title="cogl_fixed_atan ()">cogl_fixed_atan</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>);
98 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-cos" title="cogl_fixed_cos ()">cogl_fixed_cos</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> angle</code></em>);
99 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-log2" title="cogl_fixed_log2 ()">cogl_fixed_log2</a> (<em class="parameter"><code>unsigned <span class="type">int</span> x</code></em>);
100 unsigned <span class="returnvalue">int</span> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-pow" title="cogl_fixed_pow ()">cogl_fixed_pow</a> (<em class="parameter"><code>unsigned <span class="type">int</span> x</code></em>,
101 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> y</code></em>);
102 unsigned <span class="returnvalue">int</span> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-pow2" title="cogl_fixed_pow2 ()">cogl_fixed_pow2</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> x</code></em>);
103 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-sin" title="cogl_fixed_sin ()">cogl_fixed_sin</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> angle</code></em>);
104 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-sqrt" title="cogl_fixed_sqrt ()">cogl_fixed_sqrt</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> x</code></em>);
105 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-tan" title="cogl_fixed_tan ()">cogl_fixed_tan</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> angle</code></em>);
106 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-div" title="cogl_fixed_div ()">cogl_fixed_div</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>,
107 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> b</code></em>);
108 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-mul" title="cogl_fixed_mul ()">cogl_fixed_mul</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>,
109 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> b</code></em>);
110 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-fixed-mul-div" title="cogl_fixed_mul_div ()">cogl_fixed_mul_div</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>,
111 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> b</code></em>,
112 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> c</code></em>);
114 typedef <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle">CoglAngle</a>;
115 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-ANGLE-FROM-DEG:CAPS" title="COGL_ANGLE_FROM_DEG()">COGL_ANGLE_FROM_DEG</a> (x)
116 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-ANGLE-FROM-DEGX:CAPS" title="COGL_ANGLE_FROM_DEGX()">COGL_ANGLE_FROM_DEGX</a> (x)
117 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-ANGLE-TO-DEG:CAPS" title="COGL_ANGLE_TO_DEG()">COGL_ANGLE_TO_DEG</a> (x)
118 #define <a class="link" href="cogl-Fixed-Point-API.html#COGL-ANGLE-TO-DEGX:CAPS" title="COGL_ANGLE_TO_DEGX()">COGL_ANGLE_TO_DEGX</a> (x)
119 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-angle-cos" title="cogl_angle_cos ()">cogl_angle_cos</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a> angle</code></em>);
120 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-angle-sin" title="cogl_angle_sin ()">cogl_angle_sin</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a> angle</code></em>);
121 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> <a class="link" href="cogl-Fixed-Point-API.html#cogl-angle-tan" title="cogl_angle_tan ()">cogl_angle_tan</a> (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a> angle</code></em>);
124 <div class="refsect1">
125 <a name="cogl-Fixed-Point-API.description"></a><h2>Description</h2>
127 COGL has a fixed point API targeted at platforms without a floating
128 point unit, such as embedded devices. On such platforms this API should
129 be preferred to the floating point one as it does not trigger the slow
130 path of software emulation, relying on integer math for fixed-to-floating
131 and floating-to-fixed notations conversion.
134 It is not recommened for use on platforms with a floating point unit
135 (e.g. desktop systems), nor for use in language bindings.
138 Basic rules of Fixed Point arithmethic:
140 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
141 <li class="listitem"><p>Two fixed point numbers can be directly added, subtracted and
142 have their modulus taken.</p></li>
143 <li class="listitem"><p>To add other numerical type to a fixed point number it has to
144 be first converted to fixed point.</p></li>
145 <li class="listitem"><p>A fixed point number can be directly multiplied or divided by
147 <li class="listitem"><p>Two fixed point numbers can only be multiplied and divided by
148 the provided <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-MUL:CAPS" title="COGL_FIXED_MUL()"><code class="literal">COGL_FIXED_MUL</code></a> and <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-DIV:CAPS" title="COGL_FIXED_DIV()"><code class="literal">COGL_FIXED_DIV</code></a> macros.</p></li>
153 The fixed point API is available since COGL 1.0.
156 <div class="refsect1">
157 <a name="cogl-Fixed-Point-API.details"></a><h2>Details</h2>
158 <div class="refsect2">
159 <a name="CoglFixed"></a><h3>CoglFixed</h3>
160 <pre class="programlisting">typedef gint32 CoglFixed;
163 Fixed point number using a (16.16) notation.
167 <div class="refsect2">
168 <a name="COGL-FIXED-BITS:CAPS"></a><h3>COGL_FIXED_BITS</h3>
169 <pre class="programlisting">#define COGL_FIXED_BITS (32)
172 Evaluates to the number of bits used by the <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> type.
174 <p class="since">Since 1.0</p>
177 <div class="refsect2">
178 <a name="COGL-FIXED-Q:CAPS"></a><h3>COGL_FIXED_Q</h3>
179 <pre class="programlisting">#define COGL_FIXED_Q (COGL_FIXED_BITS - 16)
182 Evaluates to the number of bits used for the non-integer part
183 of the <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> type.
185 <p class="since">Since 1.0</p>
188 <div class="refsect2">
189 <a name="COGL-FIXED-MAX:CAPS"></a><h3>COGL_FIXED_MAX</h3>
190 <pre class="programlisting">#define COGL_FIXED_MAX (0x7fffffff)
193 The biggest number representable using <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a>
195 <p class="since">Since 1.0</p>
198 <div class="refsect2">
199 <a name="COGL-FIXED-MIN:CAPS"></a><h3>COGL_FIXED_MIN</h3>
200 <pre class="programlisting">#define COGL_FIXED_MIN (0x80000000)
203 The smallest number representable using <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a>
205 <p class="since">Since 1.0</p>
208 <div class="refsect2">
209 <a name="COGL-FIXED-FROM-FLOAT:CAPS"></a><h3>COGL_FIXED_FROM_FLOAT()</h3>
210 <pre class="programlisting">#define COGL_FIXED_FROM_FLOAT(x) ((float) cogl_double_to_fixed (x))
213 Converts <em class="parameter"><code>x</code></em> from a floating point to a fixed point notation.
215 <div class="variablelist"><table border="0">
216 <col align="left" valign="top">
218 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
219 <td>a floating point number</td>
222 <p class="since">Since 1.0</p>
225 <div class="refsect2">
226 <a name="COGL-FIXED-TO-FLOAT:CAPS"></a><h3>COGL_FIXED_TO_FLOAT()</h3>
227 <pre class="programlisting">#define COGL_FIXED_TO_FLOAT(x) ((float) ((int)(x) / 65536.0))
230 Converts <em class="parameter"><code>x</code></em> from a fixed point to a floating point notation, in
233 <div class="variablelist"><table border="0">
234 <col align="left" valign="top">
236 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
237 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
240 <p class="since">Since 1.0</p>
243 <div class="refsect2">
244 <a name="COGL-FIXED-FROM-INT:CAPS"></a><h3>COGL_FIXED_FROM_INT()</h3>
245 <pre class="programlisting">#define COGL_FIXED_FROM_INT(x) ((x) << COGL_FIXED_Q)
248 Converts <em class="parameter"><code>x</code></em> from an integer to a fixed point notation.
250 <div class="variablelist"><table border="0">
251 <col align="left" valign="top">
253 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
254 <td>an integer number</td>
257 <p class="since">Since 1.0</p>
260 <div class="refsect2">
261 <a name="COGL-FIXED-TO-INT:CAPS"></a><h3>COGL_FIXED_TO_INT()</h3>
262 <pre class="programlisting">#define COGL_FIXED_TO_INT(x) ((x) >> COGL_FIXED_Q)
265 Converts <em class="parameter"><code>x</code></em> from a fixed point notation to an integer, dropping
266 the fractional part without rounding.
268 <div class="variablelist"><table border="0">
269 <col align="left" valign="top">
271 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
272 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
275 <p class="since">Since 1.0</p>
278 <div class="refsect2">
279 <a name="COGL-FIXED-FROM-DOUBLE:CAPS"></a><h3>COGL_FIXED_FROM_DOUBLE()</h3>
280 <pre class="programlisting">#define COGL_FIXED_FROM_DOUBLE(x) (cogl_double_to_fixed (x))
283 Converts <em class="parameter"><code>x</code></em> from a double precision, floating point to a fixed
286 <div class="variablelist"><table border="0">
287 <col align="left" valign="top">
289 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
290 <td>a floating point number</td>
293 <p class="since">Since 1.0</p>
296 <div class="refsect2">
297 <a name="COGL-FIXED-TO-DOUBLE:CAPS"></a><h3>COGL_FIXED_TO_DOUBLE()</h3>
298 <pre class="programlisting">#define COGL_FIXED_TO_DOUBLE(x) ((double) ((int)(x) / 65536.0))
301 Converts <em class="parameter"><code>x</code></em> from a fixed point to a floating point notation, in
304 <div class="variablelist"><table border="0">
305 <col align="left" valign="top">
307 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
308 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
311 <p class="since">Since 1.0</p>
314 <div class="refsect2">
315 <a name="COGL-FLOAT-TO-INT:CAPS"></a><h3>COGL_FLOAT_TO_INT()</h3>
316 <pre class="programlisting">#define COGL_FLOAT_TO_INT(x) (cogl_double_to_int ((x)))
319 Converts <em class="parameter"><code>x</code></em> from a floating point notation to a signed integer.
321 <div class="variablelist"><table border="0">
322 <col align="left" valign="top">
324 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
325 <td>a floatint point number</td>
328 <p class="since">Since 1.0</p>
331 <div class="refsect2">
332 <a name="COGL-FLOAT-TO-UINT:CAPS"></a><h3>COGL_FLOAT_TO_UINT()</h3>
333 <pre class="programlisting">#define COGL_FLOAT_TO_UINT(x) (cogl_double_to_uint ((x)))
336 Converts <em class="parameter"><code>x</code></em> from a floating point notation to an unsigned integer.
338 <div class="variablelist"><table border="0">
339 <col align="left" valign="top">
341 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
342 <td>a floatint point number</td>
345 <p class="since">Since 1.0</p>
348 <div class="refsect2">
349 <a name="COGL-FIXED-EPSILON:CAPS"></a><h3>COGL_FIXED_EPSILON</h3>
350 <pre class="programlisting">#define COGL_FIXED_EPSILON (1)
353 A very small number expressed as a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number.
355 <p class="since">Since 1.0</p>
358 <div class="refsect2">
359 <a name="COGL-FIXED-1:CAPS"></a><h3>COGL_FIXED_1</h3>
360 <pre class="programlisting">#define COGL_FIXED_1 (1 << COGL_FIXED_Q)
363 The number 1 expressed as a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number.
365 <p class="since">Since 1.0</p>
368 <div class="refsect2">
369 <a name="COGL-FIXED-0-5:CAPS"></a><h3>COGL_FIXED_0_5</h3>
370 <pre class="programlisting">#define COGL_FIXED_0_5 (32768)
373 The number 0.5 expressed as a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number.
375 <p class="since">Since 1.0</p>
378 <div class="refsect2">
379 <a name="COGL-FIXED-30:CAPS"></a><h3>COGL_FIXED_30</h3>
380 <pre class="programlisting">#define COGL_FIXED_30 (COGL_FIXED_FROM_INT (30))
383 Evaluates to the number 30 in fixed point notation.
385 <p class="since">Since 1.0</p>
388 <div class="refsect2">
389 <a name="COGL-FIXED-45:CAPS"></a><h3>COGL_FIXED_45</h3>
390 <pre class="programlisting">#define COGL_FIXED_45 (COGL_FIXED_FROM_INT (45))
393 Evaluates to the number 45 in fixed point notation.
395 <p class="since">Since 1.0</p>
398 <div class="refsect2">
399 <a name="COGL-FIXED-60:CAPS"></a><h3>COGL_FIXED_60</h3>
400 <pre class="programlisting">#define COGL_FIXED_60 (COGL_FIXED_FROM_INT (60))
403 Evaluates to the number 60 in fixed point notation.
405 <p class="since">Since 1.0</p>
408 <div class="refsect2">
409 <a name="COGL-FIXED-90:CAPS"></a><h3>COGL_FIXED_90</h3>
410 <pre class="programlisting">#define COGL_FIXED_90 (COGL_FIXED_FROM_INT (90))
413 Evaluates to the number 90 in fixed point notation.
415 <p class="since">Since 1.0</p>
418 <div class="refsect2">
419 <a name="COGL-FIXED-120:CAPS"></a><h3>COGL_FIXED_120</h3>
420 <pre class="programlisting">#define COGL_FIXED_120 (COGL_FIXED_FROM_INT (120))
423 Evaluates to the number 120 in fixed point notation.
425 <p class="since">Since 1.0</p>
428 <div class="refsect2">
429 <a name="COGL-FIXED-180:CAPS"></a><h3>COGL_FIXED_180</h3>
430 <pre class="programlisting">#define COGL_FIXED_180 (COGL_FIXED_FROM_INT (180))
433 Evaluates to the number 180 in fixed point notation.
435 <p class="since">Since 1.0</p>
438 <div class="refsect2">
439 <a name="COGL-FIXED-240:CAPS"></a><h3>COGL_FIXED_240</h3>
440 <pre class="programlisting">#define COGL_FIXED_240 (COGL_FIXED_FROM_INT (240))
443 Evaluates to the number 240 in fixed point notation.
445 <p class="since">Since 1.0</p>
448 <div class="refsect2">
449 <a name="COGL-FIXED-255:CAPS"></a><h3>COGL_FIXED_255</h3>
450 <pre class="programlisting">#define COGL_FIXED_255 (COGL_FIXED_FROM_INT (255))
453 Evaluates to the number 255 in fixed point notation.
455 <p class="since">Since 1.0</p>
458 <div class="refsect2">
459 <a name="COGL-FIXED-270:CAPS"></a><h3>COGL_FIXED_270</h3>
460 <pre class="programlisting">#define COGL_FIXED_270 (COGL_FIXED_FROM_INT (270))
463 Evaluates to the number 270 in fixed point notation.
465 <p class="since">Since 1.0</p>
468 <div class="refsect2">
469 <a name="COGL-FIXED-360:CAPS"></a><h3>COGL_FIXED_360</h3>
470 <pre class="programlisting">#define COGL_FIXED_360 (COGL_FIXED_FROM_INT (360))
473 Evaluates to the number 360 in fixed point notation.
475 <p class="since">Since 1.0</p>
478 <div class="refsect2">
479 <a name="COGL-FIXED-MUL:CAPS"></a><h3>COGL_FIXED_MUL()</h3>
480 <pre class="programlisting">#define COGL_FIXED_MUL(a,b) (cogl_fixed_mul ((a), (b)))
485 <div class="variablelist"><table border="0">
486 <col align="left" valign="top">
489 <td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
490 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
493 <td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td>
494 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
498 <p class="since">Since 1.0</p>
501 <div class="refsect2">
502 <a name="COGL-FIXED-DIV:CAPS"></a><h3>COGL_FIXED_DIV()</h3>
503 <pre class="programlisting">#define COGL_FIXED_DIV(a,b) (cogl_fixed_div ((a), (b)))
508 <div class="variablelist"><table border="0">
509 <col align="left" valign="top">
512 <td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
513 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
516 <td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td>
517 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
521 <p class="since">Since 1.0</p>
524 <div class="refsect2">
525 <a name="COGL-FIXED-MUL-DIV:CAPS"></a><h3>COGL_FIXED_MUL_DIV()</h3>
526 <pre class="programlisting">#define COGL_FIXED_MUL_DIV(a,b,c) (cogl_fixed_mul_div ((a), (b), (c)))
529 Computes ((a * b) / c). It is logically equivalent to:
533 <div class="informalexample">
534 <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
537 <td class="listing_lines" align="right"><pre>1</pre></td>
538 <td class="listing_code"><pre class="programlisting"><span class="normal">res </span><span class="symbol">=</span><span class="normal"> </span><span class="function"><a href="cogl-Fixed-Point-API.html#COGL-FIXED-DIV:CAPS">COGL_FIXED_DIV</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="cogl-Fixed-Point-API.html#COGL-FIXED-MUL:CAPS">COGL_FIXED_MUL</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">a</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">),</span><span class="normal"> c</span><span class="symbol">);</span></pre></td>
547 But it is shorter to type.
549 <div class="variablelist"><table border="0">
550 <col align="left" valign="top">
553 <td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
554 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
557 <td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td>
558 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
561 <td><p><span class="term"><em class="parameter"><code>c</code></em> :</span></p></td>
562 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
566 <p class="since">Since 1.0</p>
569 <div class="refsect2">
570 <a name="COGL-FIXED-FAST-DIV:CAPS"></a><h3>COGL_FIXED_FAST_DIV()</h3>
571 <pre class="programlisting">#define COGL_FIXED_FAST_DIV(a,b) ((((a) << 8) / (b)) << 8)
574 Fast version of <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-DIV:CAPS" title="COGL_FIXED_DIV()"><code class="literal">COGL_FIXED_DIV</code></a>, implemented as a macro.
578 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
579 <h3 class="title">Note</h3>This macro might lose precision. If the precision of the result
580 is important use <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-DIV:CAPS" title="COGL_FIXED_DIV()"><code class="literal">COGL_FIXED_DIV</code></a> instead.</div>
583 <div class="variablelist"><table border="0">
584 <col align="left" valign="top">
587 <td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
588 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
591 <td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td>
592 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
596 <p class="since">Since 1.0</p>
599 <div class="refsect2">
600 <a name="COGL-FIXED-FAST-MUL:CAPS"></a><h3>COGL_FIXED_FAST_MUL()</h3>
601 <pre class="programlisting">#define COGL_FIXED_FAST_MUL(a,b) ((a) >> 8) * ((b) >> 8)
604 Fast version of <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-MUL:CAPS" title="COGL_FIXED_MUL()"><code class="literal">COGL_FIXED_MUL</code></a>, implemented as a macro.
608 <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
609 <h3 class="title">Note</h3>This macro might lose precision. If the precision of the result
610 is important use <a class="link" href="cogl-Fixed-Point-API.html#COGL-FIXED-MUL:CAPS" title="COGL_FIXED_MUL()"><code class="literal">COGL_FIXED_MUL</code></a> instead.</div>
613 <div class="variablelist"><table border="0">
614 <col align="left" valign="top">
617 <td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
618 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
621 <td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td>
622 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
626 <p class="since">Since 1.0</p>
629 <div class="refsect2">
630 <a name="COGL-FIXED-FRACTION:CAPS"></a><h3>COGL_FIXED_FRACTION()</h3>
631 <pre class="programlisting">#define COGL_FIXED_FRACTION(x) ((x) & ((1 << COGL_FIXED_Q) - 1))
634 Retrieves the fractionary part of <em class="parameter"><code>x</code></em>.
636 <div class="variablelist"><table border="0">
637 <col align="left" valign="top">
639 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
640 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
643 <p class="since">Since 1.0</p>
646 <div class="refsect2">
647 <a name="COGL-FIXED-FLOOR:CAPS"></a><h3>COGL_FIXED_FLOOR()</h3>
648 <pre class="programlisting">#define COGL_FIXED_FLOOR(x)</pre>
650 Rounds down a fixed point number to the previous integer.
652 <div class="variablelist"><table border="0">
653 <col align="left" valign="top">
655 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
656 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
659 <p class="since">Since 1.0</p>
662 <div class="refsect2">
663 <a name="COGL-FIXED-CEIL:CAPS"></a><h3>COGL_FIXED_CEIL()</h3>
664 <pre class="programlisting">#define COGL_FIXED_CEIL(x) (COGL_FIXED_FLOOR ((x) + 0xffff))
667 Rounds up a fixed point number to the next integer.
669 <div class="variablelist"><table border="0">
670 <col align="left" valign="top">
672 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
673 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
676 <p class="since">Since 1.0</p>
679 <div class="refsect2">
680 <a name="COGL-FIXED-2-PI:CAPS"></a><h3>COGL_FIXED_2_PI</h3>
681 <pre class="programlisting">#define COGL_FIXED_2_PI (0x0006487f)
684 Two times pi, expressed as a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number.
686 <p class="since">Since 1.0</p>
689 <div class="refsect2">
690 <a name="COGL-FIXED-PI:CAPS"></a><h3>COGL_FIXED_PI</h3>
691 <pre class="programlisting">#define COGL_FIXED_PI (0x0003243f)
694 The number pi, expressed as a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number.
696 <p class="since">Since 1.0</p>
699 <div class="refsect2">
700 <a name="COGL-FIXED-PI-2:CAPS"></a><h3>COGL_FIXED_PI_2</h3>
701 <pre class="programlisting">#define COGL_FIXED_PI_2 (0x00019220)
704 Half pi, expressed as a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number.
706 <p class="since">Since 1.0</p>
709 <div class="refsect2">
710 <a name="COGL-FIXED-PI-4:CAPS"></a><h3>COGL_FIXED_PI_4</h3>
711 <pre class="programlisting">#define COGL_FIXED_PI_4 (0x0000c910)
714 pi / 4, expressed as <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number.
716 <p class="since">Since 1.0</p>
719 <div class="refsect2">
720 <a name="COGL-RADIANS-TO-DEGREES:CAPS"></a><h3>COGL_RADIANS_TO_DEGREES</h3>
721 <pre class="programlisting">#define COGL_RADIANS_TO_DEGREES (0x394bb8)
724 Evaluates to 180 / pi in fixed point notation.
726 <p class="since">Since 1.0</p>
729 <div class="refsect2">
730 <a name="COGL-SQRTI-ARG-10-PERCENT:CAPS"></a><h3>COGL_SQRTI_ARG_10_PERCENT</h3>
731 <pre class="programlisting">#define COGL_SQRTI_ARG_10_PERCENT 5590
734 Maximum argument that can be passed to <a class="link" href="cogl-Fixed-Point-API.html#cogl-sqrti" title="cogl_sqrti ()"><code class="function">cogl_sqrti()</code></a> for which the
735 resulting error is < 10%
737 <p class="since">Since 1.0</p>
740 <div class="refsect2">
741 <a name="COGL-SQRTI-ARG-5-PERCENT:CAPS"></a><h3>COGL_SQRTI_ARG_5_PERCENT</h3>
742 <pre class="programlisting">#define COGL_SQRTI_ARG_5_PERCENT 210
745 Maximum argument that can be passed to <a class="link" href="cogl-Fixed-Point-API.html#cogl-sqrti" title="cogl_sqrti ()"><code class="function">cogl_sqrti()</code></a> for which the
746 resulting error is < 5%
748 <p class="since">Since 1.0</p>
751 <div class="refsect2">
752 <a name="COGL-SQRTI-ARG-MAX:CAPS"></a><h3>COGL_SQRTI_ARG_MAX</h3>
753 <pre class="programlisting">#define COGL_SQRTI_ARG_MAX 0x3fffff
756 Maximum argument that can be passed to <a class="link" href="cogl-Fixed-Point-API.html#cogl-sqrti" title="cogl_sqrti ()"><code class="function">cogl_sqrti()</code></a> function.
758 <p class="since">Since 1.0</p>
761 <div class="refsect2">
762 <a name="cogl-sqrti"></a><h3>cogl_sqrti ()</h3>
763 <pre class="programlisting"><span class="returnvalue">int</span> cogl_sqrti (<em class="parameter"><code><span class="type">int</span> x</code></em>);</pre>
765 Very fast fixed point implementation of square root for integers.
768 This function is at least 6x faster than clib <code class="function">sqrt()</code> on x86, and (this is
769 not a typo!) about 500x faster on ARM without FPU. It's error is < 5%
770 for arguments < <a class="link" href="cogl-Fixed-Point-API.html#COGL-SQRTI-ARG-5-PERCENT:CAPS" title="COGL_SQRTI_ARG_5_PERCENT"><code class="literal">COGL_SQRTI_ARG_5_PERCENT</code></a> and < 10% for arguments <
771 <a class="link" href="cogl-Fixed-Point-API.html#COGL-SQRTI-ARG-10-PERCENT:CAPS" title="COGL_SQRTI_ARG_10_PERCENT"><code class="literal">COGL_SQRTI_ARG_10_PERCENT</code></a>. The maximum argument that can be passed to
772 this function is COGL_SQRTI_ARG_MAX.
774 <div class="variablelist"><table border="0">
775 <col align="left" valign="top">
778 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
779 <td>integer value</td>
782 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
783 <td>integer square root.</td>
787 <p class="since">Since 0.2</p>
790 <div class="refsect2">
791 <a name="cogl-fixed-atan2"></a><h3>cogl_fixed_atan2 ()</h3>
792 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_atan2 (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>,
793 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> b</code></em>);</pre>
795 Computes the arc tangent of <em class="parameter"><code>a</code></em> / <em class="parameter"><code>b</code></em> but uses the sign of both
796 arguments to return the angle in right quadrant.
798 <div class="variablelist"><table border="0">
799 <col align="left" valign="top">
802 <td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
803 <td>the numerator as a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
806 <td><p><span class="term"><em class="parameter"><code>b</code></em> :</span></p></td>
807 <td>the denominator as a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
810 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
811 <td>the arc tangent of the passed fraction, in fixed point
816 <p class="since">Since 1.0</p>
819 <div class="refsect2">
820 <a name="cogl-fixed-atan"></a><h3>cogl_fixed_atan ()</h3>
821 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_atan (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>);</pre>
823 Computes the arc tangent of <em class="parameter"><code>a</code></em>.
825 <div class="variablelist"><table border="0">
826 <col align="left" valign="top">
829 <td><p><span class="term"><em class="parameter"><code>a</code></em> :</span></p></td>
830 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
833 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
834 <td>the arc tangent of the passed value, in fixed point notation</td>
838 <p class="since">Since 1.0</p>
841 <div class="refsect2">
842 <a name="cogl-fixed-cos"></a><h3>cogl_fixed_cos ()</h3>
843 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_cos (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> angle</code></em>);</pre>
845 Computes the cosine of <em class="parameter"><code>angle</code></em>.
847 <div class="variablelist"><table border="0">
848 <col align="left" valign="top">
851 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
852 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
855 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
856 <td>the cosine of the passed angle, in fixed point notation</td>
860 <p class="since">Since 1.0</p>
863 <div class="refsect2">
864 <a name="cogl-fixed-log2"></a><h3>cogl_fixed_log2 ()</h3>
865 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_log2 (<em class="parameter"><code>unsigned <span class="type">int</span> x</code></em>);</pre>
867 Calculates base 2 logarithm.
870 This function is some 2.5 times faster on x86, and over 12 times faster on
871 fpu-less arm, than using libc <code class="function">log()</code>.
873 <div class="variablelist"><table border="0">
874 <col align="left" valign="top">
877 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
878 <td>value to calculate base 2 logarithm from</td>
881 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
882 <td>base 2 logarithm.</td>
886 <p class="since">Since 1.0</p>
889 <div class="refsect2">
890 <a name="cogl-fixed-pow"></a><h3>cogl_fixed_pow ()</h3>
891 <pre class="programlisting">unsigned <span class="returnvalue">int</span> cogl_fixed_pow (<em class="parameter"><code>unsigned <span class="type">int</span> x</code></em>,
892 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> y</code></em>);</pre>
894 Calculates <em class="parameter"><code>x</code></em> to the <em class="parameter"><code>y</code></em> power.
896 <div class="variablelist"><table border="0">
897 <col align="left" valign="top">
900 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
904 <td><p><span class="term"><em class="parameter"><code>y</code></em> :</span></p></td>
906 <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> exponent</td>
909 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
910 <td>the power of <em class="parameter"><code>x</code></em> to the <em class="parameter"><code>y</code></em>
915 <p class="since">Since 1.0</p>
918 <div class="refsect2">
919 <a name="cogl-fixed-pow2"></a><h3>cogl_fixed_pow2 ()</h3>
920 <pre class="programlisting">unsigned <span class="returnvalue">int</span> cogl_fixed_pow2 (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> x</code></em>);</pre>
922 Calculates 2 to the <em class="parameter"><code>x</code></em> power.
925 This function is around 11 times faster on x86, and around 22 times faster
926 on fpu-less arm than libc pow(2, x).
928 <div class="variablelist"><table border="0">
929 <col align="left" valign="top">
932 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
933 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
936 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
937 <td>the power of 2 to the passed value</td>
941 <p class="since">Since 1.0</p>
944 <div class="refsect2">
945 <a name="cogl-fixed-sin"></a><h3>cogl_fixed_sin ()</h3>
946 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_sin (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> angle</code></em>);</pre>
948 Computes the sine of <em class="parameter"><code>angle</code></em>.
950 <div class="variablelist"><table border="0">
951 <col align="left" valign="top">
954 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
955 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
958 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
959 <td>the sine of the passed angle, in fixed point notation</td>
963 <p class="since">Since 1.0</p>
966 <div class="refsect2">
967 <a name="cogl-fixed-sqrt"></a><h3>cogl_fixed_sqrt ()</h3>
968 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_sqrt (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> x</code></em>);</pre>
970 Computes the square root of <em class="parameter"><code>x</code></em>.
972 <div class="variablelist"><table border="0">
973 <col align="left" valign="top">
976 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
977 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
980 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
981 <td>the square root of the passed value, in floating point
986 <p class="since">Since 1.0</p>
989 <div class="refsect2">
990 <a name="cogl-fixed-tan"></a><h3>cogl_fixed_tan ()</h3>
991 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_tan (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> angle</code></em>);</pre>
993 Computes the tangent of <em class="parameter"><code>angle</code></em>.
995 <div class="variablelist"><table border="0">
996 <col align="left" valign="top">
999 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
1000 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> number</td>
1003 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1004 <td>the tangent of the passed angle, in fixed point notation</td>
1008 <p class="since">Since 1.0</p>
1011 <div class="refsect2">
1012 <a name="cogl-fixed-div"></a><h3>cogl_fixed_div ()</h3>
1013 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_div (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>,
1014 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> b</code></em>);</pre>
1017 <div class="refsect2">
1018 <a name="cogl-fixed-mul"></a><h3>cogl_fixed_mul ()</h3>
1019 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_mul (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>,
1020 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> b</code></em>);</pre>
1023 <div class="refsect2">
1024 <a name="cogl-fixed-mul-div"></a><h3>cogl_fixed_mul_div ()</h3>
1025 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_fixed_mul_div (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> a</code></em>,
1026 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> b</code></em>,
1027 <em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="type">CoglFixed</span></a> c</code></em>);</pre>
1030 <div class="refsect2">
1031 <a name="CoglAngle"></a><h3>CoglAngle</h3>
1032 <pre class="programlisting">typedef gint32 CoglAngle;
1035 Integer representation of an angle such that 1024 corresponds to
1036 full circle (i.e., 2 * pi).
1038 <p class="since">Since 1.0</p>
1041 <div class="refsect2">
1042 <a name="COGL-ANGLE-FROM-DEG:CAPS"></a><h3>COGL_ANGLE_FROM_DEG()</h3>
1043 <pre class="programlisting">#define COGL_ANGLE_FROM_DEG(x) (COGL_FLOAT_TO_INT (((float)(x) * 1024.0f) / 360.0f))
1046 Converts an angle in degrees into a <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a>.
1048 <div class="variablelist"><table border="0">
1049 <col align="left" valign="top">
1051 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
1052 <td>an angle in degrees in floating point notation</td>
1055 <p class="since">Since 1.0</p>
1058 <div class="refsect2">
1059 <a name="COGL-ANGLE-FROM-DEGX:CAPS"></a><h3>COGL_ANGLE_FROM_DEGX()</h3>
1060 <pre class="programlisting">#define COGL_ANGLE_FROM_DEGX(x) (COGL_FIXED_TO_INT ((((x) / 360) * 1024) + COGL_FIXED_0_5))
1063 Converts an angle in degrees into a <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a>.
1065 <div class="variablelist"><table border="0">
1066 <col align="left" valign="top">
1068 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
1069 <td>an angle in degrees in fixed point notation</td>
1072 <p class="since">Since 1.0</p>
1075 <div class="refsect2">
1076 <a name="COGL-ANGLE-TO-DEG:CAPS"></a><h3>COGL_ANGLE_TO_DEG()</h3>
1077 <pre class="programlisting">#define COGL_ANGLE_TO_DEG(x) (((float)(x) * 360.0) / 1024.0)
1080 Converts a <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a> into an angle in degrees, using floatint point
1083 <div class="variablelist"><table border="0">
1084 <col align="left" valign="top">
1086 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
1087 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a>
1091 <p class="since">Since 1.0</p>
1094 <div class="refsect2">
1095 <a name="COGL-ANGLE-TO-DEGX:CAPS"></a><h3>COGL_ANGLE_TO_DEGX()</h3>
1096 <pre class="programlisting">#define COGL_ANGLE_TO_DEGX(x) (COGL_FIXED_FROM_INT ((x) * 45) / 128)
1099 Converts a <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a> into an angle in degrees, using fixed point notation
1101 <div class="variablelist"><table border="0">
1102 <col align="left" valign="top">
1104 <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td>
1105 <td>a <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a>
1109 <p class="since">Since 1.0</p>
1112 <div class="refsect2">
1113 <a name="cogl-angle-cos"></a><h3>cogl_angle_cos ()</h3>
1114 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_angle_cos (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a> angle</code></em>);</pre>
1116 Computes the cosine of <em class="parameter"><code>angle</code></em>
1118 <div class="variablelist"><table border="0">
1119 <col align="left" valign="top">
1122 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
1123 <td>an angle expressed using <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a>
1127 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1128 <td>the cosine of the passed angle</td>
1132 <p class="since">Since 1.0</p>
1135 <div class="refsect2">
1136 <a name="cogl-angle-sin"></a><h3>cogl_angle_sin ()</h3>
1137 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_angle_sin (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a> angle</code></em>);</pre>
1139 Computes the sine of <em class="parameter"><code>angle</code></em>
1141 <div class="variablelist"><table border="0">
1142 <col align="left" valign="top">
1145 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
1146 <td>an angle expressed using <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a>
1150 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1151 <td>the sine of the passed angle</td>
1155 <p class="since">Since 1.0</p>
1158 <div class="refsect2">
1159 <a name="cogl-angle-tan"></a><h3>cogl_angle_tan ()</h3>
1160 <pre class="programlisting"><a class="link" href="cogl-Fixed-Point-API.html#CoglFixed" title="CoglFixed"><span class="returnvalue">CoglFixed</span></a> cogl_angle_tan (<em class="parameter"><code><a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a> angle</code></em>);</pre>
1162 Computes the tangent of <em class="parameter"><code>angle</code></em>
1164 <div class="variablelist"><table border="0">
1165 <col align="left" valign="top">
1168 <td><p><span class="term"><em class="parameter"><code>angle</code></em> :</span></p></td>
1169 <td>an angle expressed using <a class="link" href="cogl-Fixed-Point-API.html#CoglAngle" title="CoglAngle"><span class="type">CoglAngle</span></a>
1173 <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
1174 <td>the tangent of the passed angle</td>
1178 <p class="since">Since 1.0</p>
1182 <div class="footer">
1184 Generated by GTK-Doc V1.18.1</div>