blob: 8b75b383821f345693d4075e52e487c918f5c7f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include "global.h"
#include "trig.h"
extern s16 gSineTable[];
extern s16 gSineDegreeTable[];
// amplitude * sin(index*(π/128))
s16 Sin(s16 index, s16 amplitude)
{
return (amplitude * gSineTable[index]) >> 8;
}
// amplitude * cos(index*(π/128))
s16 Cos(s16 index, s16 amplitude)
{
return (amplitude * gSineTable[index + 64]) >> 8;
}
// angle in degrees
s16 Sin2(u16 angle)
{
s32 angleMod = angle % 180;
s32 negate = ((angle / 180) & 1);
s16 value = gSineDegreeTable[angleMod];
if (negate)
return -value;
else
return value;
}
// angle in degrees
s16 Cos2(u16 angle)
{
return Sin2(angle + 90);
}
|