ファイル:Barnes-Hut tree construction.png

提供: testwiki
ナビゲーションに移動 検索に移動
    元のファイル (300 × 300 ピクセル、ファイルサイズ: 9キロバイト、MIME タイプ: image/png、繰り返し、6 フレーム、6.0秒)
    注意: 技術的な制限により、このファイルのサムネイルはアニメーションされません。

    このファイルはウィキメディア・コモンズのものであり、他のプロジェクトで使用されている可能性があります。 ウィキメディア・コモンズでのファイル解説ページにある説明を以下に示します。

    概要

    解説
    English: An animation of Barnes-Hut tree construction for 48 particles distributed in a 2D box uniformly.
    日付
    原典 投稿者自身による著作物
    作者 Osanshouo

    Source code

    This animation was created with the following Python source code.

    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.cm as cm
    
    def cube_plot(ax, pos, level, idx):
        d = 1./2**level
        idx = [ idx[0]*d, idx[1]*d ]
        count = np.sum((pos[:,0] - idx[0] >= 0)*(pos[:,0] - idx[0] < d)*(pos[:,1] - idx[1] >= 0)*(pos[:,1] - idx[1] < d))
        if count == 0:
            return count
        
        color = cm.nipy_spectral(level/7.)
        ax.plot([idx[0]  , idx[0]+d], [idx[1]  , idx[1]  ], lw=1, color=color, alpha=1)
        ax.plot([idx[0]  , idx[0]  ], [idx[1]  , idx[1]+d], lw=1, color=color, alpha=1)
        ax.plot([idx[0]+d, idx[0]+d], [idx[1]  , idx[1]+d], lw=1, color=color, alpha=1)
        ax.plot([idx[0]  , idx[0]+d], [idx[1]+d, idx[1]+d], lw=1, color=color, alpha=1)
        return count
    
    def plot_rec(ax, pos, Lmax, level, idx):
        count = cube_plot(ax, pos, level, idx)
        if level +1 == Lmax:
            return
        if count > 1:
            plot_rec(ax, pos, Lmax, level+1, [idx[0]*2, idx[1]*2])
            plot_rec(ax, pos, Lmax, level+1, [idx[0]*2+1, idx[1]*2])
            plot_rec(ax, pos, Lmax, level+1, [idx[0]*2, idx[1]*2+1])
            plot_rec(ax, pos, Lmax, level+1, [idx[0]*2+1, idx[1]*2+1])
    
    n = 48
    np.random.seed(123)
    
    pos = np.random.rand(n, 2)
    
    for Lmax in range(1, 7):
        fig = plt.figure( figsize=(3, 3) )
        plt.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95)
        ax = fig.add_subplot(111, aspect=1)
        ax.set_xlim([0, 1])
        ax.set_ylim([0, 1])
        plt.tick_params(axis='x',which='both',bottom=False,top=False,labelbottom=False)
        plt.tick_params(axis='y',which='both',left=False,right=False,labelleft=False)
    
        ax.scatter(pos[:,0], pos[:,1], c="indianred", s=5)
        plot_rec(ax, pos, Lmax, 0, [0,0])
    
        plt.savefig("bh{}.png".format(Lmax))
        plt.close()
    

    ライセンス

    この作品の著作権者である私は、この作品を以下のライセンスで提供します。
    w:ja:クリエイティブ・コモンズ
    表示
    このファイルはクリエイティブ・コモンズ 表示 4.0 国際ライセンスのもとに利用を許諾されています。
    あなたは以下の条件に従う場合に限り、自由に
    • 共有 – 本作品を複製、頒布、展示、実演できます。
    • 再構成 – 二次的著作物を作成できます。
    あなたの従うべき条件は以下の通りです。
    • 表示 – あなたは適切なクレジットを表示し、ライセンスへのリンクを提供し、変更があったらその旨を示さなければなりません。これらは合理的であればどのような方法で行っても構いませんが、許諾者があなたやあなたの利用行為を支持していると示唆するような方法は除きます。

    キャプション

    このファイルの内容を1行で記述してください
    An animation of Barnes-Hut tree construction

    このファイルに描写されている項目

    題材

    24 5 2020

    748135a3e9240c4439a15672acf9e8f9060cc025

    9,652 バイト

    300 ピクセル

    300 ピクセル

    ファイルの履歴

    過去の版のファイルを表示するには、その版の日時をクリックしてください。

    日時サムネイル寸法利用者コメント
    現在の版2020年5月25日 (月) 14:212020年5月25日 (月) 14:21時点における版のサムネイル300 × 300 (9キロバイト)wikimediacommons>Osanshouoshrink to 300px

    このファイルを使用しているページはありません。