具有形成一个圆点阵列如何随机一个坐标?阵列、坐标、圆点

2023-09-08 10:52:33 作者:子屿.

我们有一个数组或点(双的X,Y,Z),他们围成一个圆圈,从默认的旋转角度出发XA,雅,杂志。我们希望由一个轴(比如Z)上的一些随机变量来扩展我们的圈子每个点。如何做这样的事情在伪code?

We have an array or points (double's X, Y, Z) they form a circle, starting from default rotation angles Xa, Ya, Za. We want to extend each point in our circle by one axes (say Z) on some random variable. How to do such thing in pseudocode?

推荐答案

你的意思是这样的(伪code):

Do you mean something like this (pseudocode):

void randomize(Point[] points, Axis axis, double scale) {
    RandomNumberGenerator rng = new RandomNumberGenerator();
    for (Point point : points) {
        point[axis] += scale * rng.nextRandom();
    }
}

如果你需要置换点一带的一些方向,是不是一个轴,你会修改上面的计算位移矢量组件和每个组件添加到相应的点坐标。

If you need to displace points along some direction that is not an axis, you'd modify the above to compute the displacement vector components and add each component to the corresponding point coordinate.