如何生成指向方向各向同性的随机方向的单位矢量? [英] How to generate a unit vector pointing in a random direction with isotropic distribution of direction?
问题描述
我需要创建一种方法来使用随机数生成器生成指向随机方向的三个维度的单位矢量.方向的分布必须是各向同性的.
这是我尝试生成随机单位矢量的方法:
v = randn(1,3);
v = v./sqrt(v*v');
但是我不知道如何完成各向同性的部分.有什么想法吗?
I need to create a method to generate a unit vector in three dimensions that points in a random direction using a random number generator. The distribution of direction MUST be isotropic.
Here is how I am trying to generate a random unit vector:
v = randn(1,3);
v = v./sqrt(v*v');
But I don't know how to complete the isotropic part. Any ideas?
推荐答案
您做对了.随机的 normal 坐标分布为您提供方向的均匀分布.
You're doing it right. A random normal distribution of coordinates gives you a uniform distribution of directions.
要在单位球面上生成10000个均匀点,请运行
To generate 10000 uniform points on the unit sphere, you run
v = randn(10000,3);
v = bsxfun(@rdivide,v,sqrt(sum(v.^2,2)));
plot3(v(:,1),v(:,2),v(:,3),'.')
axis equal
这篇关于如何生成指向方向各向同性的随机方向的单位矢量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!