2 # Script to generate trigonometric function tables.
4 # GRUB -- GRand Unified Bootloader
5 # Copyright (C) 2008 Free Software Foundation, Inc.
7 # GRUB is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # GRUB is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with GRUB. If not, see <http://www.gnu.org/licenses/>.
21 from sys
import stdout
26 def writeTable(arr
, name
):
32 for i
in range(len(arr
)):
45 # Convert to an angle in 1/256 of a circle.
47 sintab
.append(int(round(sin(x
) * 16384)))
48 costab
.append(int(round(cos(x
) * 16384)))
50 write("#define TRIG_ANGLE_MAX 256\n")
51 write("#define TRIG_FRACTION_SCALE 16384\n")
52 writeTable(sintab
, "sintab")
53 writeTable(costab
, "costab")
55 if __name__
== "__main__":