?? gen_tables.c
字號:
/* fixedpoint (c) 2006 Kris Beevers This file is part of fixedpoint. fixedpoint is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. fixedpoint is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with fixedpoint; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA $Id: gen_tables.c,v 1.1.1.1 2006/10/18 22:30:17 beevek Exp $*/// this program generates sin/cos tables using the fixed point// definitions from fixedpoint.h. you should make sure to re-generate// the tables if you change the size of the decimal part in any way;// put the tables in fixedpoint.c#include <stdio.h>#include <math.h>#include "fixedpoint.h"int main(){ uint32_t count; fixed_t a; printf("#define TRIG_TABLE_SIZE %d // put this at top of fixedpoint.c\n", fp_pi/(1<<fp_trig_shift)); printf("static fixed_t sin_table[] = {\n "); for(count = 1, a = 0; a < fp_pi+1; a += 1<<fp_trig_shift, ++count) { double s = sin(fp2float(a)); fixed_t sfp = float2fp(s); if(!(count % 16)) printf("%d,\n ", sfp); else printf("%d, ", sfp); } printf("\n};\n\n"); printf("static fixed_t cos_table[] = {\n "); for(count = 1, a = 0; a < fp_pi+1; a += 1<<fp_trig_shift, ++count) { double c = cos(fp2float(a)); fixed_t cfp = float2fp(c); if(!(count % 16)) printf("%d,\n ", cfp); else printf("%d, ", cfp); } printf("\n};\n\n"); printf("static fixed_t tan_table[] = {\n "); for(count = 1, a = 0; a < fp_pi+1; a += 1<<fp_trig_shift, ++count) { double t = tan(fp2float(a)); fixed_t tfp = float2fp(t); if(!(count % 16)) printf("%d,\n ", tfp); else printf("%d, ", tfp); } printf("\n};\n\n"); return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -