Having an array of points that form a circle how t

2019-08-18 17:22发布

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?

1条回答
爷的心禁止访问
2楼-- · 2019-08-18 17:50

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.

查看更多
登录 后发表回答