OSDN Git Service

add tstools.
[rec10/rec10-git.git] / tstools / DtsEdit / src / gpac / math.h
1 /*\r
2  *                      GPAC - Multimedia Framework C SDK\r
3  *\r
4  *                      Copyright (c) Jean Le Feuvre 2000-2005 \r
5  *                                      All rights reserved\r
6  *\r
7  *  This file is part of GPAC / common tools sub-project\r
8  *\r
9  *  GPAC is free software; you can redistribute it and/or modify\r
10  *  it under the terms of the GNU Lesser General Public License as published by\r
11  *  the Free Software Foundation; either version 2, or (at your option)\r
12  *  any later version.\r
13  *   \r
14  *  GPAC is distributed in the hope that it will be useful,\r
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  *  GNU Lesser General Public License for more details.\r
18  *   \r
19  *  You should have received a copy of the GNU Lesser General Public\r
20  *  License along with this library; see the file COPYING.  If not, write to\r
21  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
22  *\r
23  */\r
24 \r
25 #ifndef _GF_MATH_H_\r
26 #define _GF_MATH_H_\r
27 \r
28 #ifdef __cplusplus\r
29 extern "C" {\r
30 #endif\r
31 \r
32 /*!\r
33  *      \file <gpac/math.h>\r
34  *      \brief math and trigo functions.\r
35  */\r
36 \r
37 #include <gpac/setup.h>\r
38         \r
39 /*NOTE: there is a conflict on Win32 VC6 with C++ and gpac headers when including <math.h>*/\r
40 #if !defined(__cplusplus) || defined(__SYMBIAN32__)\r
41 #include <math.h>\r
42 #endif\r
43 \r
44 /*!\r
45  \cond DUMMY_DOXY_SECTION\r
46 */\r
47 \r
48 #ifndef GPAC_FIXED_POINT\r
49 /*note: \r
50                 to turn fp on, change to GPAC_FIXED_POINT\r
51                 to turn fp off, change to GPAC_NO_FIXED_POINT\r
52         this is needed by configure+sed to modify this file directly\r
53 */\r
54 #define GPAC_NO_FIXED_POINT\r
55 #endif\r
56 \r
57 /*!\r
58  \endcond\r
59 */\r
60 \r
61 \r
62 /*!\r
63  *\addtogroup math_grp math\r
64  *\ingroup utils_grp\r
65  *\brief Mathematics and Trigonometric functions\r
66  *\r
67  *This section documents the math and trigo functions used in the GPAC framework. GPAC can be compiled with\r
68  *fixed-point support, representing float values on a 16.16 signed integer, which implies a developer \r
69  *must take care of float computations when using GPAC.\n\r
70  *A developper should not need to know in which mode the framework has been compiled as long as he uses\r
71  *the math functions of GPAC which work in both float and fixed-point mode.\n\r
72  *Using fixed-point version is decided at compilation time and cannot be changed. The feature is signaled\r
73  *through the following macros:\r
74  *- GPAC_FIXED_POINT: when defined, GPAC has been compiled in fixed-point mode\r
75  *- GPAC_NO_FIXED_POINT: when defined, GPAC has been compiled in regular (float) mode\r
76  *      @{\r
77  */\r
78 \r
79 \r
80 /*****************************************************************************************\r
81                         FIXED-POINT SUPPORT - HARDCODED FOR 16.16 representation\r
82         the software rasterizer also use a 16.16 representation even in non-fixed version\r
83 ******************************************************************************************/\r
84 \r
85 #ifdef GPAC_FIXED_POINT\r
86 \r
87 /*!\r
88  *Fixed 16.16 number\r
89  *\hideinitializer\r
90  \note This documentation has been generated for a fixed-point version of the GPAC framework.\r
91  */\r
92 typedef s32 Fixed;\r
93 #define FIX_ONE                 0x10000L\r
94 #define INT2FIX(v)              ((Fixed)( ((s32) (v) ) << 16))\r
95 #define FLT2FIX(v)              ((Fixed) ((v) * FIX_ONE))\r
96 #define FIX2INT(v)              ((s32)(((v)+((FIX_ONE>>1)))>>16))\r
97 #define FIX2FLT(v)              ((Float)( ((Float)(v)) / ((Float) FIX_ONE)))\r
98 #define FIX_EPSILON             2\r
99 #define FIX_MAX                 0x7FFFFFFF\r
100 #define FIX_MIN                 -FIX_MAX\r
101 #define GF_PI2          102944\r
102 #define GF_PI           205887\r
103 #define GF_2PI          411774\r
104 \r
105 /*!\return 1/a, expressed as fixed number*/\r
106 Fixed gf_invfix(Fixed a);\r
107 /*!\return a*b, expressed as fixed number*/\r
108 Fixed gf_mulfix(Fixed a, Fixed b);\r
109 /*!\return a*b/c, expressed as fixed number*/\r
110 Fixed gf_muldiv(Fixed a, Fixed b, Fixed c);\r
111 /*!\return a/b, expressed as fixed number*/\r
112 Fixed gf_divfix(Fixed a, Fixed b);\r
113 /*!\return sqrt(a), expressed as fixed number*/\r
114 Fixed gf_sqrt(Fixed x);\r
115 /*!\return ceil(a), expressed as fixed number*/\r
116 Fixed gf_ceil(Fixed a);\r
117 /*!\return floor(a), expressed as fixed number*/\r
118 Fixed gf_floor(Fixed a);\r
119 /*!\return cos(a), expressed as fixed number*/\r
120 Fixed gf_cos(Fixed angle);\r
121 /*!\return sin(a), expressed as fixed number*/\r
122 Fixed gf_sin(Fixed angle);\r
123 /*!\return tan(a), expressed as fixed number*/\r
124 Fixed gf_tan(Fixed angle);\r
125 /*!\return acos(a), expressed as fixed number*/\r
126 Fixed gf_acos(Fixed angle);\r
127 /*!\return asin(a), expressed as fixed number*/\r
128 Fixed gf_asin(Fixed angle);\r
129 /*!\return atan(y, x), expressed as fixed number*/\r
130 Fixed gf_atan2(Fixed y, Fixed x);\r
131 \r
132 #else\r
133 \r
134 \r
135 /*!Fixed is 32bit float number\r
136  \note This documentation has been generated for a float version of the GPAC framework.\r
137 */\r
138 typedef Float Fixed;\r
139 #define FIX_ONE                 1.0f\r
140 #define INT2FIX(v)              ((Float) (v))\r
141 #define FLT2FIX(v)              ((Float) (v))\r
142 #define FIX2INT(v)              ((s32)(v))\r
143 #define FIX2FLT(v)              ((Float) (v))\r
144 #define FIX_EPSILON             GF_EPSILON_FLOAT\r
145 #define FIX_MAX                 GF_MAX_FLOAT\r
146 #define FIX_MIN                 -GF_MAX_FLOAT\r
147 #define GF_PI2          1.5707963267949f\r
148 #define GF_PI           3.1415926535898f\r
149 #define GF_2PI          6.2831853071796f\r
150 \r
151 /*!\hideinitializer 1/_a, expressed as fixed number*/\r
152 #define gf_invfix(_a)   (FIX_ONE/(_a))\r
153 /*!\hideinitializer _a*_b, expressed as fixed number*/\r
154 #define gf_mulfix(_a, _b)               ((_a)*(_b))\r
155 /*!\hideinitializer _a*_b/_c, expressed as fixed number*/\r
156 #define gf_muldiv(_a, _b, _c)   ((_c) ? (_a)*(_b)/(_c) : GF_MAX_FLOAT)\r
157 /*!\hideinitializer _a/_b, expressed as fixed number*/\r
158 #define gf_divfix(_a, _b)               ((_b) ? (_a)/(_b) : GF_MAX_FLOAT)\r
159 /*!\hideinitializer sqrt(_a), expressed as fixed number*/\r
160 #define gf_sqrt(_a) ((Float) sqrt(_a))\r
161 /*!\hideinitializer ceil(_a), expressed as fixed number*/\r
162 #define gf_ceil(_a) ((Float) ceil(_a))\r
163 /*!\hideinitializer floor(_a), expressed as fixed number*/\r
164 #define gf_floor(_a) ((Float) floor(_a))\r
165 /*!\hideinitializer cos(_a), expressed as fixed number*/\r
166 #define gf_cos(_a) ((Float) cos(_a))\r
167 /*!\hideinitializer sin(_a), expressed as fixed number*/\r
168 #define gf_sin(_a) ((Float) sin(_a))\r
169 /*!\hideinitializer tan(_a), expressed as fixed number*/\r
170 #define gf_tan(_a) ((Float) tan(_a))\r
171 /*!\hideinitializer atan2(_y,_x), expressed as fixed number*/\r
172 #define gf_atan2(_y, _x) ((Float) atan2(_y, _x))\r
173 /*!\hideinitializer acos(_a), expressed as fixed number*/\r
174 #define gf_acos(_a) ((Float) acos(_a))\r
175 /*!\hideinitializer asin(_a), expressed as fixed number*/\r
176 #define gf_asin(_a) ((Float) asin(_a))\r
177 \r
178 #endif\r
179 \r
180 /*!\def FIX_ONE\r
181  \hideinitializer\r
182  Fixed unit value\r
183 */\r
184 /*!\def INT2FIX(v)\r
185  \hideinitializer\r
186  Conversion from integer to fixed\r
187 */\r
188 /*!\def FLT2FIX(v)\r
189  \hideinitializer\r
190  Conversion from float to fixed\r
191 */\r
192 /*!\def FIX2INT(v)\r
193  \hideinitializer\r
194  Conversion from fixed to integer\r
195 */\r
196 /*!\def FIX2FLT(v)\r
197  \hideinitializer\r
198  Conversion from fixed to float\r
199 */\r
200 /*!\def FIX_EPSILON\r
201  \hideinitializer\r
202  Epsilon Fixed (positive value closest to 0)\r
203 */\r
204 /*!\def FIX_MAX\r
205  \hideinitializer\r
206  Maximum Fixed (maximum representable fixed value)\r
207 */\r
208 /*!\def FIX_MIN\r
209  \hideinitializer\r
210  Minimum Fixed (minimum representable fixed value)\r
211 */\r
212 /*!\def GF_PI2\r
213  \hideinitializer\r
214  PI/2 expressed as Fixed\r
215 */\r
216 /*!\def GF_PI\r
217  \hideinitializer\r
218  PI expressed as Fixed\r
219 */\r
220 /*!\def GF_2PI\r
221  \hideinitializer\r
222  2*PI expressed as Fixed\r
223 */\r
224 \r
225 Fixed gf_angle_diff(Fixed a, Fixed b);\r
226 \r
227 /*!\r
228  *      \brief Field bit-size \r
229  *\r
230  *      Gets the number of bits needed to represent the value.\r
231  *      \param MaxVal Maximum value to be represented.\r
232  *      \return number of bits required to represent the value.\r
233  */\r
234 u32 gf_get_bit_size(u32 MaxVal);\r
235 \r
236 /*!\r
237  *      \brief Get power of 2\r
238  *\r
239  *      Gets the closest power of 2 greater or equal to the value.\r
240  *      \param val value to be used.\r
241  *      \return requested power of 2.\r
242  */\r
243 u32 gf_get_next_pow2(u32 val);\r
244 \r
245 /*!\r
246  *\addtogroup math2d_grp math2d\r
247  *\ingroup math_grp\r
248  *\brief 2D Mathematics functions\r
249  *\r
250  *This section documents mathematic tools for 2D geometry and color matrices operations\r
251  *      @{\r
252  */\r
253 \r
254 /*!\brief 2D point\r
255  *\r
256  *The 2D point object is used in all the GPAC framework for both point and vector representation.\r
257 */\r
258 typedef struct __vec2f\r
259 {\r
260         Fixed x;\r
261         Fixed y;\r
262 } GF_Point2D;\r
263 /*!\r
264  *\brief get 2D vector length\r
265  *\r
266  *Gets the length of a 2D vector\r
267  *\return length of the vector\r
268  */\r
269 Fixed gf_v2d_len(GF_Point2D *vec);\r
270 /*!\r
271  *\brief 2D vector from polar coordinates\r
272  *\r
273  *Constructs a 2D vector from its polar coordinates\r
274  *\param length the length of the vector\r
275  *\param angle the angle of the vector in radians\r
276  *\return the 2D vector\r
277  */\r
278 GF_Point2D gf_v2d_from_polar(Fixed length, Fixed angle);\r
279 \r
280 /*!\brief rectangle 2D\r
281  *\r
282  *The 2D rectangle used in the GPAC project.\r
283  */\r
284 typedef struct\r
285 {\r
286         /*!the left coordinate of the rectangle*/\r
287         Fixed x;\r
288         /*!the top coordinate of the rectangle, regardless of the canvas orientation. In other words, y is always the \r
289         greatest coordinate value,      even if the rectangle is presented bottom-up. This insures proper rectangles testing*/\r
290         Fixed y;\r
291         /*!the width of the rectangle. Width must be greater than or equal to 0*/\r
292         Fixed width;\r
293         /*!the height of the rectangle. Height must be greater than or equal to 0*/\r
294         Fixed height;\r
295 } GF_Rect;\r
296 \r
297 /*!\r
298  \brief rectangle union\r
299  *\r
300  *Gets the union of two rectangles.\r
301  *\param rc1 first rectangle of the union. Upon return, this rectangle will contain the result of the union\r
302  *\param rc2 second rectangle of the union\r
303 */\r
304 void gf_rect_union(GF_Rect *rc1, GF_Rect *rc2);\r
305 /*!\r
306  \brief centers a rectangle\r
307  *\r
308  *Builds a rectangle centered on the origin\r
309  *\param w width of the rectangle\r
310  *\param h height of the rectangle\r
311  *\return centered rectangle object\r
312 */\r
313 GF_Rect gf_rect_center(Fixed w, Fixed h);\r
314 /*!\r
315  \brief rectangle overlap test\r
316  *\r
317  *Tests if two rectangles overlap.\r
318  *\param rc1 first rectangle to test\r
319  *\param rc2 second rectangle to test\r
320  *\return 1 if rectangles overlap, 0 otherwise\r
321 */\r
322 Bool gf_rect_overlaps(GF_Rect rc1, GF_Rect rc2);\r
323 /*!\r
324  \brief rectangle identity test\r
325  *\r
326  *Tests if two rectangles are identical.\r
327  *\param rc1 first rectangle to test\r
328  *\param rc2 second rectangle to test\r
329  *\return 1 if rectangles are identical, 0 otherwise\r
330 */\r
331 Bool gf_rect_equal(GF_Rect rc1, GF_Rect rc2);\r
332 \r
333 /*!\r
334  *\brief pixel-aligned rectangle\r
335  *\r
336  *Pixel-aligned rectangle used in the GPAC framework. This is usually needed for 2D drawing algorithms.\r
337  */\r
338 typedef struct\r
339 {\r
340         /*!the left coordinate of the rectangle*/\r
341         s32 x;\r
342         /*!the top coordinate of the rectangle, regardless of the canvas orientation. In other words, y is always the \r
343         greatest coordinate value, even if the rectangle is presented bottom-up. This insures proper rectangles operations*/\r
344         s32 y;\r
345         /*!the width of the rectangle. Width must be greater than or equal to 0*/\r
346         s32 width;\r
347         /*!the height of the rectangle. Height must be greater than or equal to 0*/\r
348         s32 height;\r
349 } GF_IRect;\r
350 /*!\r
351  *\brief gets the pixelized version of a rectangle\r
352  *\r
353  *Returns the smallest pixel-aligned rectangle completely containing a rectangle\r
354  *\param r the rectangle to transform\r
355  *\return the pixel-aligned transformed rectangle\r
356 */\r
357 GF_IRect gf_rect_pixelize(GF_Rect *r);\r
358 \r
359 \r
360 /*!\r
361  *\brief 2D matrix\r
362  *\r
363  *The 2D affine matrix object usied in GPAC. The transformation of P(x,y) in P'(X, Y) is:\r
364  \code\r
365         X = m[0]*x + m[1]*y + m[2];\r
366         Y = m[3]*x + m[4]*y + m[5];\r
367  \endcode\r
368 */\r
369 typedef struct\r
370 {\r
371         Fixed m[6];\r
372 } GF_Matrix2D;\r
373 \r
374 /*!\brief matrix initialization\r
375  *\hideinitializer\r
376  *\r
377  *Inits the matrix to the identity matrix\r
378 */\r
379 #define gf_mx2d_init(_obj) { memset((_obj).m, 0, sizeof(Fixed)*6); (_obj).m[0] = (_obj).m[4] = FIX_ONE; }\r
380 /*!\brief matrix copy\r
381  *\hideinitializer\r
382  *\r
383  *Copies the matrix _from to the matrix _obj\r
384 */\r
385 #define gf_mx2d_copy(_obj, from) memcpy((_obj).m, (from).m, sizeof(Fixed)*6)\r
386 /*!\brief matrix identity testing\r
387  *\hideinitializer\r
388  *\r
389  *This macro evaluates to 1 if the matrix _obj is the identity matrix, 0 otherwise\r
390 */\r
391 #define gf_mx2d_is_identity(_obj) ((!(_obj).m[1] && !(_obj).m[2] && !(_obj).m[3] && !(_obj).m[5] && ((_obj).m[0]==FIX_ONE) && ((_obj).m[4]==FIX_ONE)) ? 1 : 0)\r
392 \r
393 /*!\brief 2D matrix multiplication\r
394  *\r
395  *Multiplies two 2D matrices from*_this\r
396  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
397  *\param from transformation matrix to add\r
398 */\r
399 void gf_mx2d_add_matrix(GF_Matrix2D *_this, GF_Matrix2D *from);\r
400 \r
401 /*!\brief 2D matrix pre-multiplication\r
402  *\r
403  *Multiplies two 2D matrices _this*from\r
404  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
405  *\param from transformation matrix to add\r
406 */\r
407 void gf_mx2d_pre_multiply(GF_Matrix2D *_this, GF_Matrix2D *from);\r
408 \r
409 /*!\brief matrix translating\r
410  *\r
411  *Translates a 2D matrix\r
412  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
413  *\param cx horizontal translation\r
414  *\param cy vertical translation\r
415 */\r
416 void gf_mx2d_add_translation(GF_Matrix2D *_this, Fixed cx, Fixed cy);\r
417 /*!\brief matrix rotating\r
418  *\r
419  *Rotates a 2D matrix\r
420  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
421  *\param cx horizontal rotation center coordinate\r
422  *\param cy vertical rotation center coordinate\r
423  *\param angle rotation angle in radians\r
424 */\r
425 void gf_mx2d_add_rotation(GF_Matrix2D *_this, Fixed cx, Fixed cy, Fixed angle);\r
426 /*!\brief matrix scaling\r
427  *\r
428  *Scales a 2D matrix\r
429  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
430  *\param scale_x horizontal scaling factor\r
431  *\param scale_y vertical scaling factor\r
432 */\r
433 void gf_mx2d_add_scale(GF_Matrix2D *_this, Fixed scale_x, Fixed scale_y);\r
434 /*!\brief matrix uncentered scaling\r
435  *\r
436  *Scales a 2D matrix with a non-centered scale\r
437  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
438  *\param scale_x horizontal scaling factor\r
439  *\param scale_y vertical scaling factor\r
440  *\param cx horizontal scaling center coordinate\r
441  *\param cy vertical scaling center coordinate\r
442  *\param angle scale orienttion angle in radians\r
443 */\r
444 void gf_mx2d_add_scale_at(GF_Matrix2D *_this, Fixed scale_x, Fixed scale_y, Fixed cx, Fixed cy, Fixed angle);\r
445 /*!\brief matrix skewing\r
446  *\r
447  *Skews a 2D matrix\r
448  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
449  *\param skew_x horizontal skew factor\r
450  *\param skew_y vertical skew factor\r
451 */\r
452 void gf_mx2d_add_skew(GF_Matrix2D *_this, Fixed skew_x, Fixed skew_y);\r
453 /*!\brief matrix horizontal skewing\r
454  *\r
455  *Skews a 2D matrix horizontally by a given angle\r
456  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
457  *\param angle horizontal skew angle in radians\r
458 */\r
459 void gf_mx2d_add_skew_x(GF_Matrix2D *_this, Fixed angle);\r
460 /*!\brief matrix vertical skewing\r
461  *\r
462  *Skews a 2D matrix vertically by a given angle\r
463  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
464  *\param angle vertical skew angle in radians\r
465 */\r
466 void gf_mx2d_add_skew_y(GF_Matrix2D *_this, Fixed angle);\r
467 /*!\brief matrix inversing\r
468  *\r
469  *Inverses a 2D matrix \r
470  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix\r
471 */\r
472 void gf_mx2d_inverse(GF_Matrix2D *_this);\r
473 /*!\brief matrix coordinate transformation\r
474  *\r
475  *Applies a 2D matrix transformation to coordinates\r
476  *\param _this transformation matrix\r
477  *\param x pointer to horizontal coordinate. Once the function is called, x contains the transformed horizontal coordinate\r
478  *\param y pointer to vertical coordinate. Once the function is called, y contains the transformed vertical coordinate\r
479 */\r
480 void gf_mx2d_apply_coords(GF_Matrix2D *_this, Fixed *x, Fixed *y);\r
481 /*!\brief matrix point transformation\r
482  *\r
483  *Applies a 2D matrix transformation to a 2D point\r
484  *\param _this transformation matrix\r
485  *\param pt pointer to 2D point. Once the function is called, pt contains the transformed point\r
486 */\r
487 void gf_mx2d_apply_point(GF_Matrix2D *_this, GF_Point2D *pt);\r
488 /*!\brief matrix rectangle transformation\r
489  *\r
490  *Applies a 2D matrix transformation to a rectangle, giving the enclosing rectangle of the transformed one\r
491  *\param _this transformation matrix\r
492  *\param rc pointer to rectangle. Once the function is called, rc contains the transformed rectangle\r
493 */\r
494 void gf_mx2d_apply_rect(GF_Matrix2D *_this, GF_Rect *rc);\r
495 \r
496 /*!\brief matrix decomposition\r
497  *\r
498  *Decomposes a 2D matrix M as M=Scale x Rotation x Translation if possible\r
499  *\param _this transformation matrix\r
500  *\param scale resulting scale part\r
501  *\param rotate resulting rotation part\r
502  *\param translate resulting translation part\r
503  *\return 0 if matrix cannot be decomposed, 1 otherwise\r
504 */\r
505 Bool gf_mx2d_decompose(GF_Matrix2D *_this, GF_Point2D *scale, Fixed *rotate, GF_Point2D *translate);\r
506 \r
507 /*! @} */\r
508 \r
509 \r
510 /*!\r
511  *\addtogroup math3d_grp math3d\r
512  *\ingroup math_grp\r
513  *\brief 3D Mathematics functions\r
514  *\r
515  *This section documents mathematic tools for 3D geometry operations\r
516  *      @{\r
517  */\r
518 \r
519 /*!\brief 3D point or vector\r
520  *\r
521  *The 3D point object is used in all the GPAC framework for both point and vector representation.\r
522 */\r
523 typedef struct __vec3f\r
524 {\r
525         Fixed x;\r
526         Fixed y;\r
527         Fixed z;\r
528 } GF_Vec;\r
529 \r
530 /*base vector operations are MACROs for faster access*/\r
531 /*!\hideinitializer macro evaluating to 1 if vectors are equal, 0 otherwise*/\r
532 #define gf_vec_equal(v1, v2) (((v1).x == (v2).x) && ((v1).y == (v2).y) && ((v1).z == (v2).z))\r
533 /*!\hideinitializer macro reversing a vector v = v*/\r
534 #define gf_vec_rev(v) { (v).x = -(v).x; (v).y = -(v).y; (v).z = -(v).z; }\r
535 /*!\hideinitializer macro performing the minus operation res = v1 - v2*/\r
536 #define gf_vec_diff(res, v1, v2) { (res).x = (v1).x - (v2).x; (res).y = (v1).y - (v2).y; (res).z = (v1).z - (v2).z; }\r
537 /*!\hideinitializer macro performing the add operation res = v1 + v2*/\r
538 #define gf_vec_add(res, v1, v2) { (res).x = (v1).x + (v2).x; (res).y = (v1).y + (v2).y; (res).z = (v1).z + (v2).z; }\r
539 \r
540 /*!\r
541  *\brief get 3D vector length\r
542  *\r
543  *Gets the length of a 3D vector\r
544  *\return length of the vector\r
545  */\r
546 Fixed gf_vec_len(GF_Vec v);\r
547 /*!\r
548  *\brief get 3D vector square length\r
549  *\r
550  *Gets the square length of a 3D vector\r
551  *\return square length of the vector\r
552  */\r
553 Fixed gf_vec_lensq(GF_Vec v);\r
554 /*!\r
555  *\brief get 3D vector dot product\r
556  *\r
557  *Gets the dot product of two vectors\r
558  *\return dot product of the vectors\r
559  */\r
560 Fixed gf_vec_dot(GF_Vec v1, GF_Vec v2);\r
561 /*!\r
562  *\brief vector normalization\r
563  *\r
564  *Norms the vector, eg make its length equal to \ref FIX_ONE\r
565  *\param v vector to normalize\r
566  */\r
567 void gf_vec_norm(GF_Vec *v);\r
568 /*!\r
569  *\brief vector scaling\r
570  *\r
571  *Scales a vector by a given amount\r
572  *\param v vector to scale\r
573  *\param f scale factor\r
574  *\return scaled vector\r
575  */\r
576 GF_Vec gf_vec_scale(GF_Vec v, Fixed f);\r
577 /*!\r
578  *\brief vector cross product\r
579  *\r
580  *Gets the cross product of two vectors\r
581  *\param v1 first vector\r
582  *\param v2 second vector\r
583  *\return cross-product vector\r
584  */\r
585 GF_Vec gf_vec_cross(GF_Vec v1, GF_Vec v2);\r
586 \r
587 /*!\brief 4D vector\r
588  *\r
589  *The 4D vector object is used in all the GPAC framework for 4 dimension vectors, VRML Rotations and quaternions representation.\r
590 */\r
591 typedef struct __vec4f\r
592 {\r
593         Fixed x;\r
594         Fixed y;\r
595         Fixed z;\r
596         Fixed q;\r
597 } GF_Vec4;\r
598 \r
599 \r
600 /*!\brief 3D matrix\r
601  *\r
602  *The 3D matrix object used in GPAC. The matrix is oriented like OpenGL matrices (column-major ordering), with \r
603  the translation part at the end of the coefficients list.\r
604  \note Unless specified otherwise, the matrix object is always expected to represent an affine transformation.\r
605  */\r
606 typedef struct\r
607 {\r
608         Fixed m[16];\r
609 } GF_Matrix;\r
610 \r
611 \r
612 /*!\hideinitializer gets the len of a quaternion*/\r
613 #define gf_quat_len(v) gf_sqrt(gf_mulfix((v).q,(v).q) + gf_mulfix((v).x,(v).x) + gf_mulfix((v).y,(v).y) + gf_mulfix((v).z,(v).z))\r
614 /*!\hideinitializer normalizes a quaternion*/\r
615 #define gf_quat_norm(v) { \\r
616         Fixed __mag = gf_quat_len(v);   \\r
617         (v).x = gf_divfix((v).x, __mag); (v).y = gf_divfix((v).y, __mag); (v).z = gf_divfix((v).z, __mag); (v).q = gf_divfix((v).q, __mag);     \\r
618         }       \\r
619 \r
620 /*!\brief quaternion to rotation\r
621  *\r
622  *Transforms a quaternion to a Rotation, expressed as a 4 dimension vector with x,y,z for axis and q for rotation angle\r
623  *\param quat the quaternion to transform\r
624  *\return the rotation value\r
625  */\r
626 GF_Vec4 gf_quat_to_rotation(GF_Vec4 *quat);\r
627 /*!\brief quaternion from rotation\r
628  *\r
629  *Transforms a Rotation to a quaternion\r
630  *\param rot the rotation to transform\r
631  *\return the quaternion value\r
632  */\r
633 GF_Vec4 gf_quat_from_rotation(GF_Vec4 rot);\r
634 /*!inverses a quaternion*/\r
635 GF_Vec4 gf_quat_get_inv(GF_Vec4 *quat);\r
636 /*!\brief quaternion multiplication\r
637  *\r
638  *Multiplies two quaternions\r
639  *\param q1 the first quaternion\r
640  *\param q2 the second quaternion\r
641  *\return the resulting quaternion\r
642  */\r
643 GF_Vec4 gf_quat_multiply(GF_Vec4 *q1, GF_Vec4 *q2);\r
644 /*!\brief quaternion vector rotating\r
645  *\r
646  *Rotates a vector with a quaternion \r
647  *\param quat the quaternion modelizing the rotation\r
648  *\param vec the vector to rotate\r
649  *\return the resulting vector\r
650  */\r
651 GF_Vec gf_quat_rotate(GF_Vec4 *quat, GF_Vec *vec);\r
652 /*!\brief quaternion from axis and cos\r
653  *\r
654  *Constructs a quaternion from an axis and a cosinus value (shortcut to \ref gf_quat_from_rotation)\r
655  *\param axis the rotation axis\r
656  *\param cos_a the rotation cosinus value\r
657  *\return the resulting quaternion\r
658  */\r
659 GF_Vec4 gf_quat_from_axis_cos(GF_Vec axis, Fixed cos_a);\r
660 /*!\brief quaternion interpolation\r
661  *\r
662  *Interpolates two quaternions using spherical linear interpolation\r
663  *\param q1 the first quaternion\r
664  *\param q2 the second quaternion\r
665  *\param frac the fraction of the interpolation, between 0 and \ref FIX_ONE\r
666  *\return the interpolated quaternion\r
667  */\r
668 GF_Vec4 gf_quat_slerp(GF_Vec4 q1, GF_Vec4 q2, Fixed frac);\r
669 \r
670 /*!\brief 3D Bounding Box\r
671  *\r
672  *The 3D Bounding Box is a 3D Axis-Aligned Bounding Box used to in various tools of the GPAC framework for bounds \r
673  estimation of a 3D object. It features an axis-aligned box and a sphere bounding volume for fast intersection tests.\r
674  */\r
675 typedef struct\r
676 {\r
677         /*!minimum x, y, and z of the object*/\r
678         GF_Vec min_edge;\r
679         /*!maximum x, y, and z of the object*/\r
680         GF_Vec max_edge;\r
681 \r
682         /*!center of the bounding box.\note this is computed from min_edge and max_edge*/\r
683         GF_Vec center;\r
684         /*!radius of the bounding sphere for this box.\note this is computed from min_edge and max_edge*/\r
685         Fixed radius;\r
686         /*!the bbox center and radius are valid*/\r
687         Bool is_set;\r
688 } GF_BBox;\r
689 /*!updates information of the bounding box based on the edge information*/\r
690 void gf_bbox_refresh(GF_BBox *b);\r
691 /*!builds a bounding box from a 2D rectangle*/\r
692 void gf_bbox_from_rect(GF_BBox *box, GF_Rect *rc);\r
693 /*!builds a rectangle from a 3D bounding box.\note The z dimension is lost and no projection is performed*/\r
694 void gf_rect_from_bbox(GF_Rect *rc, GF_BBox *box);\r
695 /*!\brief bounding box expansion\r
696  *\r
697  *Checks if a point is inside a bounding box and updates the bounding box to include it if not the case\r
698  *\param box the bounding box object\r
699  *\param pt the 3D point to check\r
700 */\r
701 void gf_bbox_grow_point(GF_BBox *box, GF_Vec pt);\r
702 /*!performs the union of two bounding boxes*/\r
703 void gf_bbox_union(GF_BBox *b1, GF_BBox *b2);\r
704 /*!checks if two bounding boxes are equal or not*/\r
705 Bool gf_bbox_equal(GF_BBox *b1, GF_BBox *b2);\r
706 /*!checks if a point is inside a bounding box or not*/\r
707 Bool gf_bbox_point_inside(GF_BBox *box, GF_Vec *p);\r
708 /*!\brief get box vertices\r
709  *\r
710  *Returns the 8 bounding box vertices given the minimum and maximum edge. Vertices are ordered to respect \r
711  "p-vertex indexes", (vertex from a box closest to plane) and so that n-vertex (vertex from a box farthest from plane) \r
712  is 7-p_vx_idx\r
713  *\param bmin minimum edge of the box\r
714  *\param bmax maximum edge of the box\r
715  *\param vecs list of 8 3D points used to store the vertices.\r
716 */\r
717 void gf_bbox_get_vertices(GF_Vec bmin, GF_Vec bmax, GF_Vec *vecs);\r
718 \r
719 \r
720 /*!\brief matrix initialization\r
721  *\hideinitializer\r
722  *\r
723  *Inits the matrix to the identity matrix\r
724 */\r
725 #define gf_mx_init(_obj) { memset((_obj).m, 0, sizeof(Fixed)*16); (_obj).m[0] = (_obj).m[5] = (_obj).m[10] = (_obj).m[15] = FIX_ONE; }\r
726 /*!\brief matrix copy\r
727  *\hideinitializer\r
728  *\r
729  *Copies the matrix _from to the matrix _obj\r
730 */\r
731 #define gf_mx_copy(_obj, from) memcpy(&(_obj), &(from), sizeof(GF_Matrix));\r
732 /*!\brief matrix constructor from 2D\r
733  *\r
734  *Initializes a 3D matrix from a 2D matrix.\note all z-related coefficients will be set to default.\r
735 */\r
736 void gf_mx_from_mx2d(GF_Matrix *mx, GF_Matrix2D *mat2D);\r
737 /*!\brief matrix identity testing\r
738  *\r
739  *Tests if two matrices are equal or not.\r
740  \return 1 if matrices are same, 0 otherwise\r
741 */\r
742 Bool gf_mx_equal(GF_Matrix *mx1, GF_Matrix *mx2);\r
743 /*!\brief matrix translation\r
744  *\r
745  *Translates a matrix \r
746  *\param mx the matrix being transformed. Once the function is called, contains the result matrix\r
747  *\param tx horizontal translation\r
748  *\param ty vertical translation\r
749  *\param tz depth translation\r
750 */\r
751 void gf_mx_add_translation(GF_Matrix *mx, Fixed tx, Fixed ty, Fixed tz);\r
752 /*!\brief matrix scaling\r
753  *\r
754  *Scales a matrix \r
755  *\param mx the matrix being transformed. Once the function is called, contains the result matrix\r
756  *\param sx horizontal translation scaling\r
757  *\param sy vertical translation scaling\r
758  *\param sz depth translation scaling\r
759 */\r
760 void gf_mx_add_scale(GF_Matrix *mx, Fixed sx, Fixed sy, Fixed sz);\r
761 /*!\brief matrix rotating\r
762  *\r
763  *Rotates a matrix \r
764  *\param mx the matrix being transformed. Once the function is called, contains the result matrix\r
765  *\param angle rotation angle in radians\r
766  *\param x horizontal coordinate of rotation axis\r
767  *\param y vertical coordinate of rotation axis\r
768  *\param z depth coordinate of rotation axis\r
769 */\r
770 void gf_mx_add_rotation(GF_Matrix *mx, Fixed angle, Fixed x, Fixed y, Fixed z);\r
771 /*!\brief matrices multiplication \r
772  *\r
773  *Multiplies a matrix with another one mx = mx*mul\r
774  *\param mx the matrix being transformed. Once the function is called, contains the result matrix\r
775  *\param mul the matrix to add\r
776 */\r
777 void gf_mx_add_matrix(GF_Matrix *mx, GF_Matrix *mul);\r
778 /*!\brief 2D matrix multiplication\r
779  *\r
780  *Adds a 2D affine matrix to a matrix\r
781  *\param mx the matrix \r
782  *\param mat2D the matrix to premultiply\r
783  */\r
784 void gf_mx_add_matrix_2d(GF_Matrix *mx, GF_Matrix2D *mat2D);\r
785 \r
786 /*!\brief affine matrix inversion\r
787  *\r
788  *Inverses an affine matrix.\warning Results are undefined if the matrix is not an affine one\r
789  *\param mx the matrix to inverse\r
790  */\r
791 void gf_mx_inverse(GF_Matrix *mx);\r
792 /*!\brief matrix point transformation\r
793  *\r
794  *Applies a 3D matrix transformation to a 3D point\r
795  *\param mx transformation matrix\r
796  *\param pt pointer to 3D point. Once the function is called, pt contains the transformed point\r
797 */\r
798 void gf_mx_apply_vec(GF_Matrix *mx, GF_Vec *pt);\r
799 /*!\brief matrix rectangle transformation\r
800  *\r
801  *Applies a 3D matrix transformation to a rectangle, giving the enclosing rectangle of the transformed one.\note all depth information are discarded.\r
802  *\param _this transformation matrix\r
803  *\param rc pointer to rectangle. Once the function is called, rc contains the transformed rectangle\r
804 */\r
805 void gf_mx_apply_rect(GF_Matrix *_this, GF_Rect *rc);\r
806 /*!\brief ortho matrix construction\r
807  *\r
808  *Creates an orthogonal projection matrix\r
809  *\param mx matrix to initialize\r
810  *\param left min horizontal coordinate of viewport\r
811  *\param right max horizontal coordinate of viewport\r
812  *\param bottom min vertical coordinate of viewport\r
813  *\param top max vertical coordinate of viewport\r
814  *\param z_near min depth coordinate of viewport\r
815  *\param z_far max depth coordinate of viewport\r
816 */\r
817 void gf_mx_ortho(GF_Matrix *mx, Fixed left, Fixed right, Fixed bottom, Fixed top, Fixed z_near, Fixed z_far);\r
818 /*!\brief perspective matrix construction\r
819  *\r
820  *Creates a perspective projection matrix\r
821  *\param mx matrix to initialize\r
822  *\param foc camera field of view angle in radian\r
823  *\param aspect_ratio viewport aspect ratio\r
824  *\param z_near min depth coordinate of viewport\r
825  *\param z_far max depth coordinate of viewport\r
826 */\r
827 void gf_mx_perspective(GF_Matrix *mx, Fixed foc, Fixed aspect_ratio, Fixed z_near, Fixed z_far);\r
828 /*!\brief creates look matrix\r
829  *\r
830  *Creates a transformation matrix looking at a given direction from a given point (camera matrix).\r
831  *\param mx matrix to initialize\r
832  *\param position position\r
833  *\param target look direction\r
834  *\param up_vector vector describing the up direction\r
835 */\r
836 void gf_mx_lookat(GF_Matrix *mx, GF_Vec position, GF_Vec target, GF_Vec up_vector);\r
837 /*!\brief matrix box transformation\r
838  *\r
839  *Applies a 3D matrix transformation to a bounding box, giving the enclosing box of the transformed one\r
840  *\param mx transformation matrix\r
841  *\param b pointer to bounding box. Once the function is called, contains the transformed bounding box\r
842 */\r
843 void gf_mx_apply_bbox(GF_Matrix *mx, GF_BBox *b);\r
844 /*!\brief matrix box sphere transformation\r
845  *\r
846  *Applies a 3D matrix transformation to a bounding box, computing only the enclosing sphere of the transformed one.\r
847  *\param mx transformation matrix\r
848  *\param b pointer to bounding box. Once the function is called, contains the transformed bounding sphere\r
849 */\r
850 void gf_mx_apply_bbox_sphere(GF_Matrix *mx, GF_BBox *box);\r
851 /*!\brief non-affine matrix multiplication\r
852  *\r
853  *Multiplies two non-affine matrices mx = mx*mul\r
854 */\r
855 void gf_mx_add_matrix_4x4(GF_Matrix *mat, GF_Matrix *mul);\r
856 /*!\brief non-affine matrix inversion\r
857  *\r
858  *Inverses a non-affine matrices\r
859  *\return 1 if inversion was done, 0 if inversion not possible.\r
860 */\r
861 Bool gf_mx_inverse_4x4(GF_Matrix *mx);\r
862 /*!\brief matrix 4D vector transformation\r
863  *\r
864  *Applies a 3D non-affine matrix transformation to a 4 dimension vector\r
865  *\param mx transformation matrix\r
866  *\param vec pointer to the vector. Once the function is called, contains the transformed vector\r
867 */\r
868 void gf_mx_apply_vec_4x4(GF_Matrix *mx, GF_Vec4 *vec);\r
869 /*!\brief matrix decomposition\r
870  *\r
871  *Decomposes a matrix into translation, scale, shear and rotate\r
872  *\param mx the matrix to decompose\r
873  *\param translate the decomposed translation part\r
874  *\param scale the decomposed scaling part\r
875  *\param rotate the decomposed rotation part, expressed as a Rotataion (axis + angle)\r
876  *\param shear the decomposed shear part\r
877  */\r
878 void gf_mx_decompose(GF_Matrix *mx, GF_Vec *translate, GF_Vec *scale, GF_Vec4 *rotate, GF_Vec *shear);\r
879 /*!\brief matrix vector rotation\r
880  *\r
881  *Rotates a vector with a given matrix, ignoring any translation.\r
882  *\param mx transformation matrix\r
883  *\param pt pointer to 3D vector. Once the function is called, pt contains the transformed vector\r
884  */\r
885 void gf_mx_rotate_vector(GF_Matrix *mx, GF_Vec *pt);\r
886 /*!\brief matrix initialization from vectors\r
887  *\r
888  *Inits a matrix to rotate the local axis in the given vectors\r
889  \param mx matrix to initialize\r
890  \param x_axis target normalized X axis\r
891  \param y_axis target normalized Y axis\r
892  \param z_axis target normalized Z axis\r
893 */\r
894 void gf_mx_rotation_matrix_from_vectors(GF_Matrix *mx, GF_Vec x_axis, GF_Vec y_axis, GF_Vec z_axis);\r
895 /*!\brief matrix to 2D matrix \r
896  *\r
897  *Inits a 2D matrix by removing all depth info from a 3D matrix\r
898  *\param mx2d 2D matrix to initialize\r
899  *\param mx 3D matrix to use\r
900 */\r
901 void gf_mx2d_from_mx(GF_Matrix2D *mx2d, GF_Matrix *mx);\r
902 \r
903 /*!\brief Plane object*/\r
904 typedef struct\r
905 {\r
906         /*!normal vector to the plane*/\r
907         GF_Vec normal;\r
908         /*!distance from origin of the plane*/\r
909         Fixed d;\r
910 } GF_Plane;\r
911 /*!\brief matrix plane transformation\r
912  *\r
913  *Transorms a plane by a given matrix\r
914  *\param mx the matrix to use\r
915  *\param plane pointer to 3D plane. Once the function is called, plane contains the transformed plane\r
916  */\r
917 void gf_mx_apply_plane(GF_Matrix *mx, GF_Plane *plane);\r
918 /*!\brief point to plane distance\r
919  *\r
920  *Gets the distance between a point and a plne\r
921  *\param plane the plane to use\r
922  *\param p pointer to ^point to check\r
923  *\return the distance between the place and the point\r
924  */\r
925 Fixed gf_plane_get_distance(GF_Plane *plane, GF_Vec *p);\r
926 /*!\brief closest point on a line\r
927  *\r
928  *Gets the closest point on a line from a given point in space\r
929  *\param line_pt a point of the line to test\r
930  *\param line_vec the normalized direction vector of the line\r
931  *\param pt the point to check\r
932  *\return the closest point on the line to the desired point\r
933  */\r
934 GF_Vec gf_closest_point_to_line(GF_Vec line_pt, GF_Vec line_vec, GF_Vec pt);\r
935 /*!\brief box p-vertex index\r
936  *\r
937  *Gets the p-vertex index for a given plane. The p-vertex index is the index of the closest vertex of a bounding box to the plane. The vertices of a box are always \r
938  *ordered in GPAC? cf \ref gf_bbox_get_vertices\r
939  *\param p the plane to check\r
940  *\return the p-vertex index value, ranging from 0 to 7\r
941 */\r
942 u32 gf_plane_get_p_vertex_idx(GF_Plane *p);\r
943 /*!\brief plane line intersection\r
944  *\r
945  *Checks for the intersection of a plane and a line\r
946  *\param plane plane to test\r
947  *\param linepoint a point on the line to test\r
948  *\param linevec normalized direction vector of the line to test\r
949  *\param outPoint optional pointer to retrieve the intersection point, NULL otherwise\r
950  *\return 1 if line and plane intersect, 0 otherwise\r
951 */\r
952 Bool gf_plane_intersect_line(GF_Plane *plane, GF_Vec *linepoint, GF_Vec *linevec, GF_Vec *outPoint);\r
953 \r
954 /*!Classification types for box/plane position used in \ref gf_bbox_plane_relation*/\r
955 enum \r
956 {       \r
957         /*!box is in front of the plane*/\r
958         GF_BBOX_FRONT,\r
959         /*!box intersects the plane*/\r
960         GF_BBOX_INTER,\r
961         /*!box is back of the plane*/\r
962         GF_BBOX_BACK\r
963 };\r
964 /*!\brief box-plane relation\r
965  *\r
966  *Gets the spatial relation between a box and a plane\r
967  *\param box the box to check\r
968  *\param p the plane to check\r
969  *\return the relation type\r
970  */\r
971 u32 gf_bbox_plane_relation(GF_BBox *box, GF_Plane *p);\r
972 \r
973 /*!\brief 3D Ray\r
974  *\r
975  *The 3D ray object is used in GPAC for all collision and mouse interaction tests\r
976 */\r
977 typedef struct\r
978 {\r
979         /*!origin point of the ray*/\r
980         GF_Vec orig;\r
981         /*!normalized direction vector of the ray*/\r
982         GF_Vec dir;\r
983 } GF_Ray;\r
984 \r
985 /*!\brief ray constructor\r
986  *\r
987  *Constructs a ray object\r
988  *\param start starting point of the ray\r
989  *\param end end point of the ray, or any point on the ray\r
990  *\return the ray object\r
991 */\r
992 GF_Ray gf_ray(GF_Vec start, GF_Vec end);\r
993 /*!\brief matrix ray transformation\r
994  *\r
995  *Transforms a ray by a given transformation matrix\r
996  *\param mx the matrix to use\r
997  *\param r pointer to the ray. Once the function is called, contains the transformed ray\r
998 */\r
999 void gf_mx_apply_ray(GF_Matrix *mx, GF_Ray *r);\r
1000 /*!\brief ray box intersection test\r
1001  *\r
1002  *Checks if a ray intersects a box or not\r
1003  *\param ray the ray to check\r
1004  *\param min_edge the minimum edge of the box to check\r
1005  *\param max_edge the maximum edge of the box to check\r
1006  *\param out_point optional location of a 3D point to store the intersection, NULL otherwise.\r
1007  *\return retuns 1 if the ray intersects the box, 0 otherwise\r
1008 */\r
1009 Bool gf_ray_hit_box(GF_Ray *ray, GF_Vec min_edge, GF_Vec max_edge, GF_Vec *out_point);\r
1010 /*!\brief ray sphere intersection test\r
1011  *\r
1012  *Checks if a ray intersects a box or not\r
1013  *\param ray the ray to check\r
1014  *\param center the center of the sphere to check. If NULL, the origin (0,0,0)is used\r
1015  *\param radius the radius of the sphere to check\r
1016  *\param out_point optional location of a 3D point to store the intersection, NULL otherwise\r
1017  *\return retuns 1 if the ray intersects the sphere, 0 otherwise\r
1018 */\r
1019 Bool gf_ray_hit_sphere(GF_Ray *ray, GF_Vec *center, Fixed radius, GF_Vec *out_point);\r
1020 /*!\brief ray triangle intersection test\r
1021  *\r
1022  *Checks if a ray intersects a triangle or not\r
1023  *\param ray the ray to check\r
1024  *\param v0 first vertex of the triangle\r
1025  *\param v1 second vertex of the triangle\r
1026  *\param v2 third vertex of the triangle\r
1027  *\param dist optional location of a fixed number to store the intersection distance from ray origin if any, NULL otherwise\r
1028  *\return retuns 1 if the ray intersects the triangle, 0 otherwise\r
1029 */\r
1030 Bool gf_ray_hit_triangle(GF_Ray *ray, GF_Vec *v0, GF_Vec *v1, GF_Vec *v2, Fixed *dist);\r
1031 /*same as above and performs backface cull (solid meshes)*/\r
1032 /*!\brief ray triangle intersection test\r
1033  *\r
1034  *Checks if a ray intersects a triangle or not, performing backface culling. For parameters details, look at \ref gf_ray_hit_triangle_backcull\r
1035  */\r
1036 Bool gf_ray_hit_triangle_backcull(GF_Ray *ray, GF_Vec *v0, GF_Vec *v1, GF_Vec *v2, Fixed *dist);\r
1037 \r
1038 /*! @} */\r
1039 \r
1040 /*! @} */\r
1041 \r
1042 #ifdef __cplusplus\r
1043 }\r
1044 #endif\r
1045 \r
1046 \r
1047 #endif          /*_GF_MATH_H_*/\r
1048 \r