AOT計算で呼び出し自体を早くする三角関数
AOTTrigon.cpp@0:2888f1d9a23e, 2014-12-22 (annotated)
- Committer:
- kb10uy
- Date:
- Mon Dec 22 13:10:53 2014 +0000
- Revision:
- 0:2888f1d9a23e
- Child:
- 2:d8c9637a5f09
initial commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kb10uy | 0:2888f1d9a23e | 1 | #include "AOTTrigon.h" |
kb10uy | 0:2888f1d9a23e | 2 | |
kb10uy | 0:2888f1d9a23e | 3 | AOTTrigon::AOTTrigon(int divide) { |
kb10uy | 0:2888f1d9a23e | 4 | division = divide; |
kb10uy | 0:2888f1d9a23e | 5 | rate = division / (3.14159265358979323846264 * 2.0); |
kb10uy | 0:2888f1d9a23e | 6 | t_sin = new double[division]; |
kb10uy | 0:2888f1d9a23e | 7 | for(int i = 0; i < division; i++) |
kb10uy | 0:2888f1d9a23e | 8 | t_sin[i] = sin((double)i / division * (3.14159265358979323846264 * 2.0)); |
kb10uy | 0:2888f1d9a23e | 9 | } |
kb10uy | 0:2888f1d9a23e | 10 | |
kb10uy | 0:2888f1d9a23e | 11 | inline double AOTTrigon::sine(double x) { |
kb10uy | 0:2888f1d9a23e | 12 | return t_sin[(int)(fmod(x,3.14159265358979323846264*2.0)*rate)]; |
kb10uy | 0:2888f1d9a23e | 13 | } |
kb10uy | 0:2888f1d9a23e | 14 | |
kb10uy | 0:2888f1d9a23e | 15 | inline double AOTTrigon::cosine(double x) { |
kb10uy | 0:2888f1d9a23e | 16 | return sine(x+3.14159265358979323846264/2.0); |
kb10uy | 0:2888f1d9a23e | 17 | } |
kb10uy | 0:2888f1d9a23e | 18 | |
kb10uy | 0:2888f1d9a23e | 19 | inline double AOTTrigon::tangent(double x) { |
kb10uy | 0:2888f1d9a23e | 20 | return sine(x)/cosine(x); |
kb10uy | 0:2888f1d9a23e | 21 | } |