Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们有一个数组或点(双精度的 X、Y、Z)它们形成一个圆,从默认的旋转角度 Xa、Ya、Za 开始。我们想在某个随机变量上将圆中的每个点扩展一个轴(比如 Z)。如何在伪代码中做这样的事情?
你的意思是这样的(伪代码):
void randomize(Point[] points, Axis axis, double scale) { RandomNumberGenerator rng = new RandomNumberGenerator(); for (Point point : points) { point[axis] += scale * rng.nextRandom(); } }
如果您需要沿某个不是轴的方向移动点,您可以修改上面的内容以计算位移矢量分量并将每个分量添加到相应的点坐标。