python 2次元正弦波を出力する

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 2次元正弦波を出力する相关的知识,希望对你有一定的参考价值。

# -*- coding: utf-8 -*-

import numpy as np
from matplotlib import pyplot as plt

def sine2d(x_size, y_size, a0, a, n_x, n_y, theta_x, theta_y):
    [x, y] = np.meshgrid(np.arange(0, x_size), np.arange(0, y_size))
    f = a0 + np.sin( (2 * np.pi / n_x) * (x - theta_x) + (2 * np.pi / n_y) * (y - theta_y))
    return f

if __name__ == "__main__":
    f = sine2d(256, 256, 0, 1, 100, 10, 30, 30)
    plt.imshow(f)
    plt.show()

以上是关于python 2次元正弦波を出力する的主要内容,如果未能解决你的问题,请参考以下文章