AOT計算で呼び出し自体を早くする三角関数

Dependents:   NuMidi401 NuFM401

Committer:
kb10uy
Date:
Mon Dec 29 02:41:37 2014 +0000
Revision:
9:d6153f6a5f75
Parent:
8:b771ac4871bb
Child:
10:5bccb4bc4f33
???

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kb10uy 0:2888f1d9a23e 1 #pragma once
kb10uy 0:2888f1d9a23e 2 #include "math.h"
kb10uy 0:2888f1d9a23e 3
kb10uy 0:2888f1d9a23e 4 /** AOTTrigon class
kb10uy 0:2888f1d9a23e 5 * AOT計算によって三角関数の計算を高速化します。
kb10uy 0:2888f1d9a23e 6 */
kb10uy 0:2888f1d9a23e 7 class AOTTrigon
kb10uy 0:2888f1d9a23e 8 {
kb10uy 0:2888f1d9a23e 9 public:
kb10uy 4:c15b45812c25 10 AOTTrigon();
kb10uy 0:2888f1d9a23e 11
kb10uy 7:eed80268ab34 12 inline float sin(float);
kb10uy 8:b771ac4871bb 13 inline float cos(float);
kb10uy 7:eed80268ab34 14 inline float tan(float);
kb10uy 0:2888f1d9a23e 15
kb10uy 0:2888f1d9a23e 16 private:
kb10uy 7:eed80268ab34 17 float *t_sin;
kb10uy 7:eed80268ab34 18 float rate;
kb10uy 9:d6153f6a5f75 19 const double pi;
kb10uy 1:f1e55d228f6a 20 };
kb10uy 3:ba78a1dd8b55 21
kb10uy 7:eed80268ab34 22 inline float AOTTrigon::sin(float x)
kb10uy 3:ba78a1dd8b55 23 {
kb10uy 4:c15b45812c25 24 return t_sin[((int)(x * rate)) & 0xFF];
kb10uy 3:ba78a1dd8b55 25 }
kb10uy 8:b771ac4871bb 26
kb10uy 7:eed80268ab34 27 inline float AOTTrigon::cos(float x)
kb10uy 3:ba78a1dd8b55 28 {
kb10uy 7:eed80268ab34 29 return sin(x + pi / 2.0f);
kb10uy 3:ba78a1dd8b55 30 }
kb10uy 8:b771ac4871bb 31
kb10uy 7:eed80268ab34 32 inline float AOTTrigon::tan(float x)
kb10uy 3:ba78a1dd8b55 33 {
kb10uy 3:ba78a1dd8b55 34 return sin(x) / cos(x);
kb10uy 3:ba78a1dd8b55 35 }