~oem-solutions-group/unity-2d/clutter-1.0

« back to all changes in this revision

Viewing changes to doc/reference/cogl/xml/cogl-fixed.xml

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-03-21 13:27:56 UTC
  • mto: (2.1.3 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100321132756-nf8yd30yxo3zzwcm
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0"?>
2
 
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3
 
               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
4
 
<!ENTITY version "1.0.8">
5
 
]>
6
 
<refentry id="cogl-Fixed-Point-API">
7
 
<refmeta>
8
 
<refentrytitle role="top_of_page" id="cogl-Fixed-Point-API.top_of_page">Fixed Point API</refentrytitle>
9
 
<manvolnum>3</manvolnum>
10
 
<refmiscinfo>COGL Library</refmiscinfo>
11
 
</refmeta>
12
 
 
13
 
<refnamediv>
14
 
<refname>Fixed Point API</refname>
15
 
<refpurpose>Fixed Point API</refpurpose>
16
 
</refnamediv>
17
 
 
18
 
<refsynopsisdiv id="cogl-Fixed-Point-API.synopsis" role="synopsis">
19
 
<title role="synopsis.title">Synopsis</title>
20
 
 
21
 
<synopsis>
22
 
typedef             <link linkend="CoglFixed">CoglFixed</link>;
23
 
#define             <link linkend="COGL-FIXED-BITS--CAPS">COGL_FIXED_BITS</link>
24
 
#define             <link linkend="COGL-FIXED-Q--CAPS">COGL_FIXED_Q</link>
25
 
#define             <link linkend="COGL-FIXED-MAX--CAPS">COGL_FIXED_MAX</link>
26
 
#define             <link linkend="COGL-FIXED-MIN--CAPS">COGL_FIXED_MIN</link>
27
 
 
28
 
#define             <link linkend="COGL-FIXED-FROM-FLOAT--CAPS">COGL_FIXED_FROM_FLOAT</link>               (x)
29
 
#define             <link linkend="COGL-FIXED-TO-FLOAT--CAPS">COGL_FIXED_TO_FLOAT</link>                 (x)
30
 
#define             <link linkend="COGL-FIXED-FROM-INT--CAPS">COGL_FIXED_FROM_INT</link>                 (x)
31
 
#define             <link linkend="COGL-FIXED-TO-INT--CAPS">COGL_FIXED_TO_INT</link>                   (x)
32
 
#define             <link linkend="COGL-FIXED-FROM-DOUBLE--CAPS">COGL_FIXED_FROM_DOUBLE</link>              (x)
33
 
#define             <link linkend="COGL-FIXED-TO-DOUBLE--CAPS">COGL_FIXED_TO_DOUBLE</link>                (x)
34
 
#define             <link linkend="COGL-FLOAT-TO-INT--CAPS">COGL_FLOAT_TO_INT</link>                   (x)
35
 
#define             <link linkend="COGL-FLOAT-TO-UINT--CAPS">COGL_FLOAT_TO_UINT</link>                  (x)
36
 
 
37
 
#define             <link linkend="COGL-FIXED-EPSILON--CAPS">COGL_FIXED_EPSILON</link>
38
 
#define             <link linkend="COGL-FIXED-1--CAPS">COGL_FIXED_1</link>
39
 
#define             <link linkend="COGL-FIXED-0-5--CAPS">COGL_FIXED_0_5</link>
40
 
#define             <link linkend="COGL-FIXED-30--CAPS">COGL_FIXED_30</link>
41
 
#define             <link linkend="COGL-FIXED-45--CAPS">COGL_FIXED_45</link>
42
 
#define             <link linkend="COGL-FIXED-60--CAPS">COGL_FIXED_60</link>
43
 
#define             <link linkend="COGL-FIXED-90--CAPS">COGL_FIXED_90</link>
44
 
#define             <link linkend="COGL-FIXED-120--CAPS">COGL_FIXED_120</link>
45
 
#define             <link linkend="COGL-FIXED-180--CAPS">COGL_FIXED_180</link>
46
 
#define             <link linkend="COGL-FIXED-240--CAPS">COGL_FIXED_240</link>
47
 
#define             <link linkend="COGL-FIXED-255--CAPS">COGL_FIXED_255</link>
48
 
#define             <link linkend="COGL-FIXED-270--CAPS">COGL_FIXED_270</link>
49
 
#define             <link linkend="COGL-FIXED-360--CAPS">COGL_FIXED_360</link>
50
 
 
51
 
#define             <link linkend="COGL-FIXED-MUL--CAPS">COGL_FIXED_MUL</link>                      (a,b)
52
 
#define             <link linkend="COGL-FIXED-DIV--CAPS">COGL_FIXED_DIV</link>                      (a,b)
53
 
#define             <link linkend="COGL-FIXED-MUL-DIV--CAPS">COGL_FIXED_MUL_DIV</link>                  (a,b,c)
54
 
#define             <link linkend="COGL-FIXED-FAST-DIV--CAPS">COGL_FIXED_FAST_DIV</link>                 (a,b)
55
 
#define             <link linkend="COGL-FIXED-FAST-MUL--CAPS">COGL_FIXED_FAST_MUL</link>                 (a,b)
56
 
#define             <link linkend="COGL-FIXED-FRACTION--CAPS">COGL_FIXED_FRACTION</link>                 (x)
57
 
#define             <link linkend="COGL-FIXED-FLOOR--CAPS">COGL_FIXED_FLOOR</link>                    (x)
58
 
#define             <link linkend="COGL-FIXED-CEIL--CAPS">COGL_FIXED_CEIL</link>                     (x)
59
 
 
60
 
#define             <link linkend="COGL-FIXED-2-PI--CAPS">COGL_FIXED_2_PI</link>
61
 
#define             <link linkend="COGL-FIXED-PI--CAPS">COGL_FIXED_PI</link>
62
 
#define             <link linkend="COGL-FIXED-PI-2--CAPS">COGL_FIXED_PI_2</link>
63
 
#define             <link linkend="COGL-FIXED-PI-4--CAPS">COGL_FIXED_PI_4</link>
64
 
#define             <link linkend="COGL-RADIANS-TO-DEGREES--CAPS">COGL_RADIANS_TO_DEGREES</link>
65
 
 
66
 
#define             <link linkend="COGL-SQRTI-ARG-10-PERCENT--CAPS">COGL_SQRTI_ARG_10_PERCENT</link>
67
 
#define             <link linkend="COGL-SQRTI-ARG-5-PERCENT--CAPS">COGL_SQRTI_ARG_5_PERCENT</link>
68
 
#define             <link linkend="COGL-SQRTI-ARG-MAX--CAPS">COGL_SQRTI_ARG_MAX</link>
69
 
<link linkend="gint">gint</link>                <link linkend="cogl-sqrti">cogl_sqrti</link>                          (<link linkend="gint">gint</link> x);
70
 
 
71
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-fixed-atan2">cogl_fixed_atan2</link>                    (<link linkend="CoglFixed">CoglFixed</link> a,
72
 
                                                         <link linkend="CoglFixed">CoglFixed</link> b);
73
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-fixed-atani">cogl_fixed_atani</link>                    (<link linkend="CoglFixed">CoglFixed</link> a);
74
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-fixed-cos">cogl_fixed_cos</link>                      (<link linkend="CoglFixed">CoglFixed</link> angle);
75
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-fixed-log2">cogl_fixed_log2</link>                     (<link linkend="guint">guint</link> x);
76
 
<link linkend="guint">guint</link>               <link linkend="cogl-fixed-pow">cogl_fixed_pow</link>                      (<link linkend="guint">guint</link> x,
77
 
                                                         <link linkend="CoglFixed">CoglFixed</link> y);
78
 
<link linkend="guint">guint</link>               <link linkend="cogl-fixed-pow2">cogl_fixed_pow2</link>                     (<link linkend="CoglFixed">CoglFixed</link> x);
79
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-fixed-sin">cogl_fixed_sin</link>                      (<link linkend="CoglFixed">CoglFixed</link> angle);
80
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-fixed-sqrt">cogl_fixed_sqrt</link>                     (<link linkend="CoglFixed">CoglFixed</link> x);
81
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-fixed-tan">cogl_fixed_tan</link>                      (<link linkend="CoglFixed">CoglFixed</link> angle);
82
 
 
83
 
typedef             <link linkend="CoglAngle">CoglAngle</link>;
84
 
#define             <link linkend="COGL-ANGLE-FROM-DEG--CAPS">COGL_ANGLE_FROM_DEG</link>                 (x)
85
 
#define             <link linkend="COGL-ANGLE-FROM-DEGX--CAPS">COGL_ANGLE_FROM_DEGX</link>                (x)
86
 
#define             <link linkend="COGL-ANGLE-TO-DEG--CAPS">COGL_ANGLE_TO_DEG</link>                   (x)
87
 
#define             <link linkend="COGL-ANGLE-TO-DEGX--CAPS">COGL_ANGLE_TO_DEGX</link>                  (x)
88
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-angle-cos">cogl_angle_cos</link>                      (<link linkend="CoglAngle">CoglAngle</link> angle);
89
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-angle-sin">cogl_angle_sin</link>                      (<link linkend="CoglAngle">CoglAngle</link> angle);
90
 
<link linkend="CoglFixed">CoglFixed</link>           <link linkend="cogl-angle-tan">cogl_angle_tan</link>                      (<link linkend="CoglAngle">CoglAngle</link> angle);
91
 
</synopsis>
92
 
</refsynopsisdiv>
93
 
 
94
 
 
95
 
 
96
 
 
97
 
 
98
 
 
99
 
 
100
 
 
101
 
 
102
 
<refsect1 id="cogl-Fixed-Point-API.description" role="desc">
103
 
<title role="desc.title">Description</title>
104
 
<para>
105
 
COGL has a fixed point API targeted at platforms without a floating
106
 
point unit, such as embedded devices. On such platforms this API should
107
 
be preferred to the floating point one as it does not trigger the slow
108
 
path of software emulation, relying on integer math for fixed-to-floating
109
 
and floating-to-fixed notations conversion.
110
 
</para>
111
 
<para>
112
 
It is not recommened for use on platforms with a floating point unit
113
 
(e.g. desktop systems), nor for use in language bindings.
114
 
</para>
115
 
<para>
116
 
Basic rules of Fixed Point arithmethic:
117
 
<itemizedlist>
118
 
  <listitem>
119
 
    <para>Two fixed point numbers can be directly added, subtracted and
120
 
    have their modulus taken.</para>
121
 
  </listitem>
122
 
  <listitem>
123
 
    <para>To add other numerical type to a fixed point number it has to
124
 
    be first converted to fixed point.</para>
125
 
  </listitem>
126
 
  <listitem>
127
 
    <para>A fixed point number can be directly multiplied or divided by
128
 
    an integer.</para>
129
 
  </listitem>
130
 
  <listitem>
131
 
    <para>Two fixed point numbers can only be multiplied and divided by
132
 
    the provided <link linkend="COGL-FIXED-MUL--CAPS"><literal>COGL_FIXED_MUL</literal></link> and <link linkend="COGL-FIXED-DIV--CAPS"><literal>COGL_FIXED_DIV</literal></link> macros.</para>
133
 
  </listitem>
134
 
</itemizedlist>
135
 
</para>
136
 
<para>
137
 
The fixed point API is available since COGL 1.0.</para>
138
 
<para>
139
 
</para>
140
 
</refsect1>
141
 
 
142
 
<refsect1 id="cogl-Fixed-Point-API.details" role="details">
143
 
<title role="details.title">Details</title>
144
 
<refsect2 id="CoglFixed" role="typedef">
145
 
<title>CoglFixed</title>
146
 
<indexterm zone="CoglFixed"><primary sortas="Fixed">CoglFixed</primary></indexterm><programlisting>typedef gint32 CoglFixed;
147
 
</programlisting>
148
 
<para>
149
 
Fixed point number using a (16.16) notation.</para>
150
 
<para>
151
 
</para></refsect2>
152
 
<refsect2 id="COGL-FIXED-BITS--CAPS" role="macro" condition="since:1.0">
153
 
<title>COGL_FIXED_BITS</title>
154
 
<indexterm zone="COGL-FIXED-BITS--CAPS" role="1.0"><primary sortas="FIXED_BITS">COGL_FIXED_BITS</primary></indexterm><programlisting>#define COGL_FIXED_BITS         (32)
155
 
</programlisting>
156
 
<para>
157
 
Evaluates to the number of bits used by the <link linkend="CoglFixed"><type>CoglFixed</type></link> type.</para>
158
 
<para>
159
 
</para><para role="since">Since 1.0</para></refsect2>
160
 
<refsect2 id="COGL-FIXED-Q--CAPS" role="macro" condition="since:1.0">
161
 
<title>COGL_FIXED_Q</title>
162
 
<indexterm zone="COGL-FIXED-Q--CAPS" role="1.0"><primary sortas="FIXED_Q">COGL_FIXED_Q</primary></indexterm><programlisting>#define COGL_FIXED_Q            (COGL_FIXED_BITS - 16)
163
 
</programlisting>
164
 
<para>
165
 
Evaluates to the number of bits used for the non-integer part
166
 
of the <link linkend="CoglFixed"><type>CoglFixed</type></link> type.</para>
167
 
<para>
168
 
</para><para role="since">Since 1.0</para></refsect2>
169
 
<refsect2 id="COGL-FIXED-MAX--CAPS" role="macro" condition="since:1.0">
170
 
<title>COGL_FIXED_MAX</title>
171
 
<indexterm zone="COGL-FIXED-MAX--CAPS" role="1.0"><primary sortas="FIXED_MAX">COGL_FIXED_MAX</primary></indexterm><programlisting>#define COGL_FIXED_MAX          (0x7fffffff)
172
 
</programlisting>
173
 
<para>
174
 
The biggest number representable using <link linkend="CoglFixed"><type>CoglFixed</type></link></para>
175
 
<para>
176
 
</para><para role="since">Since 1.0</para></refsect2>
177
 
<refsect2 id="COGL-FIXED-MIN--CAPS" role="macro" condition="since:1.0">
178
 
<title>COGL_FIXED_MIN</title>
179
 
<indexterm zone="COGL-FIXED-MIN--CAPS" role="1.0"><primary sortas="FIXED_MIN">COGL_FIXED_MIN</primary></indexterm><programlisting>#define COGL_FIXED_MIN          (0x80000000)
180
 
</programlisting>
181
 
<para>
182
 
The smallest number representable using <link linkend="CoglFixed"><type>CoglFixed</type></link></para>
183
 
<para>
184
 
</para><para role="since">Since 1.0</para></refsect2>
185
 
<refsect2 id="COGL-FIXED-FROM-FLOAT--CAPS" role="macro" condition="since:1.0">
186
 
<title>COGL_FIXED_FROM_FLOAT()</title>
187
 
<indexterm zone="COGL-FIXED-FROM-FLOAT--CAPS" role="1.0"><primary sortas="FIXED_FROM_FLOAT">COGL_FIXED_FROM_FLOAT</primary></indexterm><programlisting>#define COGL_FIXED_FROM_FLOAT(x)        ((float) cogl_double_to_fixed (x))
188
 
</programlisting>
189
 
<para>
190
 
Converts <parameter>x</parameter> from a floating point to a fixed point notation.</para>
191
 
<para>
192
 
</para><variablelist role="params">
193
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
194
 
<listitem><simpara> a floating point number
195
 
</simpara></listitem></varlistentry>
196
 
</variablelist><para role="since">Since 1.0</para></refsect2>
197
 
<refsect2 id="COGL-FIXED-TO-FLOAT--CAPS" role="macro" condition="since:1.0">
198
 
<title>COGL_FIXED_TO_FLOAT()</title>
199
 
<indexterm zone="COGL-FIXED-TO-FLOAT--CAPS" role="1.0"><primary sortas="FIXED_TO_FLOAT">COGL_FIXED_TO_FLOAT</primary></indexterm><programlisting>#define COGL_FIXED_TO_FLOAT(x)          ((float) ((int)(x) / 65536.0))
200
 
</programlisting>
201
 
<para>
202
 
Converts <parameter>x</parameter> from a fixed point to a floating point notation, in
203
 
double precision.</para>
204
 
<para>
205
 
</para><variablelist role="params">
206
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
207
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
208
 
</simpara></listitem></varlistentry>
209
 
</variablelist><para role="since">Since 1.0</para></refsect2>
210
 
<refsect2 id="COGL-FIXED-FROM-INT--CAPS" role="macro" condition="since:1.0">
211
 
<title>COGL_FIXED_FROM_INT()</title>
212
 
<indexterm zone="COGL-FIXED-FROM-INT--CAPS" role="1.0"><primary sortas="FIXED_FROM_INT">COGL_FIXED_FROM_INT</primary></indexterm><programlisting>#define COGL_FIXED_FROM_INT(x)          ((x) &lt;&lt; COGL_FIXED_Q)
213
 
</programlisting>
214
 
<para>
215
 
Converts <parameter>x</parameter> from an integer to a fixed point notation.</para>
216
 
<para>
217
 
</para><variablelist role="params">
218
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
219
 
<listitem><simpara> an integer number
220
 
</simpara></listitem></varlistentry>
221
 
</variablelist><para role="since">Since 1.0</para></refsect2>
222
 
<refsect2 id="COGL-FIXED-TO-INT--CAPS" role="macro" condition="since:1.0">
223
 
<title>COGL_FIXED_TO_INT()</title>
224
 
<indexterm zone="COGL-FIXED-TO-INT--CAPS" role="1.0"><primary sortas="FIXED_TO_INT">COGL_FIXED_TO_INT</primary></indexterm><programlisting>#define COGL_FIXED_TO_INT(x)            ((x) &gt;&gt; COGL_FIXED_Q)
225
 
</programlisting>
226
 
<para>
227
 
Converts <parameter>x</parameter> from a fixed point notation to an integer, dropping
228
 
the fractional part without rounding.</para>
229
 
<para>
230
 
</para><variablelist role="params">
231
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
232
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
233
 
</simpara></listitem></varlistentry>
234
 
</variablelist><para role="since">Since 1.0</para></refsect2>
235
 
<refsect2 id="COGL-FIXED-FROM-DOUBLE--CAPS" role="macro" condition="since:1.0">
236
 
<title>COGL_FIXED_FROM_DOUBLE()</title>
237
 
<indexterm zone="COGL-FIXED-FROM-DOUBLE--CAPS" role="1.0"><primary sortas="FIXED_FROM_DOUBLE">COGL_FIXED_FROM_DOUBLE</primary></indexterm><programlisting>#define COGL_FIXED_FROM_DOUBLE(x)       (cogl_double_to_fixed (x))
238
 
</programlisting>
239
 
<para>
240
 
Converts <parameter>x</parameter> from a double precision, floating point to a fixed
241
 
point notation.</para>
242
 
<para>
243
 
</para><variablelist role="params">
244
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
245
 
<listitem><simpara> a floating point number
246
 
</simpara></listitem></varlistentry>
247
 
</variablelist><para role="since">Since 1.0</para></refsect2>
248
 
<refsect2 id="COGL-FIXED-TO-DOUBLE--CAPS" role="macro">
249
 
<title>COGL_FIXED_TO_DOUBLE()</title>
250
 
<indexterm zone="COGL-FIXED-TO-DOUBLE--CAPS"><primary sortas="FIXED_TO_DOUBLE">COGL_FIXED_TO_DOUBLE</primary></indexterm><programlisting>#define COGL_FIXED_TO_DOUBLE(x)         ((double) ((int)(x) / 65536.0))
251
 
</programlisting>
252
 
<para>
253
 
</para><variablelist role="params">
254
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
255
 
<listitem><simpara>
256
 
</simpara></listitem></varlistentry>
257
 
</variablelist></refsect2>
258
 
<refsect2 id="COGL-FLOAT-TO-INT--CAPS" role="macro" condition="since:1.0">
259
 
<title>COGL_FLOAT_TO_INT()</title>
260
 
<indexterm zone="COGL-FLOAT-TO-INT--CAPS" role="1.0"><primary sortas="FLOAT_TO_INT">COGL_FLOAT_TO_INT</primary></indexterm><programlisting>#define COGL_FLOAT_TO_INT(x)            (cogl_double_to_int ((x)))
261
 
</programlisting>
262
 
<para>
263
 
Converts <parameter>x</parameter> from a floating point notation to a signed integer.</para>
264
 
<para>
265
 
</para><variablelist role="params">
266
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
267
 
<listitem><simpara> a floatint point number
268
 
</simpara></listitem></varlistentry>
269
 
</variablelist><para role="since">Since 1.0</para></refsect2>
270
 
<refsect2 id="COGL-FLOAT-TO-UINT--CAPS" role="macro" condition="since:1.0">
271
 
<title>COGL_FLOAT_TO_UINT()</title>
272
 
<indexterm zone="COGL-FLOAT-TO-UINT--CAPS" role="1.0"><primary sortas="FLOAT_TO_UINT">COGL_FLOAT_TO_UINT</primary></indexterm><programlisting>#define COGL_FLOAT_TO_UINT(x)           (cogl_double_to_uint ((x)))
273
 
</programlisting>
274
 
<para>
275
 
Converts <parameter>x</parameter> from a floating point notation to an unsigned integer.</para>
276
 
<para>
277
 
</para><variablelist role="params">
278
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
279
 
<listitem><simpara> a floatint point number
280
 
</simpara></listitem></varlistentry>
281
 
</variablelist><para role="since">Since 1.0</para></refsect2>
282
 
<refsect2 id="COGL-FIXED-EPSILON--CAPS" role="macro" condition="since:1.0">
283
 
<title>COGL_FIXED_EPSILON</title>
284
 
<indexterm zone="COGL-FIXED-EPSILON--CAPS" role="1.0"><primary sortas="FIXED_EPSILON">COGL_FIXED_EPSILON</primary></indexterm><programlisting>#define COGL_FIXED_EPSILON      (1)
285
 
</programlisting>
286
 
<para>
287
 
A very small number expressed as a <link linkend="CoglFixed"><type>CoglFixed</type></link> number.</para>
288
 
<para>
289
 
</para><para role="since">Since 1.0</para></refsect2>
290
 
<refsect2 id="COGL-FIXED-1--CAPS" role="macro" condition="since:1.0">
291
 
<title>COGL_FIXED_1</title>
292
 
<indexterm zone="COGL-FIXED-1--CAPS" role="1.0"><primary sortas="FIXED_1">COGL_FIXED_1</primary></indexterm><programlisting>#define COGL_FIXED_1            (1 &lt;&lt; COGL_FIXED_Q)
293
 
</programlisting>
294
 
<para>
295
 
The number 1 expressed as a <link linkend="CoglFixed"><type>CoglFixed</type></link> number.</para>
296
 
<para>
297
 
</para><para role="since">Since 1.0</para></refsect2>
298
 
<refsect2 id="COGL-FIXED-0-5--CAPS" role="macro" condition="since:1.0">
299
 
<title>COGL_FIXED_0_5</title>
300
 
<indexterm zone="COGL-FIXED-0-5--CAPS" role="1.0"><primary sortas="FIXED_0_5">COGL_FIXED_0_5</primary></indexterm><programlisting>#define COGL_FIXED_0_5          (32768)
301
 
</programlisting>
302
 
<para>
303
 
The number 0.5 expressed as a <link linkend="CoglFixed"><type>CoglFixed</type></link> number.</para>
304
 
<para>
305
 
</para><para role="since">Since 1.0</para></refsect2>
306
 
<refsect2 id="COGL-FIXED-30--CAPS" role="macro" condition="since:1.0">
307
 
<title>COGL_FIXED_30</title>
308
 
<indexterm zone="COGL-FIXED-30--CAPS" role="1.0"><primary sortas="FIXED_30">COGL_FIXED_30</primary></indexterm><programlisting>#define COGL_FIXED_30           (COGL_FIXED_FROM_INT (30))
309
 
</programlisting>
310
 
<para>
311
 
Evaluates to the number 30 in fixed point notation.</para>
312
 
<para>
313
 
</para><para role="since">Since 1.0</para></refsect2>
314
 
<refsect2 id="COGL-FIXED-45--CAPS" role="macro" condition="since:1.0">
315
 
<title>COGL_FIXED_45</title>
316
 
<indexterm zone="COGL-FIXED-45--CAPS" role="1.0"><primary sortas="FIXED_45">COGL_FIXED_45</primary></indexterm><programlisting>#define COGL_FIXED_45           (COGL_FIXED_FROM_INT (45))
317
 
</programlisting>
318
 
<para>
319
 
Evaluates to the number 45 in fixed point notation.</para>
320
 
<para>
321
 
</para><para role="since">Since 1.0</para></refsect2>
322
 
<refsect2 id="COGL-FIXED-60--CAPS" role="macro" condition="since:1.0">
323
 
<title>COGL_FIXED_60</title>
324
 
<indexterm zone="COGL-FIXED-60--CAPS" role="1.0"><primary sortas="FIXED_60">COGL_FIXED_60</primary></indexterm><programlisting>#define COGL_FIXED_60           (COGL_FIXED_FROM_INT (60))
325
 
</programlisting>
326
 
<para>
327
 
Evaluates to the number 60 in fixed point notation.</para>
328
 
<para>
329
 
</para><para role="since">Since 1.0</para></refsect2>
330
 
<refsect2 id="COGL-FIXED-90--CAPS" role="macro" condition="since:1.0">
331
 
<title>COGL_FIXED_90</title>
332
 
<indexterm zone="COGL-FIXED-90--CAPS" role="1.0"><primary sortas="FIXED_90">COGL_FIXED_90</primary></indexterm><programlisting>#define COGL_FIXED_90           (COGL_FIXED_FROM_INT (90))
333
 
</programlisting>
334
 
<para>
335
 
Evaluates to the number 90 in fixed point notation.</para>
336
 
<para>
337
 
</para><para role="since">Since 1.0</para></refsect2>
338
 
<refsect2 id="COGL-FIXED-120--CAPS" role="macro" condition="since:1.0">
339
 
<title>COGL_FIXED_120</title>
340
 
<indexterm zone="COGL-FIXED-120--CAPS" role="1.0"><primary sortas="FIXED_120">COGL_FIXED_120</primary></indexterm><programlisting>#define COGL_FIXED_120          (COGL_FIXED_FROM_INT (120))
341
 
</programlisting>
342
 
<para>
343
 
Evaluates to the number 120 in fixed point notation.</para>
344
 
<para>
345
 
</para><para role="since">Since 1.0</para></refsect2>
346
 
<refsect2 id="COGL-FIXED-180--CAPS" role="macro" condition="since:1.0">
347
 
<title>COGL_FIXED_180</title>
348
 
<indexterm zone="COGL-FIXED-180--CAPS" role="1.0"><primary sortas="FIXED_180">COGL_FIXED_180</primary></indexterm><programlisting>#define COGL_FIXED_180          (COGL_FIXED_FROM_INT (180))
349
 
</programlisting>
350
 
<para>
351
 
Evaluates to the number 180 in fixed point notation.</para>
352
 
<para>
353
 
</para><para role="since">Since 1.0</para></refsect2>
354
 
<refsect2 id="COGL-FIXED-240--CAPS" role="macro" condition="since:1.0">
355
 
<title>COGL_FIXED_240</title>
356
 
<indexterm zone="COGL-FIXED-240--CAPS" role="1.0"><primary sortas="FIXED_240">COGL_FIXED_240</primary></indexterm><programlisting>#define COGL_FIXED_240          (COGL_FIXED_FROM_INT (240))
357
 
</programlisting>
358
 
<para>
359
 
Evaluates to the number 240 in fixed point notation.</para>
360
 
<para>
361
 
</para><para role="since">Since 1.0</para></refsect2>
362
 
<refsect2 id="COGL-FIXED-255--CAPS" role="macro" condition="since:1.0">
363
 
<title>COGL_FIXED_255</title>
364
 
<indexterm zone="COGL-FIXED-255--CAPS" role="1.0"><primary sortas="FIXED_255">COGL_FIXED_255</primary></indexterm><programlisting>#define COGL_FIXED_255          (COGL_FIXED_FROM_INT (255))
365
 
</programlisting>
366
 
<para>
367
 
Evaluates to the number 255 in fixed point notation.</para>
368
 
<para>
369
 
</para><para role="since">Since 1.0</para></refsect2>
370
 
<refsect2 id="COGL-FIXED-270--CAPS" role="macro" condition="since:1.0">
371
 
<title>COGL_FIXED_270</title>
372
 
<indexterm zone="COGL-FIXED-270--CAPS" role="1.0"><primary sortas="FIXED_270">COGL_FIXED_270</primary></indexterm><programlisting>#define COGL_FIXED_270          (COGL_FIXED_FROM_INT (270))
373
 
</programlisting>
374
 
<para>
375
 
Evaluates to the number 270 in fixed point notation.</para>
376
 
<para>
377
 
</para><para role="since">Since 1.0</para></refsect2>
378
 
<refsect2 id="COGL-FIXED-360--CAPS" role="macro" condition="since:1.0">
379
 
<title>COGL_FIXED_360</title>
380
 
<indexterm zone="COGL-FIXED-360--CAPS" role="1.0"><primary sortas="FIXED_360">COGL_FIXED_360</primary></indexterm><programlisting>#define COGL_FIXED_360          (COGL_FIXED_FROM_INT (360))
381
 
</programlisting>
382
 
<para>
383
 
Evaluates to the number 360 in fixed point notation.</para>
384
 
<para>
385
 
</para><para role="since">Since 1.0</para></refsect2>
386
 
<refsect2 id="COGL-FIXED-MUL--CAPS" role="macro" condition="since:1.0">
387
 
<title>COGL_FIXED_MUL()</title>
388
 
<indexterm zone="COGL-FIXED-MUL--CAPS" role="1.0"><primary sortas="FIXED_MUL">COGL_FIXED_MUL</primary></indexterm><programlisting>#define COGL_FIXED_MUL(a,b)             (cogl_fixed_mul ((a), (b)))
389
 
</programlisting>
390
 
<para>
391
 
Computes (a * b).</para>
392
 
<para>
393
 
</para><variablelist role="params">
394
 
<varlistentry><term><parameter>a</parameter>&#160;:</term>
395
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
396
 
</simpara></listitem></varlistentry>
397
 
<varlistentry><term><parameter>b</parameter>&#160;:</term>
398
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
399
 
</simpara></listitem></varlistentry>
400
 
</variablelist><para role="since">Since 1.0</para></refsect2>
401
 
<refsect2 id="COGL-FIXED-DIV--CAPS" role="macro" condition="since:1.0">
402
 
<title>COGL_FIXED_DIV()</title>
403
 
<indexterm zone="COGL-FIXED-DIV--CAPS" role="1.0"><primary sortas="FIXED_DIV">COGL_FIXED_DIV</primary></indexterm><programlisting>#define COGL_FIXED_DIV(a,b)             (cogl_fixed_div ((a), (b)))
404
 
</programlisting>
405
 
<para>
406
 
Computes (a / b).</para>
407
 
<para>
408
 
</para><variablelist role="params">
409
 
<varlistentry><term><parameter>a</parameter>&#160;:</term>
410
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
411
 
</simpara></listitem></varlistentry>
412
 
<varlistentry><term><parameter>b</parameter>&#160;:</term>
413
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
414
 
</simpara></listitem></varlistentry>
415
 
</variablelist><para role="since">Since 1.0</para></refsect2>
416
 
<refsect2 id="COGL-FIXED-MUL-DIV--CAPS" role="macro" condition="since:1.0">
417
 
<title>COGL_FIXED_MUL_DIV()</title>
418
 
<indexterm zone="COGL-FIXED-MUL-DIV--CAPS" role="1.0"><primary sortas="FIXED_MUL_DIV">COGL_FIXED_MUL_DIV</primary></indexterm><programlisting>#define COGL_FIXED_MUL_DIV(a,b,c)       (cogl_fixed_mul_div ((a), (b), (c)))
419
 
</programlisting>
420
 
<para>
421
 
Computes ((a * b) / c). It is logically equivalent to:
422
 
</para>
423
 
<para>
424
 
<informalexample><programlisting>
425
 
  res = COGL_FIXED_DIV (COGL_FIXED_MUL (a, b), c);
426
 
</programlisting></informalexample>
427
 
</para>
428
 
<para>
429
 
But it is shorter to type.</para>
430
 
<para>
431
 
</para><variablelist role="params">
432
 
<varlistentry><term><parameter>a</parameter>&#160;:</term>
433
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
434
 
</simpara></listitem></varlistentry>
435
 
<varlistentry><term><parameter>b</parameter>&#160;:</term>
436
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
437
 
</simpara></listitem></varlistentry>
438
 
<varlistentry><term><parameter>c</parameter>&#160;:</term>
439
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
440
 
</simpara></listitem></varlistentry>
441
 
</variablelist><para role="since">Since 1.0</para></refsect2>
442
 
<refsect2 id="COGL-FIXED-FAST-DIV--CAPS" role="macro" condition="since:1.0">
443
 
<title>COGL_FIXED_FAST_DIV()</title>
444
 
<indexterm zone="COGL-FIXED-FAST-DIV--CAPS" role="1.0"><primary sortas="FIXED_FAST_DIV">COGL_FIXED_FAST_DIV</primary></indexterm><programlisting>#define COGL_FIXED_FAST_DIV(a,b)        ((((a) &lt;&lt; 8) / (b)) &lt;&lt; 8)
445
 
</programlisting>
446
 
<para>
447
 
Fast version of <link linkend="COGL-FIXED-DIV--CAPS"><literal>COGL_FIXED_DIV</literal></link>, implemented as a macro.
448
 
</para>
449
 
<para>
450
 
<note>This macro might lose precision. If the precision of the result
451
 
is important use <link linkend="COGL-FIXED-DIV--CAPS"><literal>COGL_FIXED_DIV</literal></link> instead.</note></para>
452
 
<para>
453
 
</para><variablelist role="params">
454
 
<varlistentry><term><parameter>a</parameter>&#160;:</term>
455
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
456
 
</simpara></listitem></varlistentry>
457
 
<varlistentry><term><parameter>b</parameter>&#160;:</term>
458
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
459
 
</simpara></listitem></varlistentry>
460
 
</variablelist><para role="since">Since 1.0</para></refsect2>
461
 
<refsect2 id="COGL-FIXED-FAST-MUL--CAPS" role="macro" condition="since:1.0">
462
 
<title>COGL_FIXED_FAST_MUL()</title>
463
 
<indexterm zone="COGL-FIXED-FAST-MUL--CAPS" role="1.0"><primary sortas="FIXED_FAST_MUL">COGL_FIXED_FAST_MUL</primary></indexterm><programlisting>#define COGL_FIXED_FAST_MUL(a,b)        ((a) &gt;&gt; 8) * ((b) &gt;&gt; 8)
464
 
</programlisting>
465
 
<para>
466
 
Fast version of <link linkend="COGL-FIXED-MUL--CAPS"><literal>COGL_FIXED_MUL</literal></link>, implemented as a macro.
467
 
</para>
468
 
<para>
469
 
<note>This macro might lose precision. If the precision of the result
470
 
is important use <link linkend="COGL-FIXED-MUL--CAPS"><literal>COGL_FIXED_MUL</literal></link> instead.</note></para>
471
 
<para>
472
 
</para><variablelist role="params">
473
 
<varlistentry><term><parameter>a</parameter>&#160;:</term>
474
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
475
 
</simpara></listitem></varlistentry>
476
 
<varlistentry><term><parameter>b</parameter>&#160;:</term>
477
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
478
 
</simpara></listitem></varlistentry>
479
 
</variablelist><para role="since">Since 1.0</para></refsect2>
480
 
<refsect2 id="COGL-FIXED-FRACTION--CAPS" role="macro" condition="since:1.0">
481
 
<title>COGL_FIXED_FRACTION()</title>
482
 
<indexterm zone="COGL-FIXED-FRACTION--CAPS" role="1.0"><primary sortas="FIXED_FRACTION">COGL_FIXED_FRACTION</primary></indexterm><programlisting>#define COGL_FIXED_FRACTION(x)          ((x) &amp; ((1 &lt;&lt; COGL_FIXED_Q) - 1))
483
 
</programlisting>
484
 
<para>
485
 
Retrieves the fractionary part of <parameter>x</parameter>.</para>
486
 
<para>
487
 
</para><variablelist role="params">
488
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
489
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
490
 
</simpara></listitem></varlistentry>
491
 
</variablelist><para role="since">Since 1.0</para></refsect2>
492
 
<refsect2 id="COGL-FIXED-FLOOR--CAPS" role="macro" condition="since:1.0">
493
 
<title>COGL_FIXED_FLOOR()</title>
494
 
<indexterm zone="COGL-FIXED-FLOOR--CAPS" role="1.0"><primary sortas="FIXED_FLOOR">COGL_FIXED_FLOOR</primary></indexterm><programlisting>#define             COGL_FIXED_FLOOR(x)</programlisting>
495
 
<para>
496
 
Rounds down a fixed point number to the previous integer.</para>
497
 
<para>
498
 
</para><variablelist role="params">
499
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
500
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
501
 
</simpara></listitem></varlistentry>
502
 
</variablelist><para role="since">Since 1.0</para></refsect2>
503
 
<refsect2 id="COGL-FIXED-CEIL--CAPS" role="macro" condition="since:1.0">
504
 
<title>COGL_FIXED_CEIL()</title>
505
 
<indexterm zone="COGL-FIXED-CEIL--CAPS" role="1.0"><primary sortas="FIXED_CEIL">COGL_FIXED_CEIL</primary></indexterm><programlisting>#define COGL_FIXED_CEIL(x)              (COGL_FIXED_FLOOR ((x) + 0xffff))
506
 
</programlisting>
507
 
<para>
508
 
Rounds up a fixed point number to the next integer.</para>
509
 
<para>
510
 
</para><variablelist role="params">
511
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
512
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
513
 
</simpara></listitem></varlistentry>
514
 
</variablelist><para role="since">Since 1.0</para></refsect2>
515
 
<refsect2 id="COGL-FIXED-2-PI--CAPS" role="macro" condition="since:1.0">
516
 
<title>COGL_FIXED_2_PI</title>
517
 
<indexterm zone="COGL-FIXED-2-PI--CAPS" role="1.0"><primary sortas="FIXED_2_PI">COGL_FIXED_2_PI</primary></indexterm><programlisting>#define COGL_FIXED_2_PI         (0x0006487f)
518
 
</programlisting>
519
 
<para>
520
 
Two times pi, expressed as a <link linkend="CoglFixed"><type>CoglFixed</type></link> number.</para>
521
 
<para>
522
 
</para><para role="since">Since 1.0</para></refsect2>
523
 
<refsect2 id="COGL-FIXED-PI--CAPS" role="macro" condition="since:1.0">
524
 
<title>COGL_FIXED_PI</title>
525
 
<indexterm zone="COGL-FIXED-PI--CAPS" role="1.0"><primary sortas="FIXED_PI">COGL_FIXED_PI</primary></indexterm><programlisting>#define COGL_FIXED_PI           (0x0003243f)
526
 
</programlisting>
527
 
<para>
528
 
The number pi, expressed as a <link linkend="CoglFixed"><type>CoglFixed</type></link> number.</para>
529
 
<para>
530
 
</para><para role="since">Since 1.0</para></refsect2>
531
 
<refsect2 id="COGL-FIXED-PI-2--CAPS" role="macro" condition="since:1.0">
532
 
<title>COGL_FIXED_PI_2</title>
533
 
<indexterm zone="COGL-FIXED-PI-2--CAPS" role="1.0"><primary sortas="FIXED_PI_2">COGL_FIXED_PI_2</primary></indexterm><programlisting>#define COGL_FIXED_PI_2         (0x00019220)
534
 
</programlisting>
535
 
<para>
536
 
Half pi, expressed as a <link linkend="CoglFixed"><type>CoglFixed</type></link> number.</para>
537
 
<para>
538
 
</para><para role="since">Since 1.0</para></refsect2>
539
 
<refsect2 id="COGL-FIXED-PI-4--CAPS" role="macro" condition="since:1.0">
540
 
<title>COGL_FIXED_PI_4</title>
541
 
<indexterm zone="COGL-FIXED-PI-4--CAPS" role="1.0"><primary sortas="FIXED_PI_4">COGL_FIXED_PI_4</primary></indexterm><programlisting>#define COGL_FIXED_PI_4         (0x0000c910)
542
 
</programlisting>
543
 
<para>
544
 
pi / 4, expressed as <link linkend="CoglFixed"><type>CoglFixed</type></link> number.</para>
545
 
<para>
546
 
</para><para role="since">Since 1.0</para></refsect2>
547
 
<refsect2 id="COGL-RADIANS-TO-DEGREES--CAPS" role="macro" condition="since:1.0">
548
 
<title>COGL_RADIANS_TO_DEGREES</title>
549
 
<indexterm zone="COGL-RADIANS-TO-DEGREES--CAPS" role="1.0"><primary sortas="RADIANS_TO_DEGREES">COGL_RADIANS_TO_DEGREES</primary></indexterm><programlisting>#define COGL_RADIANS_TO_DEGREES (0x394bb8)
550
 
</programlisting>
551
 
<para>
552
 
Evaluates to 180 / pi in fixed point notation.</para>
553
 
<para>
554
 
</para><para role="since">Since 1.0</para></refsect2>
555
 
<refsect2 id="COGL-SQRTI-ARG-10-PERCENT--CAPS" role="macro" condition="since:1.0">
556
 
<title>COGL_SQRTI_ARG_10_PERCENT</title>
557
 
<indexterm zone="COGL-SQRTI-ARG-10-PERCENT--CAPS" role="1.0"><primary sortas="SQRTI_ARG_10_PERCENT">COGL_SQRTI_ARG_10_PERCENT</primary></indexterm><programlisting>#define             COGL_SQRTI_ARG_10_PERCENT</programlisting>
558
 
<para>
559
 
Maximum argument that can be passed to <link linkend="cogl-sqrti"><function>cogl_sqrti()</function></link> for which the
560
 
resulting error is &lt; 10%</para>
561
 
<para>
562
 
</para><para role="since">Since 1.0</para></refsect2>
563
 
<refsect2 id="COGL-SQRTI-ARG-5-PERCENT--CAPS" role="macro" condition="since:1.0">
564
 
<title>COGL_SQRTI_ARG_5_PERCENT</title>
565
 
<indexterm zone="COGL-SQRTI-ARG-5-PERCENT--CAPS" role="1.0"><primary sortas="SQRTI_ARG_5_PERCENT">COGL_SQRTI_ARG_5_PERCENT</primary></indexterm><programlisting>#define             COGL_SQRTI_ARG_5_PERCENT</programlisting>
566
 
<para>
567
 
Maximum argument that can be passed to <link linkend="cogl-sqrti"><function>cogl_sqrti()</function></link> for which the
568
 
resulting error is &lt; 5%</para>
569
 
<para>
570
 
</para><para role="since">Since 1.0</para></refsect2>
571
 
<refsect2 id="COGL-SQRTI-ARG-MAX--CAPS" role="macro" condition="since:1.0">
572
 
<title>COGL_SQRTI_ARG_MAX</title>
573
 
<indexterm zone="COGL-SQRTI-ARG-MAX--CAPS" role="1.0"><primary sortas="SQRTI_ARG_MAX">COGL_SQRTI_ARG_MAX</primary></indexterm><programlisting>#define             COGL_SQRTI_ARG_MAX</programlisting>
574
 
<para>
575
 
Maximum argument that can be passed to <link linkend="cogl-sqrti"><function>cogl_sqrti()</function></link> function.</para>
576
 
<para>
577
 
</para><para role="since">Since 1.0</para></refsect2>
578
 
<refsect2 id="cogl-sqrti" role="function" condition="since:0.2">
579
 
<title>cogl_sqrti ()</title>
580
 
<indexterm zone="cogl-sqrti" role="0.2"><primary sortas="sqrti">cogl_sqrti</primary></indexterm><programlisting><link linkend="gint">gint</link>                cogl_sqrti                          (<link linkend="gint">gint</link> x);</programlisting>
581
 
<para>
582
 
Very fast fixed point implementation of square root for integers.
583
 
</para>
584
 
<para>
585
 
This function is at least 6x faster than clib <link linkend="sqrt"><function>sqrt()</function></link> on x86, and (this is
586
 
not a typo!) about 500x faster on ARM without FPU. It's error is &lt; 5%
587
 
for arguments &lt; <link linkend="COGL-SQRTI-ARG-5-PERCENT--CAPS"><type>COGL_SQRTI_ARG_5_PERCENT</type></link> and &lt; 10% for arguments &lt;
588
 
<link linkend="COGL-SQRTI-ARG-10-PERCENT--CAPS"><type>COGL_SQRTI_ARG_10_PERCENT</type></link>. The maximum argument that can be passed to
589
 
this function is COGL_SQRTI_ARG_MAX.</para>
590
 
<para>
591
 
</para><variablelist role="params">
592
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
593
 
<listitem><simpara> integer value
594
 
</simpara></listitem></varlistentry>
595
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> integer square root.
596
 
 
597
 
 
598
 
</simpara></listitem></varlistentry>
599
 
</variablelist><para role="since">Since 0.2</para></refsect2>
600
 
<refsect2 id="cogl-fixed-atan2" role="function" condition="since:1.0">
601
 
<title>cogl_fixed_atan2 ()</title>
602
 
<indexterm zone="cogl-fixed-atan2" role="1.0"><primary sortas="fixed_atan2">cogl_fixed_atan2</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_fixed_atan2                    (<link linkend="CoglFixed">CoglFixed</link> a,
603
 
                                                         <link linkend="CoglFixed">CoglFixed</link> b);</programlisting>
604
 
<para>
605
 
Computes the arc tangent of <parameter>a</parameter> / <parameter>b</parameter> but uses the sign of both
606
 
arguments to return the angle in right quadrant.</para>
607
 
<para>
608
 
</para><variablelist role="params">
609
 
<varlistentry><term><parameter>a</parameter>&#160;:</term>
610
 
<listitem><simpara> the numerator as a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
611
 
</simpara></listitem></varlistentry>
612
 
<varlistentry><term><parameter>b</parameter>&#160;:</term>
613
 
<listitem><simpara> the denominator as a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
614
 
</simpara></listitem></varlistentry>
615
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the arc tangent of the passed fraction, in fixed point
616
 
  notation
617
 
 
618
 
</simpara></listitem></varlistentry>
619
 
</variablelist><para role="since">Since 1.0</para></refsect2>
620
 
<refsect2 id="cogl-fixed-atani" role="function" condition="since:1.0">
621
 
<title>cogl_fixed_atani ()</title>
622
 
<indexterm zone="cogl-fixed-atani" role="1.0"><primary sortas="fixed_atani">cogl_fixed_atani</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_fixed_atani                    (<link linkend="CoglFixed">CoglFixed</link> a);</programlisting>
623
 
<para>
624
 
Computes the arc tangent of <parameter>a</parameter>.</para>
625
 
<para>
626
 
</para><variablelist role="params">
627
 
<varlistentry><term><parameter>a</parameter>&#160;:</term>
628
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
629
 
</simpara></listitem></varlistentry>
630
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the arc tangent of the passed value, in fixed point notation
631
 
 
632
 
</simpara></listitem></varlistentry>
633
 
</variablelist><para role="since">Since 1.0</para></refsect2>
634
 
<refsect2 id="cogl-fixed-cos" role="function" condition="since:1.0">
635
 
<title>cogl_fixed_cos ()</title>
636
 
<indexterm zone="cogl-fixed-cos" role="1.0"><primary sortas="fixed_cos">cogl_fixed_cos</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_fixed_cos                      (<link linkend="CoglFixed">CoglFixed</link> angle);</programlisting>
637
 
<para>
638
 
Computes the cosine of <parameter>angle</parameter>.</para>
639
 
<para>
640
 
</para><variablelist role="params">
641
 
<varlistentry><term><parameter>angle</parameter>&#160;:</term>
642
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
643
 
</simpara></listitem></varlistentry>
644
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the cosine of the passed angle, in fixed point notation
645
 
 
646
 
</simpara></listitem></varlistentry>
647
 
</variablelist><para role="since">Since 1.0</para></refsect2>
648
 
<refsect2 id="cogl-fixed-log2" role="function" condition="since:1.0">
649
 
<title>cogl_fixed_log2 ()</title>
650
 
<indexterm zone="cogl-fixed-log2" role="1.0"><primary sortas="fixed_log2">cogl_fixed_log2</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_fixed_log2                     (<link linkend="guint">guint</link> x);</programlisting>
651
 
<para>
652
 
Calculates base 2 logarithm.
653
 
</para>
654
 
<para>
655
 
This function is some 2.5 times faster on x86, and over 12 times faster on
656
 
fpu-less arm, than using libc <link linkend="log"><function>log()</function></link>.</para>
657
 
<para>
658
 
</para><variablelist role="params">
659
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
660
 
<listitem><simpara> value to calculate base 2 logarithm from
661
 
</simpara></listitem></varlistentry>
662
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> base 2 logarithm.
663
 
 
664
 
</simpara></listitem></varlistentry>
665
 
</variablelist><para role="since">Since 1.0</para></refsect2>
666
 
<refsect2 id="cogl-fixed-pow" role="function" condition="since:1.0">
667
 
<title>cogl_fixed_pow ()</title>
668
 
<indexterm zone="cogl-fixed-pow" role="1.0"><primary sortas="fixed_pow">cogl_fixed_pow</primary></indexterm><programlisting><link linkend="guint">guint</link>               cogl_fixed_pow                      (<link linkend="guint">guint</link> x,
669
 
                                                         <link linkend="CoglFixed">CoglFixed</link> y);</programlisting>
670
 
<para>
671
 
Calculates <parameter>x</parameter> to the <parameter>y</parameter> power.</para>
672
 
<para>
673
 
</para><variablelist role="params">
674
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
675
 
<listitem><simpara> base
676
 
</simpara></listitem></varlistentry>
677
 
<varlistentry><term><parameter>y</parameter>&#160;:</term>
678
 
<listitem><simpara> <link linkend="CoglFixed"><type>CoglFixed</type></link> exponent
679
 
</simpara></listitem></varlistentry>
680
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the power of <parameter>x</parameter> to the <parameter>y</parameter>
681
 
 
682
 
</simpara></listitem></varlistentry>
683
 
</variablelist><para role="since">Since 1.0</para></refsect2>
684
 
<refsect2 id="cogl-fixed-pow2" role="function" condition="since:1.0">
685
 
<title>cogl_fixed_pow2 ()</title>
686
 
<indexterm zone="cogl-fixed-pow2" role="1.0"><primary sortas="fixed_pow2">cogl_fixed_pow2</primary></indexterm><programlisting><link linkend="guint">guint</link>               cogl_fixed_pow2                     (<link linkend="CoglFixed">CoglFixed</link> x);</programlisting>
687
 
<para>
688
 
Calculates 2 to the <parameter>x</parameter> power.
689
 
</para>
690
 
<para>
691
 
This function is around 11 times faster on x86, and around 22 times faster
692
 
on fpu-less arm than libc pow(2, x).</para>
693
 
<para>
694
 
</para><variablelist role="params">
695
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
696
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
697
 
</simpara></listitem></varlistentry>
698
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the power of 2 to the passed value
699
 
 
700
 
</simpara></listitem></varlistentry>
701
 
</variablelist><para role="since">Since 1.0</para></refsect2>
702
 
<refsect2 id="cogl-fixed-sin" role="function" condition="since:1.0">
703
 
<title>cogl_fixed_sin ()</title>
704
 
<indexterm zone="cogl-fixed-sin" role="1.0"><primary sortas="fixed_sin">cogl_fixed_sin</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_fixed_sin                      (<link linkend="CoglFixed">CoglFixed</link> angle);</programlisting>
705
 
<para>
706
 
Computes the sine of <parameter>angle</parameter>.</para>
707
 
<para>
708
 
</para><variablelist role="params">
709
 
<varlistentry><term><parameter>angle</parameter>&#160;:</term>
710
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
711
 
</simpara></listitem></varlistentry>
712
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the sine of the passed angle, in fixed point notation
713
 
 
714
 
</simpara></listitem></varlistentry>
715
 
</variablelist><para role="since">Since 1.0</para></refsect2>
716
 
<refsect2 id="cogl-fixed-sqrt" role="function" condition="since:1.0">
717
 
<title>cogl_fixed_sqrt ()</title>
718
 
<indexterm zone="cogl-fixed-sqrt" role="1.0"><primary sortas="fixed_sqrt">cogl_fixed_sqrt</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_fixed_sqrt                     (<link linkend="CoglFixed">CoglFixed</link> x);</programlisting>
719
 
<para>
720
 
Computes the square root of <parameter>x</parameter>.</para>
721
 
<para>
722
 
</para><variablelist role="params">
723
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
724
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
725
 
</simpara></listitem></varlistentry>
726
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the square root of the passed value, in floating point
727
 
  notation
728
 
 
729
 
</simpara></listitem></varlistentry>
730
 
</variablelist><para role="since">Since 1.0</para></refsect2>
731
 
<refsect2 id="cogl-fixed-tan" role="function" condition="since:1.0">
732
 
<title>cogl_fixed_tan ()</title>
733
 
<indexterm zone="cogl-fixed-tan" role="1.0"><primary sortas="fixed_tan">cogl_fixed_tan</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_fixed_tan                      (<link linkend="CoglFixed">CoglFixed</link> angle);</programlisting>
734
 
<para>
735
 
Computes the tangent of <parameter>angle</parameter>.</para>
736
 
<para>
737
 
</para><variablelist role="params">
738
 
<varlistentry><term><parameter>angle</parameter>&#160;:</term>
739
 
<listitem><simpara> a <link linkend="CoglFixed"><type>CoglFixed</type></link> number
740
 
</simpara></listitem></varlistentry>
741
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the tangent of the passed angle, in fixed point notation
742
 
 
743
 
</simpara></listitem></varlistentry>
744
 
</variablelist><para role="since">Since 1.0</para></refsect2>
745
 
<refsect2 id="CoglAngle" role="typedef" condition="since:1.0">
746
 
<title>CoglAngle</title>
747
 
<indexterm zone="CoglAngle" role="1.0"><primary sortas="Angle">CoglAngle</primary></indexterm><programlisting>typedef gint32 CoglAngle;
748
 
</programlisting>
749
 
<para>
750
 
Integer representation of an angle such that 1024 corresponds to
751
 
full circle (i.e., 2 * pi).</para>
752
 
<para>
753
 
</para><para role="since">Since 1.0</para></refsect2>
754
 
<refsect2 id="COGL-ANGLE-FROM-DEG--CAPS" role="macro" condition="since:1.0">
755
 
<title>COGL_ANGLE_FROM_DEG()</title>
756
 
<indexterm zone="COGL-ANGLE-FROM-DEG--CAPS" role="1.0"><primary sortas="ANGLE_FROM_DEG">COGL_ANGLE_FROM_DEG</primary></indexterm><programlisting>#define COGL_ANGLE_FROM_DEG(x)  (COGL_FLOAT_TO_INT (((float)(x) * 1024.0f) / 360.0f))
757
 
</programlisting>
758
 
<para>
759
 
Converts an angle in degrees into a <link linkend="CoglAngle"><type>CoglAngle</type></link>.</para>
760
 
<para>
761
 
</para><variablelist role="params">
762
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
763
 
<listitem><simpara> an angle in degrees in floating point notation
764
 
</simpara></listitem></varlistentry>
765
 
</variablelist><para role="since">Since 1.0</para></refsect2>
766
 
<refsect2 id="COGL-ANGLE-FROM-DEGX--CAPS" role="macro" condition="since:1.0">
767
 
<title>COGL_ANGLE_FROM_DEGX()</title>
768
 
<indexterm zone="COGL-ANGLE-FROM-DEGX--CAPS" role="1.0"><primary sortas="ANGLE_FROM_DEGX">COGL_ANGLE_FROM_DEGX</primary></indexterm><programlisting>#define COGL_ANGLE_FROM_DEGX(x) (COGL_FIXED_TO_INT ((((x) / 360) * 1024) + COGL_FIXED_0_5))
769
 
</programlisting>
770
 
<para>
771
 
Converts an angle in degrees into a <link linkend="CoglAngle"><type>CoglAngle</type></link>.</para>
772
 
<para>
773
 
</para><variablelist role="params">
774
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
775
 
<listitem><simpara> an angle in degrees in fixed point notation
776
 
</simpara></listitem></varlistentry>
777
 
</variablelist><para role="since">Since 1.0</para></refsect2>
778
 
<refsect2 id="COGL-ANGLE-TO-DEG--CAPS" role="macro" condition="since:1.0">
779
 
<title>COGL_ANGLE_TO_DEG()</title>
780
 
<indexterm zone="COGL-ANGLE-TO-DEG--CAPS" role="1.0"><primary sortas="ANGLE_TO_DEG">COGL_ANGLE_TO_DEG</primary></indexterm><programlisting>#define COGL_ANGLE_TO_DEG(x)    (((float)(x) * 360.0) / 1024.0)
781
 
</programlisting>
782
 
<para>
783
 
Converts a <link linkend="CoglAngle"><type>CoglAngle</type></link> into an angle in degrees, using floatint point
784
 
notation.</para>
785
 
<para>
786
 
</para><variablelist role="params">
787
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
788
 
<listitem><simpara> a <link linkend="CoglAngle"><type>CoglAngle</type></link>
789
 
</simpara></listitem></varlistentry>
790
 
</variablelist><para role="since">Since 1.0</para></refsect2>
791
 
<refsect2 id="COGL-ANGLE-TO-DEGX--CAPS" role="macro" condition="since:1.0">
792
 
<title>COGL_ANGLE_TO_DEGX()</title>
793
 
<indexterm zone="COGL-ANGLE-TO-DEGX--CAPS" role="1.0"><primary sortas="ANGLE_TO_DEGX">COGL_ANGLE_TO_DEGX</primary></indexterm><programlisting>#define COGL_ANGLE_TO_DEGX(x)   (COGL_FIXED_FROM_INT ((x) * 45) / 128)
794
 
</programlisting>
795
 
<para>
796
 
Converts a <link linkend="CoglAngle"><type>CoglAngle</type></link> into an angle in degrees, using fixed point notation</para>
797
 
<para>
798
 
</para><variablelist role="params">
799
 
<varlistentry><term><parameter>x</parameter>&#160;:</term>
800
 
<listitem><simpara> a <link linkend="CoglAngle"><type>CoglAngle</type></link>
801
 
</simpara></listitem></varlistentry>
802
 
</variablelist><para role="since">Since 1.0</para></refsect2>
803
 
<refsect2 id="cogl-angle-cos" role="function" condition="since:1.0">
804
 
<title>cogl_angle_cos ()</title>
805
 
<indexterm zone="cogl-angle-cos" role="1.0"><primary sortas="angle_cos">cogl_angle_cos</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_angle_cos                      (<link linkend="CoglAngle">CoglAngle</link> angle);</programlisting>
806
 
<para>
807
 
Computes the cosine of <parameter>angle</parameter></para>
808
 
<para>
809
 
</para><variablelist role="params">
810
 
<varlistentry><term><parameter>angle</parameter>&#160;:</term>
811
 
<listitem><simpara> an angle expressed using <link linkend="CoglAngle"><type>CoglAngle</type></link>
812
 
</simpara></listitem></varlistentry>
813
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the cosine of the passed angle
814
 
 
815
 
</simpara></listitem></varlistentry>
816
 
</variablelist><para role="since">Since 1.0</para></refsect2>
817
 
<refsect2 id="cogl-angle-sin" role="function" condition="since:1.0">
818
 
<title>cogl_angle_sin ()</title>
819
 
<indexterm zone="cogl-angle-sin" role="1.0"><primary sortas="angle_sin">cogl_angle_sin</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_angle_sin                      (<link linkend="CoglAngle">CoglAngle</link> angle);</programlisting>
820
 
<para>
821
 
Computes the sine of <parameter>angle</parameter></para>
822
 
<para>
823
 
</para><variablelist role="params">
824
 
<varlistentry><term><parameter>angle</parameter>&#160;:</term>
825
 
<listitem><simpara> an angle expressed using <link linkend="CoglAngle"><type>CoglAngle</type></link>
826
 
</simpara></listitem></varlistentry>
827
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the sine of the passed angle
828
 
 
829
 
</simpara></listitem></varlistentry>
830
 
</variablelist><para role="since">Since 1.0</para></refsect2>
831
 
<refsect2 id="cogl-angle-tan" role="function" condition="since:1.0">
832
 
<title>cogl_angle_tan ()</title>
833
 
<indexterm zone="cogl-angle-tan" role="1.0"><primary sortas="angle_tan">cogl_angle_tan</primary></indexterm><programlisting><link linkend="CoglFixed">CoglFixed</link>           cogl_angle_tan                      (<link linkend="CoglAngle">CoglAngle</link> angle);</programlisting>
834
 
<para>
835
 
Computes the tangent of <parameter>angle</parameter></para>
836
 
<para>
837
 
</para><variablelist role="params">
838
 
<varlistentry><term><parameter>angle</parameter>&#160;:</term>
839
 
<listitem><simpara> an angle expressed using <link linkend="CoglAngle"><type>CoglAngle</type></link>
840
 
</simpara></listitem></varlistentry>
841
 
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the tangent of the passed angle
842
 
 
843
 
</simpara></listitem></varlistentry>
844
 
</variablelist><para role="since">Since 1.0</para></refsect2>
845
 
 
846
 
</refsect1>
847
 
 
848
 
 
849
 
 
850
 
 
851
 
</refentry>