使用Python中的泊松采样在立方体表面上对3D点(X,Y,Z)进行采样

时间:2017-02-22 08:32:08

标签: python python-3.x 3d sampling

我正在尝试在python中的立方体面上执行泊松采样。

我是python的新手,所以我在平面上发现了泊松采样的这种实现 https://github.com/IHautaI/poisson-disc/blob/master/poisson_disc.py

这就是我提出的:

    import numpy as np
    import random
    nPoints = 100
    r = 1/np.sqrt(nPoints/6)
    length = 1
    width = 1
    grid = Grid(r, length, width)
    rand = (random.uniform(0, length), random.uniform(0, width))
    PointsBottom = np.array([list(elem) for elem in grid.poisson(rand)])
    Pointstop = np.array([list(elem) for elem in grid.poisson(rand)])
    PointsRight = np.array([list(elem) for elem in grid.poisson(rand)])
    PointsLeft = np.array([list(elem) for elem in grid.poisson(rand)])
    PointsFront = np.array([list(elem) for elem in grid.poisson(rand)])
    PointsBack = np.array([list(elem) for elem in grid.poisson(rand)])
    X = np.concatenate([PointsBottom[:, 0], Pointstop[:, 0], PointsLeft[:, 0], PointsRight[:, 0], np.zeros(len(PointsFront[:, 0])), np.ones(len(PointsBack[:, 0]))])
    Y = np.concatenate([PointsBottom[:, 1], Pointstop[:, 1], np.zeros(len(PointsLeft[:, 0])), np.ones(len(PointsRight[:, 0])), PointsFront[:, 0], PointsBack[:, 0]])
    Z = np.concatenate([np.zeros(len(PointsBottom[:, 0])), np.ones(len(Pointstop[:, 0])), PointsLeft[:, 1], PointsRight[:, 1], PointsFront[:, 1], PointsBack[:, 1]])

工作正常。我的问题是 - 是否有更好/更有效的方法来做到这一点?

0 个答案:

没有答案