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

Dependents:   NuMidi401 NuFM401

Committer:
kb10uy
Date:
Mon Dec 29 02:33:50 2014 +0000
Revision:
7:eed80268ab34
Parent:
6:fddf871eba15
Child:
8:b771ac4871bb
float?

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 7:eed80268ab34 13 inline float cos(double);
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 7:eed80268ab34 19 const float 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 7:eed80268ab34 26 inline float AOTTrigon::cos(float x)
kb10uy 3:ba78a1dd8b55 27 {
kb10uy 7:eed80268ab34 28 return sin(x + pi / 2.0f);
kb10uy 3:ba78a1dd8b55 29 }
kb10uy 7:eed80268ab34 30 inline float AOTTrigon::tan(float x)
kb10uy 3:ba78a1dd8b55 31 {
kb10uy 3:ba78a1dd8b55 32 return sin(x) / cos(x);
kb10uy 3:ba78a1dd8b55 33 }