Mercurial > hg > Game > WebGL
comparison dandy/resources/sankaku.js @ 1:54589bb5e57d
add dandy
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 23 Feb 2012 14:51:33 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:718974a1a32b | 1:54589bb5e57d |
---|---|
1 mycos = []; | |
2 mysin = []; | |
3 const SANKAKU = 100000; | |
4 const pi2 = Math.PI * 2.0; | |
5 | |
6 | |
7 function sankakuf() | |
8 { | |
9 for(var i=0; i < 180; i++){ | |
10 mysin[i] = Math.sin(i / 360.0 * pi2) * SANKAKU; | |
11 } | |
12 for(i=0; i < 180; i++) { | |
13 mycos[i] = Math.cos(i / 360.0 * pi2) * SANKAKU; | |
14 } | |
15 } | |
16 | |
17 function Mycos(c) | |
18 { | |
19 c = parseInt(c); | |
20 c %= 360; | |
21 if(c < 0) | |
22 c += 360; | |
23 if((c <= 180)) | |
24 return (mycos[c]); | |
25 if(c > 180) | |
26 return (mycos[180 - (c - 180)]); | |
27 return 0; | |
28 } | |
29 | |
30 function Mysin(c) | |
31 { | |
32 c = parseInt(c); | |
33 if(c < 1) c += 1; | |
34 c %= 360; | |
35 if( c < 0) | |
36 c += 360; | |
37 if(c <= 180) | |
38 return (mysin[c]); | |
39 if(c > 180) | |
40 return (mysin[180 - (c - 180)] * -1); | |
41 return 0; | |
42 } |