ファンクション・ジェネレータ

Dependencies:   mbed SerialTxRxIntr MyTicker7 Array_Matrix

FastSin.hpp

Committer:
MikamiUitOpen
Date:
2020-10-17
Revision:
0:17c762b41fc7
Child:
1:ea5aa7f3d68c

File content as of revision 0:17c762b41fc7:

//-----------------------------------------------------------
//  FastSin() 関数
//      sin(π/2)x) の値の計算
//
//  2020/06/01, Copyright (c) 2020 MIKAMI, Naoki
//-----------------------------------------------------------

#ifndef FASTSIN_POLYNOMIAL_HPP
#define FASTSIN_POLYNOMIAL_HPP

namespace Mikami
{
    // 引数の範囲: -2 <= x <= 2
    inline float FastSin(float x)
    {
        static const float A1 =  1.570320019210f;
        static const float A3 = -0.642113166941f;
        static const float A5 =  0.071860854119f;

        if (x >  1.0f) x =  2.0f - x;
        if (x < -1.0f) x = -2.0f - x;
        float x2 = x*x;
        return ((A5*x2 + A3)*x2 + A1)*x;
    }
}
#endif  // FASTSIN_POLYNOMIAL_HPP