1 /***************************************************************************/ |
1 /**************************************************************************** |
2 /* */ |
2 * |
3 /* fttrigon.c */ |
3 * fttrigon.c |
4 /* */ |
4 * |
5 /* FreeType trigonometric functions (body). */ |
5 * FreeType trigonometric functions (body). |
6 /* */ |
6 * |
7 /* Copyright 2001-2018 by */ |
7 * Copyright (C) 2001-2019 by |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
8 * David Turner, Robert Wilhelm, and Werner Lemberg. |
9 /* */ |
9 * |
10 /* This file is part of the FreeType project, and may only be used, */ |
10 * This file is part of the FreeType project, and may only be used, |
11 /* modified, and distributed under the terms of the FreeType project */ |
11 * modified, and distributed under the terms of the FreeType project |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
12 * license, LICENSE.TXT. By continuing to use, modify, or distribute |
13 /* this file you indicate that you have read the license and */ |
13 * this file you indicate that you have read the license and |
14 /* understand and accept it fully. */ |
14 * understand and accept it fully. |
15 /* */ |
15 * |
16 /***************************************************************************/ |
16 */ |
17 |
17 |
18 /*************************************************************************/ |
18 /************************************************************************** |
19 /* */ |
19 * |
20 /* This is a fixed-point CORDIC implementation of trigonometric */ |
20 * This is a fixed-point CORDIC implementation of trigonometric |
21 /* functions as well as transformations between Cartesian and polar */ |
21 * functions as well as transformations between Cartesian and polar |
22 /* coordinates. The angles are represented as 16.16 fixed-point values */ |
22 * coordinates. The angles are represented as 16.16 fixed-point values |
23 /* in degrees, i.e., the angular resolution is 2^-16 degrees. Note that */ |
23 * in degrees, i.e., the angular resolution is 2^-16 degrees. Note that |
24 /* only vectors longer than 2^16*180/pi (or at least 22 bits) on a */ |
24 * only vectors longer than 2^16*180/pi (or at least 22 bits) on a |
25 /* discrete Cartesian grid can have the same or better angular */ |
25 * discrete Cartesian grid can have the same or better angular |
26 /* resolution. Therefore, to maintain this precision, some functions */ |
26 * resolution. Therefore, to maintain this precision, some functions |
27 /* require an interim upscaling of the vectors, whereas others operate */ |
27 * require an interim upscaling of the vectors, whereas others operate |
28 /* with 24-bit long vectors directly. */ |
28 * with 24-bit long vectors directly. |
29 /* */ |
29 * |
30 /*************************************************************************/ |
30 */ |
31 |
31 |
32 #include <ft2build.h> |
32 #include <ft2build.h> |
33 #include FT_INTERNAL_OBJECTS_H |
33 #include FT_INTERNAL_OBJECTS_H |
34 #include FT_INTERNAL_CALC_H |
34 #include FT_INTERNAL_CALC_H |
35 #include FT_TRIGONOMETRY_H |
35 #include FT_TRIGONOMETRY_H |
370 vec->x = ( vec->x + 0x80L ) >> 8; |
370 vec->x = ( vec->x + 0x80L ) >> 8; |
371 vec->y = ( vec->y + 0x80L ) >> 8; |
371 vec->y = ( vec->y + 0x80L ) >> 8; |
372 } |
372 } |
373 |
373 |
374 |
374 |
375 /* these macros return 0 for positive numbers, |
|
376 and -1 for negative ones */ |
|
377 #define FT_SIGN_LONG( x ) ( (x) >> ( FT_SIZEOF_LONG * 8 - 1 ) ) |
|
378 #define FT_SIGN_INT( x ) ( (x) >> ( FT_SIZEOF_INT * 8 - 1 ) ) |
|
379 #define FT_SIGN_INT32( x ) ( (x) >> 31 ) |
|
380 #define FT_SIGN_INT16( x ) ( (x) >> 15 ) |
|
381 |
|
382 |
|
383 /* documentation is in fttrigon.h */ |
375 /* documentation is in fttrigon.h */ |
384 |
376 |
385 FT_EXPORT_DEF( void ) |
377 FT_EXPORT_DEF( void ) |
386 FT_Vector_Rotate( FT_Vector* vec, |
378 FT_Vector_Rotate( FT_Vector* vec, |
387 FT_Angle angle ) |
379 FT_Angle angle ) |