SGDK
A free and open development kit for the Sega Mega Drive
Loading...
Searching...
No Matches
maths.h
Go to the documentation of this file.
1
10
11#ifndef _MATHS_H_
12#define _MATHS_H_
13
14
15
16// 1° step is enough for FIX16
17extern const fix16 trigtab_f16[90 + 1];
18// 0.25° step is ok for fix32
19extern const fix32 trigtab_f32[(90 * 4) + 1];
20
21extern const fix16 log2tab_f16[0x10000];
22extern const fix16 log10tab_f16[0x10000];
23extern const fix16 sqrttab_f16[0x10000];
24
25
26#ifndef PI
31#define PI 3.14159265358979323846
32#endif
33
34
35#define FIX16_INT_BITS 10
36#define FIX16_FRAC_BITS (16 - FIX16_INT_BITS)
37#define FIX16_INT_MASK (((1 << FIX16_INT_BITS) - 1) << FIX16_FRAC_BITS)
38#define FIX16_FRAC_MASK ((1 << FIX16_FRAC_BITS) - 1)
39
40#define FIX32_INT_BITS 22
41#define FIX32_FRAC_BITS (32 - FIX32_INT_BITS)
42#define FIX32_INT_MASK (((1 << FIX32_INT_BITS) - 1) << FIX32_FRAC_BITS)
43#define FIX32_FRAC_MASK ((1 << FIX32_FRAC_BITS) - 1)
44
45#define FASTFIX16_INT_BITS 8
46#define FASTFIX16_FRAC_BITS (16 - FASTFIX16_INT_BITS)
47#define FASTFIX16_INT_MASK (((1 << FASTFIX16_INT_BITS) - 1) << FASTFIX16_FRAC_BITS)
48#define FASTFIX16_FRAC_MASK ((1 << FASTFIX16_FRAC_BITS) - 1)
49
50#define FASTFIX32_INT_BITS 16
51#define FASTFIX32_FRAC_BITS (32 - FASTFIX32_INT_BITS)
52#define FASTFIX32_INT_MASK (((1 << FASTFIX32_INT_BITS) - 1) << FASTFIX32_FRAC_BITS)
53#define FASTFIX32_FRAC_MASK ((1 << FASTFIX32_FRAC_BITS) - 1)
54
62#define FIX16(value) ((fix16) ((value) * (1 << FIX16_FRAC_BITS)))
70#define FIX32(value) ((fix32) ((value) * (1 << FIX32_FRAC_BITS)))
71
79#define FASTFIX16(value) ((fastfix16) ((value) * (1 << FASTFIX16_FRAC_BITS)))
87#define FASTFIX32(value) ((fastfix32) ((value) * (1 << FASTFIX32_FRAC_BITS)))
88
94#define F16(value) FIX16(value)
100#define F32(value) FIX32(value)
106#define FF16(value) FASTFIX16(value)
112#define FF32(value) FASTFIX32(value)
113
114
115#define F16_PI ((fix16) F16(PI))
116#define F16_RAD_TO_DEG F16(57.29577951308232)
117
118#define F32_PI ((fix32) F32(PI))
119
120
121// 2D base structures
122
127typedef struct
128{
129 u16 x;
130 u16 y;
131} Vect2D_u16;
132
137typedef struct
138{
139 s16 x;
140 s16 y;
141} Vect2D_s16;
142
147typedef struct
148{
149 u32 x;
150 u32 y;
151} Vect2D_u32;
152
157typedef struct
158{
159 s32 x;
160 s32 y;
161} Vect2D_s32;
162
167typedef struct
168{
169 fix16 x;
170 fix16 y;
171} Vect2D_f16;
172
177typedef struct
178{
179 fix32 x;
180 fix32 y;
181} Vect2D_f32;
182
187typedef struct
188{
189 fastfix16 x;
190 fastfix16 y;
192
197typedef struct
198{
199 fastfix32 x;
200 fastfix32 y;
202
208typedef struct
209{
210 Vect2D_f16 a;
211 Vect2D_f16 b;
212} Mat2D_f16;
213
219typedef struct
220{
221 Vect2D_f32 a;
222 Vect2D_f32 b;
223} Mat2D_f32;
224
230typedef struct
231{
232 Vect2D_ff16 a;
233 Vect2D_ff16 b;
234} Mat2D_ff16;
235
241typedef struct
242{
243 Vect2D_ff32 a;
244 Vect2D_ff32 b;
245} Mat2D_ff32;
246
247// short alias
248
297
299// Basic math functions
301
306#define min(X, Y) (((X) < (Y))?(X):(Y))
307
312#define max(X, Y) (((X) > (Y))?(X):(Y))
313
318#define clamp(X, L, H) (min(max((X), (L)), (H)))
319
320#if (ENABLE_NEWLIB == 0)
325#define abs(X) (((X) < 0)?-(X):(X))
326#endif // ENABLE_NEWLIB
327
328
338u8 rol8(u8 value, u16 number);
348u16 rol16(u16 value, u16 number);
358u32 rol32(u32 value, u16 number);
368u8 ror8(u8 value, u16 number);
378u16 ror16(u16 value, u16 number);
388u32 ror32(u32 value, u16 number);
389
400u32 mulu(u16 op1, u16 op2);
411s32 muls(s16 op1, s16 op2);
423u16 divu(u32 op1, u16 op2);
435s16 divs(s32 op1, s16 op2);
446u16 modu(u32 op1, u16 op2);
457s16 mods(s32 op1, s16 op2);
458
471u32 divmodu(u32 op1, u16 op2);
484s32 divmods(s32 op1, s16 op2);
485
493u32 u16ToBCD(u16 value);
501u32 u32ToBCD(u32 value);
502
510u32 getNextPow2(u32 value);
521u16 getLog2(u32 value);
522
542u32 getApproximatedDistanceV(V2s32* v);
543
544
545#define distance_approx(dx, dy) _Pragma("GCC error \"This method is deprecated, use getApproximatedDistance(..) instead.\"")
546#define getApproximatedLog2(value) _Pragma("GCC error \"This method is deprecated, use FF32_getLog2Fast(..) instead.\"")
547#define getLog2Int(value) _Pragma("GCC error \"This method is deprecated, use getLog2(..) instead.\"")
548
549
551// Fix16 Fixed point math functions
553
558s16 F16_toInt(fix16 value);
563fix32 F16_toFix32(fix16 value);
578fix16 F16_frac(fix16 value);
583fix16 F16_int(fix16 value);
593fix16 F16_round(fix16 value);
599
604fix16 F16_mul(fix16 val1, fix16 val2);
609fix16 F16_div(fix16 val1, fix16 val2);
614fix16 F16_avg(fix16 val1, fix16 val2);
615
625fix16 F16_log10(fix16 value);
630fix16 F16_sqrt(fix16 value);
631
642fix16 F16_sin(fix16 angle);
647fix16 F16_cos(fix16 angle);
652fix16 F16_tan(fix16 angle);
663
670fix16 sinFix16(u16 value);
677fix16 cosFix16(u16 value);
678
693fix16 F16_getAngle(fix16 x1, fix16 y1, fix16 x2, fix16 y2);
712void F16_computePosition(fix16 *x2, fix16 *y2, fix16 x1, fix16 y1, fix16 ang, fix16 dist);
735void F16_computePositionEx(fix16 *x2, fix16 *y2, fix16 x1, fix16 y1, fix16 ang, fix16 dist, fix16 cosMul, fix16 sinMul);
736
737
738// Deprecated functions
739#define intToFix16(a) _Pragma("GCC error \"This method is deprecated, use FIX16(..) instead.\"")
740#define fix16ToInt(a) _Pragma("GCC error \"This method is deprecated, use F16_toInt(..) instead.\"")
741#define fix16ToFix32(a) _Pragma("GCC error \"This method is deprecated, use F16_toFix32(..) instead.\"")
742#define fix16Frac(a) _Pragma("GCC error \"This method is deprecated, use F16_frac(..) instead.\"")
743#define fix16Int(a) _Pragma("GCC error \"This method is deprecated, use F16_int(..) instead.\"")
744#define fix16Round(a) _Pragma("GCC error \"This method is deprecated, use F16_round(..) instead.\"")
745#define fix16ToRoundedInt(a) _Pragma("GCC error \"This method is deprecated, use F16_toRoundedInt(..) instead.\"")
746#define fix16Add(a, b) _Pragma("GCC error \"This method is deprecated, simply use '+' operator to add fix16 values together.\"")
747#define fix16Sub(a, b) _Pragma("GCC error \"This method is deprecated, simply use '-' operator to subtract fix16 values.\"")
748#define fix16Neg(a) _Pragma("GCC error \"This method is deprecated, simply use '0 - value' to get the negative fix16 value.\"")
749#define fix16Mul(a, b) _Pragma("GCC error \"This method is deprecated, use F16_mul(..) instead.\"")
750#define fix16Div(a, b) _Pragma("GCC error \"This method is deprecated, use F16_div(..) instead.\"")
751#define fix16Avg(a, b) _Pragma("GCC error \"This method is deprecated, use F16_avg(..) instead.\"")
752#define fix16Log2(a) _Pragma("GCC error \"This method is deprecated, use F16_log2(..) instead.\"")
753#define fix16Log10(a) _Pragma("GCC error \"This method is deprecated, use F16_log10(..) instead.\"")
754#define fix16Sqrt(a) _Pragma("GCC error \"This method is deprecated, use F16_sqrt(..) instead.\"")
755
756
758// Fix32 Fixed point math functions
760
765s32 F32_toInt(fix32 value);
770fix16 F32_toFix16(fix32 value);
785fix32 F32_frac(fix32 value);
790fix32 F32_int(fix32 value);
795fix32 F32_round(fix32 value);
801
807fix32 F32_mul(fix32 val1, fix32 val2);
813fix32 F32_div(fix32 val1, fix32 val2);
818fix32 F32_avg(fix32 val1, fix32 val2);
819
824fix32 F32_sin(fix16 angle);
829fix32 F32_cos(fix16 angle);
830
837fix32 sinFix32(u16 value);
844fix32 cosFix32(u16 value);
845
846
847// Deprecated functions
848#define intToFix32(a) _Pragma("GCC error \"This method is deprecated, use FIX32(..) instead.\"")
849#define fix32ToInt(a) _Pragma("GCC error \"This method is deprecated, use F32_toInt(..) instead.\"")
850#define fix32ToFix16(a) _Pragma("GCC error \"This method is deprecated, use F32_toFix16(..) instead.\"")
851#define fix32Frac(a) _Pragma("GCC error \"This method is deprecated, use F32_frac(..) instead.\"")
852#define fix32Int(a) _Pragma("GCC error \"This method is deprecated, use F32_int(..) instead.\"")
853#define fix32Round(a) _Pragma("GCC error \"This method is deprecated, use F32_round(..) instead.\"")
854#define fix32ToRoundedInt(a) _Pragma("GCC error \"This method is deprecated, use F32_toRoundedInt(..) instead.\"")
855#define fix32Add(a, b) _Pragma("GCC error \"This method is deprecated, simply use '+' operator to add fix32 values together.\"")
856#define fix32Sub(a, b) _Pragma("GCC error \"This method is deprecated, simply use '-' operator to subtract fix32 values.\"")
857#define fix32Neg(a) _Pragma("GCC error \"This method is deprecated, simply use '0 - value' to get the negative fix32 value.\"")
858#define fix32Mul(a, b) _Pragma("GCC error \"This method is deprecated, use F32_mul(..) instead.\"")
859#define fix32Div(a, b) _Pragma("GCC error \"This method is deprecated, use F32_div(..) instead.\"")
860#define fix32Avg(a, b) _Pragma("GCC error \"This method is deprecated, use F32_avg(..) instead.\"")
861
862
864// Fast Fix16 Fixed point math functions
866
907
918
919
920// Deprecated functions
921#define intToFastFix16(a) _Pragma("GCC error \"This method is deprecated, use FASTFIX16(..) instead.\"")
922#define fastFix16ToInt(a) _Pragma("GCC error \"This method is deprecated, use FF16_toInt(..) instead.\"")
923#define fastFix16Frac(a) _Pragma("GCC error \"This method is deprecated, use FF16_frac(..) instead.\"")
924#define fastFix16Int(a) _Pragma("GCC error \"This method is deprecated, use FF16_int(..) instead.\"")
925#define fastFix16Round(a) _Pragma("GCC error \"This method is deprecated, use FF16_round(..) instead.\"")
926#define fastFix16ToRoundedInt(a) _Pragma("GCC error \"This method is deprecated, use FF16_toRoundedInt(..) instead.\"")
927#define fastFix16Mul(a, b) _Pragma("GCC error \"This method is deprecated, use FF16_mul(..) instead.\"")
928#define fastFix16Div(a, b) _Pragma("GCC error \"This method is deprecated, use FF16_div(..) instead.\"")
929
930
932// Fast Fix32 Fixed point math functions
934
980
993
1005
1006
1007// Deprecated functions
1008#define intToFastFix32(a) _Pragma("GCC error \"This method is deprecated, use FASTFIX32(..) instead.\"")
1009#define fastFix32ToInt(a) _Pragma("GCC error \"This method is deprecated, use FF32_toInt(..) instead.\"")
1010#define fastFix32Frac(a) _Pragma("GCC error \"This method is deprecated, use FF32_frac(..) instead.\"")
1011#define fastFix32Int(a) _Pragma("GCC error \"This method is deprecated, use FF32_int(..) instead.\"")
1012#define fastFix32Round(a) _Pragma("GCC error \"This method is deprecated, use FF32_round(..) instead.\"")
1013#define fastFix32ToRoundedInt(a) _Pragma("GCC error \"This method is deprecated, use FF32_toRoundedInt(..) instead.\"")
1014#define fastFix32Mul(a, b) _Pragma("GCC error \"This method is deprecated, use FF32_mul(..) instead.\"")
1015#define fastFix32Div(a, b) _Pragma("GCC error \"This method is deprecated, use FF32_div(..) instead.\"")
1016
1017
1019// Vector2D base math functions
1021
1026fix16 V2D_F16_getAngle(V2f16* pt1, V2f16* pt2);
1027
1039void V2D_F16_computePosition(V2f16* pt, fix16 ang, fix16 dist);
1055void V2D_F16_computePositionEx(V2f16* pt, fix16 ang, fix16 dist, fix16 cosMul, fix16 sinMUl);
1056
1066
1067
1068// Deprecated functions
1069#define getApproximatedDistanceV(dx, dy) _Pragma("GCC error \"This method is deprecated, use V2D_S32_getApproximatedDistance(..) instead.\"")
1070
1071#endif // _MATHS_H_
u8 rol8(u8 value, u16 number)
ROL instruction for byte (8 bit) value.
Definition maths.c:76
fix16 sinFix16(u16 value)
Compute sinus of specified value and return it as fix16. The input value is an integer defined as [0...
Definition maths.c:531
fastfix32 FF32_getLog2Fast(fastfix32 value)
Return a not accurate but fast log2 approximation of the specified value (fastfixed32) Ex: getLog2(F...
Definition maths.c:774
Vect2D_u32 V2u32
alias for Vect2D_u32
Definition maths.h:260
fastfix32 F16_toFastFix32(fix16 value)
Convert specified fix16 value to fastfix32.
Definition maths.c:332
fix16 F16_log10(fix16 value)
Compute and return the result of the Log10 of specified value (fix16).
Definition maths.c:384
void F16_computePosition(fix16 *x2, fix16 *y2, fix16 x1, fix16 y1, fix16 ang, fix16 dist)
Compute the new position of the point defined by (x1, y1) by moving it by the given 'distance' in the...
Definition maths.c:519
fix16 F16_cos(fix16 angle)
Compute cosinus of specified angle (in degree) and return it (fix16).
Definition maths.c:418
fastfix16 FF16_int(fastfix16 value)
Return integer part of the specified value (fastfix16).
Definition maths.c:681
fix32 F32_round(fix32 value)
Round the specified value to nearest integer (fix32).
Definition maths.c:583
void V2D_F16_computePositionEx(V2f16 *pt, fix16 ang, fix16 dist, fix16 cosMul, fix16 sinMUl)
Compute the new position of the point 'pt' by moving it by the given 'distance' in the 'angle' direct...
Definition maths.c:869
u32 getNextPow2(u32 value)
Return next pow2 value which is greater than specified 32 bits unsigned value. Ex: getNextPow2(700) ...
Definition maths.c:241
Vect2D_ff16 V2ff16
alias for Vect2D_ff16
Definition maths.h:276
u16 rol16(u16 value, u16 number)
ROL instruction for short (16 bit) value.
Definition maths.c:81
s32 F32_toRoundedInt(fix32 value)
Round and convert the specified fix32 value to integer.
Definition maths.c:588
fastfix16 FF16_div(fastfix16 val1, fastfix16 val2)
Compute and return the result of the division of val1 by val2 (fastfix16).
Definition maths.c:702
fastfix32 FF16_toFastFix32(fastfix16 value)
Convert fastfix16 to fastfix32.
Definition maths.c:671
fix32 F32_int(fix32 value)
Return integer part of the specified value (fix32).
Definition maths.c:578
u16 divu(u32 op1, u16 op2)
Direct divu instruction (unsigned 32/16=16:16) access using inline assembly to process op1/op2 operat...
Definition maths.c:137
s32 muls(s16 op1, s16 op2)
16x16=32 signed multiplication. Force GCC to use proper 68000 muls instruction.
Definition maths.c:112
Vect2D_f16 V2f16
alias for Vect2D_f16
Definition maths.h:268
u32 V2D_S32_getApproximatedDistance(V2s32 *v)
Return euclidean distance approximation for specified vector. The returned distance is not 100% perf...
Definition maths.c:875
s32 divmods(s32 op1, s16 op2)
Direct divs instruction (signed 32/16=16:16) access using inline assembly to process op1/op2 operatio...
Definition maths.c:189
fastfix32 FF32_mul(fastfix32 val1, fastfix32 val2)
Compute and return the result of the multiplication of val1 and val2 (fastfix32). WARNING: result ca...
Definition maths.c:757
s16 FF16_toRoundedInt(fastfix16 value)
Round and convert the specified fastfix16 value to integer (fastfix16).
Definition maths.c:691
Mat2D_ff16 M2ff16
alias for Mat2D_ff16
Definition maths.h:292
void F16_computePositionEx(fix16 *x2, fix16 *y2, fix16 x1, fix16 y1, fix16 ang, fix16 dist, fix16 cosMul, fix16 sinMul)
Compute the new position of the point defined by (x1, y1) by moving it by the given 'distance' in the...
Definition maths.c:524
u32 u32ToBCD(u32 value)
Convert u32 to BCD.
Definition maths.c:226
fix32 F32_mul(fix32 val1, fix32 val2)
Compute and return the result of the multiplication of val1 and val2 (fix32). WARNING: result can ea...
Definition maths.c:594
u16 modu(u32 op1, u16 op2)
Direct divu instruction (unsigned 32/16=16:16) access using inline assembly.
Definition maths.c:157
fix16 F16_radianToDegree(fix16 radian)
Convert radian to degree (fix16)
Definition maths.c:480
fix16 F16_sin(fix16 angle)
Compute sinus of specified angle (in degree) and return it (fix16).
Definition maths.c:407
fix16 F16_div(fix16 val1, fix16 val2)
Compute and return the result of the division of val1 by val2 (fix16).
Definition maths.c:368
fix32 F32_avg(fix32 val1, fix32 val2)
Compute and return the result of the average of val1 by val2 (fix32).
Definition maths.c:610
fastfix32 F32_toFastFix32(fix32 value)
Convert specified fix32 value to fastfix32.
Definition maths.c:568
fastfix16 FF32_toFastFix16(fastfix32 value)
Convert fastfix32 to fastfix16.
Definition maths.c:732
fastfix32 FF32_fromInt(s16 value)
Convert integer to fastfix32.
Definition maths.c:712
fix16 V2D_F16_getAngle(V2f16 *pt1, V2f16 *pt2)
Compute and return the angle in degree (fix16) between the 2 points pt1 and pt2.
Definition maths.c:859
Vect2D_s16 V2s16
alias for Vect2D_s16
Definition maths.h:256
fix32 F16_toFix32(fix16 value)
Convert specified fix16 value to fix32.
Definition maths.c:322
s16 F16_toRoundedInt(fix16 value)
Round and convert the specified fix16 to integer.
Definition maths.c:357
s16 divs(s32 op1, s16 op2)
Direct divs instruction (signed 32/16=16:16) access using inline assembly to process op1/op2 operatio...
Definition maths.c:147
s16 FF32_toInt(fastfix32 value)
Convert fastfix32 to integer.
Definition maths.c:717
s32 FF32_toRoundedInt(fastfix32 value)
Round and convert the specified fastfix32 value to integer.
Definition maths.c:752
Mat2D_f32 M2f32
alias for Mat2D_f32
Definition maths.h:288
fix16 F16_int(fix16 value)
Return integer part of the specified value (fix16).
Definition maths.c:342
Vect2D_u16 V2u16
alias for Vect2D_u16
Definition maths.h:252
fix32 FF16_toFix32(fastfix16 value)
Convert fastfix16 to fix32.
Definition maths.c:666
fix16 F16_sqrt(fix16 value)
Compute and return the result of the root square of specified value (fix16).
Definition maths.c:389
fix16 F16_abs(fix16 x)
Return the absolute value of the specified value (fix16).
Definition maths.c:347
fix16 F32_toFix16(fix32 value)
Convert specified fix32 value to fix16.
Definition maths.c:558
s16 F16_toInt(fix16 value)
Convert fix16 to integer.
Definition maths.c:317
fix16 F16_mul(fix16 val1, fix16 val2)
Compute and return the result of the multiplication of val1 and val2 (fix16).
Definition maths.c:363
u32 ror32(u32 value, u16 number)
ROR instruction for long (32 bit) value.
Definition maths.c:101
Mat2D_f16 M2f16
alias for Mat2D_f16
Definition maths.h:284
fix32 sinFix32(u16 value)
Compute sinus of specified value and return it as fix32. The input value is an integer defined as [0...
Definition maths.c:634
u16 getLog2(u32 value)
Return integer log2 of specified 32 bits unsigned value. Ex: getLog2Int(1024) = 10 getLog2Int(12345...
Definition maths.c:254
u32 getApproximatedDistance(s32 dx, s32 dy)
Return euclidean distance approximation for specified vector. The returned distance is not 100% perf...
Definition maths.c:284
fastfix16 FF16_mul(fastfix16 val1, fastfix16 val2)
Compute and return the result of the multiplication of val1 and val2 (fastfix16).
Definition maths.c:697
fastfix32 FF32_div(fastfix32 val1, fastfix32 val2)
Compute and return the result of the division of val1 by val2 (fastfix32). WARNING: result can easil...
Definition maths.c:765
fix16 F16_frac(fix16 value)
Return fractional part of the specified value (fix16).
Definition maths.c:337
fix32 F32_frac(fix32 value)
Return fractional part of the specified value (fix32).
Definition maths.c:573
fix32 F32_cos(fix16 angle)
Compute cosinus of specified angle (in degree) and return it as fix32.
Definition maths.c:627
s16 FF16_toInt(fastfix16 value)
Convert fastfix16 to integer.
Definition maths.c:656
u32 divmodu(u32 op1, u16 op2)
Direct divu instruction (unsigned 32/16=16:16) access using inline assembly to process op1/op2 operat...
Definition maths.c:179
u32 mulu(u16 op1, u16 op2)
16x16=32 unsigned multiplication. Force GCC to use proper 68000 mulu instruction.
Definition maths.c:107
fix32 FF32_toFix32(fastfix32 value)
Convert fastfix32 to fix32.
Definition maths.c:727
Vect2D_f32 V2f32
alias for Vect2D_f32
Definition maths.h:272
fix16 FF32_toFix16(fastfix32 value)
Convert fastfix32 to fix16.
Definition maths.c:722
u8 ror8(u8 value, u16 number)
ROR instruction for byte (8 bit) value.
Definition maths.c:91
fastfix32 FF32_frac(fastfix32 value)
Return fractional part of the specified value (fastfix32).
Definition maths.c:737
s16 mods(s32 op1, s16 op2)
Direct divs instruction (signed 32/16=16:16) access using inline assembly.
Definition maths.c:168
s32 F32_toInt(fix32 value)
Convert fix32 to integer.
Definition maths.c:553
fix16 F16_getAngle(fix16 x1, fix16 y1, fix16 x2, fix16 y2)
Compute and return the angle in degree between the 2 points defined by (x1,y1) and (x2,...
Definition maths.c:485
fix16 F16_degreeToRadian(fix16 degree)
Convert degree to radian (fix16)
Definition maths.c:475
fix16 F16_round(fix16 value)
Round the specified value to nearest integer (fix16).
Definition maths.c:352
void V2D_F16_computePosition(V2f16 *pt, fix16 ang, fix16 dist)
Compute the new position of the point 'pt' by moving it by the given 'distance' in the 'angle' direct...
Definition maths.c:864
fix16 F16_log2(fix16 value)
Compute and return the result of the Log2 of specified value (fix16).
fastfix16 FF16_round(fastfix16 value)
Round the specified value to nearest integer (fastfix16).
Definition maths.c:686
fix16 F16_avg(fix16 val1, fix16 val2)
Compute and return the result of the average of val1 by val2 (fix16).
Definition maths.c:373
fix16 F16_normalizeAngle(fix16 angle)
Return a normalized form of the input angle degree: Output value is guaranteed to be in [FIX16(0)....
Definition maths.c:395
fix32 F32_div(fix32 val1, fix32 val2)
Compute and return the result of the division of val1 by val2 (fix32). WARNING: result can easily ov...
Definition maths.c:602
fix16 F16_atan2(fix16 y, fix16 x)
Compute the arctangent of y/x. i.e: return the angle (in degree) for the (0,0)-(x,...
Definition maths.c:447
fastfix32 FF32_int(fastfix32 value)
Return integer part of the specified value (fastfix32).
Definition maths.c:742
Vect2D_s32 V2s32
alias for Vect2D_s32
Definition maths.h:264
fix16 FF16_toFix16(fastfix16 value)
Convert fastfix16 to fix16.
Definition maths.c:661
fastfix32 FF32_round(fastfix32 value)
Round the specified value to nearest integer (fastfix32).
Definition maths.c:747
Mat2D_ff32 M2ff32
alias for Mat2D_ff32
Definition maths.h:296
fix32 cosFix32(u16 value)
Compute cosinus of specified value and return it as fix32. The input value is an integer defined as ...
Definition maths.c:640
fastfix16 F32_toFastFix16(fix32 value)
Convert specified fix32 value to fastfix16.
Definition maths.c:563
fastfix16 FF16_frac(fastfix16 value)
Return fractional part of the specified value (fastfix16).
Definition maths.c:676
fix32 F32_sin(fix16 angle)
Compute sinus of specified angle (in degree) and return it as fix32.
Definition maths.c:616
fix16 F16_atan(fix16 x)
Compute the arctangent of specified value and return it in degree (fix16).
Definition maths.c:428
u32 u16ToBCD(u16 value)
Convert u16 to BCD.
Definition maths.c:200
fix16 F16_tan(fix16 angle)
Compute the tangent of specified angle (in degree) and return it (fix16).
Definition maths.c:423
Vect2D_ff32 V2ff32
alias for Vect2D_ff32
Definition maths.h:280
u32 rol32(u32 value, u16 number)
ROL instruction for long (32 bit) value.
Definition maths.c:86
fix16 cosFix16(u16 value)
Compute cosinus of specified value and return it as fix16. The input value is an integer defined as ...
Definition maths.c:537
u16 ror16(u16 value, u16 number)
ROR instruction for short (16 bit) value.
Definition maths.c:96
fastfix16 F16_toFastFix16(fix16 value)
Convert specified fix16 value to fastfix16.
Definition maths.c:327
2x2 Matrice structure - f16 (fix16) type. Internally uses 2 2D vectors.
Definition maths.h:209
2x2 Matrice structure - f32 (fix32) type. Internally uses 2 2D vectors.
Definition maths.h:220
2x2 Matrice structure - ff16 (fastfix16) type. Internally uses 2 2D vectors.
Definition maths.h:231
2x2 Matrice structure - ff32 (fastfix32) type. Internally uses 2 2D vectors.
Definition maths.h:242
2D Vector structure - f16 (fix16) type.
Definition maths.h:168
2D Vector structure - f32 (fix32) type.
Definition maths.h:178
2D Vector structure - ff16 (fastfix16) type.
Definition maths.h:188
2D Vector structure - ff32 (fastfix32) type.
Definition maths.h:198
2D Vector structure - s16 type.
Definition maths.h:138
2D Vector structure - s32 type.
Definition maths.h:158
2D Vector structure - u16 type.
Definition maths.h:128
2D Vector structure - u32 type.
Definition maths.h:148
s16 fix16
Definition types.h:210
s32 fastfix32
Definition types.h:236
unsigned long u32
Definition types.h:105
short s16
Definition types.h:84
long s32
Definition types.h:89
s16 fastfix16
Definition types.h:231
unsigned short u16
Definition types.h:100
s32 fix32
Definition types.h:215
unsigned char u8
Definition types.h:95