eGUI alias D4D  Release 3.0
Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
d4d_math.h
Go to the documentation of this file.
1 /**************************************************************************
2 *
3 * Copyright 2014 by Petr Gargulak. eGUI Community.
4 * Copyright 2009-2013 by Petr Gargulak. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License Version 3
9 * or later (the "LGPL").
10 *
11 * As a special exception, the copyright holders of the eGUI project give you
12 * permission to link the eGUI sources with independent modules to produce an
13 * executable, regardless of the license terms of these independent modules,
14 * and to copy and distribute the resulting executable under terms of your
15 * choice, provided that you also meet, for each linked independent module,
16 * the terms and conditions of the license of that module.
17 * An independent module is a module which is not derived from or based
18 * on this library.
19 * If you modify the eGUI sources, you may extend this exception
20 * to your version of the eGUI sources, but you are not obligated
21 * to do so. If you do not wish to do so, delete this
22 * exception statement from your version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
27 *
28 * You should have received a copy of the GNU General Public License
29 * and the GNU Lesser General Public License along with this program.
30 * If not, see <http://www.gnu.org/licenses/>.
31 *
32 ***************************************************************************/
46 #ifndef __D4D_MATH_H
47 #define __D4D_MATH_H
48 
49 /******************************************************************************
50 * Constants
51 ******************************************************************************/
52 
53 
54 
55 /******************************************************************************
56 * Types
57 ******************************************************************************/
58 
59 
60 
61 /******************************************************************************
62 * Macros
63 ******************************************************************************/
64 
65 // convert deg angle of -180..180 to internal representation (-128..127)
66 #define D4D_ANGLE_DEG(deg) (((deg)==180)?0xff:((deg)*0x100/180))
67 
68 /******************************************************************************
69 * Global variables
70 ******************************************************************************/
71 
72 
73 /******************************************************************************
74 * Global functions
75 ******************************************************************************/
76 
77 sByte D4D_Sin(Byte x);
78 sByte D4D_Cos(Byte x);
79 
80 Byte D4D_MulDivUU8(Byte u1, Byte u2, Byte d);
82 
83 Word D4D_MulDivUU16(Word u1, Word u2, Word d);
85 
86 Byte D4D_Abs(sByte num);
87 Word D4D_Abs16(sWord num);
89 
90 Word D4D_LimitU16(Word val, Word min, Word max);
91 sWord D4D_LimitS16(sWord val, sWord min, sWord max);
92 
93 Byte D4D_LimitU8(Byte val, Byte min, Byte max);
94 sByte D4D_LimitS8(sByte val, sByte min, sByte max);
95 
96 #ifdef D4D_COOR_TYPE
97  #define D4D_MulDivUU D4D_MulDivUU16
98  #define D4D_MulDivSU D4D_MulDivSU16
99  #define D4D_LimitU D4D_LimitU16
100  #define D4D_LimitS D4D_LimitS16
101 #else
102 
103  #define D4D_MulDivUU D4D_MulDivUU8
104  #define D4D_MulDivSU D4D_MulDivSU8
105  #define D4D_LimitU D4D_LimitU8
106  #define D4D_LimitS D4D_LimitS8
107 #endif
108 
109 
110 #endif /* __D4D_MATH_H */
Word D4D_MulDivUU16(Word u1, Word u2, Word d)
Simple proportion unsigned calculation - 16 bit.
Definition: d4d_math.c:257
signed long sLWord
Type definition of sLWord (signed 32-bit).
Definition: d4d_types.h:171
Word D4D_Abs16(sWord num)
Calculation of absolute value - 16 bit.
Definition: d4d_math.c:325
sByte D4D_LimitS8(sByte val, sByte min, sByte max)
Calculation of limitation value (signed) - 8 bit.
Definition: d4d_math.c:448
unsigned char Byte
Type definition of Byte (unsigned 8-bit).
Definition: d4d_types.h:151
sByte D4D_Sin(Byte x)
Sine calculation using lookup table.
Definition: d4d_math.c:472
unsigned long LWord
Type definition of LWord (unsigned 32-bit).
Definition: d4d_types.h:167
signed short sWord
Type definition of sWord (signed 16-bit).
Definition: d4d_types.h:163
Byte D4D_MulDivUU8(Byte u1, Byte u2, Byte d)
Simple proportion unsigned calculation - 8 bit.
Definition: d4d_math.c:206
Byte D4D_LimitU8(Byte val, Byte min, Byte max)
Calculation of limitation value (unsigned) - 8 bit.
Definition: d4d_math.c:421
sWord D4D_LimitS16(sWord val, sWord min, sWord max)
Calculation of limitation value (signed) - 16 bit.
Definition: d4d_math.c:394
signed char sByte
Type definition of sByte (signed 8-bit).
Definition: d4d_types.h:155
Word D4D_LimitU16(Word val, Word min, Word max)
Calculation of limitation value (unsigned) - 16 bit.
Definition: d4d_math.c:367
sWord D4D_MulDivSU16(sWord s, Word u, Word d)
Simple proportion signed calculation - 8 bit.
Definition: d4d_math.c:276
Byte D4D_Abs(sByte num)
Calculation of absolute value - 8 bit.
Definition: d4d_math.c:306
sByte D4D_Cos(Byte x)
Cosine calculation using lookup table.
Definition: d4d_math.c:502
sByte D4D_MulDivSU8(sByte s, Byte u, Byte d)
Simple proportion signed calculation - 8 bit.
Definition: d4d_math.c:225
LWord D4D_Abs32(sLWord num)
Calculation of absolute value - 32 bit.
Definition: d4d_math.c:344
unsigned short Word
Type definition of Word (unsigned 16-bit).
Definition: d4d_types.h:159