Mercurial > hg > Members > kono > tree_dandy2
view sankaku.c @ 0:01387a2e419e
initial version
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 07 Dec 2010 15:39:45 +0900 |
parents | |
children |
line wrap: on
line source
#include <math.h> #include "sankaku.h" #define SANKAKU 100000 int mysin[181]; int mycos[181]; void sankakuf() { int i; for (i = 0; i < 181; i++) { mysin[i] = sin(i / 360.0 * pi2) * SANKAKU; } for (i = 0; i < 181; i++) { mycos[i] = cos(i / 360.0 * pi2) * SANKAKU; } } int Mycos(int c) { c %= 360; if (c < 0) c += 360; if ((c <= 180)) return (mycos[c]); if (c > 180) return (mycos[180 - (c - 180)]); return (0); } int Mysin(int c) { c %= 360; if (c < 0) c += 360; if (c <= 180) return (mysin[c]); if (c > 180) return (mysin[180 - (c - 180)] * -1); return (0); }