LoginSignup
1
0

More than 5 years have passed since last update.

フーリエ級数展開可視化

Posted at

箱のような形を以下のようなフーリエ級数で展開し、N=Mを増やしていったときにどんな感じになるかの確認。

\begin{eqnarray}
f(x,y)=\sum_{m=1}^{M}\sum_{n=1}^{N}b_{mn}sin\frac{mπ}{L}x・sin\frac{nπ}{L}y
\end{eqnarray}

fourier_n_1-2.PNG
fourier_n_4.PNG
fourier_n_6.PNG
fourier_n_10.PNG
fourier_n_15.PNG
fourier_n_22.PNG
fourier_n_30.PNG
fourier_n_40.PNG
fourier_n_50.PNG

// (x,y)での高さを計算
float calcHeight(float x, float y, int N, int M)
{
    float y = 0.0f, temp_y = 0.0f;
    int i, j;
    for (i = 1; i <= N; i++)
    {
        temp_y = sin((float)i*PI*0.5f)*cos((float)i*PI*0.1f*x)/(float)i;
        for (j = 1; j <= M; j++)
        {
            y += tempy*sin((float)j*PI*0.5f)*cos((float)i*PI*0.1f*y)/(float)j;
        }
    }
    y *= 4.0f/(PI*PI);
    return y;
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0