具有形成一个圆点阵列如何随机一个坐标? [英] Having an array of points that form a circle how to randomize one coordinate?

查看:134
本文介绍了具有形成一个圆点阵列如何随机一个坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个数组或点(双的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.

这篇关于具有形成一个圆点阵列如何随机一个坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆