Having an array of points that form a circle how t

2019-08-18 17:30发布

问题:

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:

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.