在3D空间中的一个点周围均匀排列X数量的东西 [英] Arrange X amount of things evenly around a point in 3d space

查看:157
本文介绍了在3D空间中的一个点周围均匀排列X数量的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有X数量的东西(让我们随便说300)

有没有一种算法可以将这些东西均匀地排列在一个中心点周围?就像一个100面的骰子或一个球体的3d网格?



://i.stack.imgur.com/iFzbw.jpgrel =nofollow noreferrer>



而不是这种极地的方式..





ps。对于那些感兴趣的人,想知道为什么我想要这样做?
嗯,为了好玩,我正在这些,并且在完成#7之后,我决定我想在Unity中代表3d中的导线阵列,并观察它们以减慢的方式操作。 解决方案

这是一个简单的转换,将矩形 [0,2 pi] x [-1,1] 中的统一样本映射到半径 r
$ b $ pre $ T(phi,z)=(r cos(phi)sqrt(1 - z ^ 2),r sin(phi)sqrt(1 - z2),rz)

变换在球体上产生均匀的样本是通过变换区域 U 获得的任何区域 T(U)从矩形不取决于 U ,但在 U 区域。



为了证明这个数学证明,证明矢量积的标准就足够了。 ∂T/∂phix∂T/∂z|

是常量(球体上的面积是该向量积的积分wrt phi z )。



总结



为了生成均匀分布在半径 r 范围内的随机样本,请执行以下操作:


  • 产生一个均匀分布在(phi_1,...,phi_n) >生成一个随机样本(z_1,...,z_n)
  • code>均匀分布于 [ - 1,1]


  • code>(phi_j,z_k)使用上面的公式计算 T(phi_j,z_k)



If I have X amount of things (lets just randomly say 300)

Is there an algorithm that will arrange these things somewhat evenly around a central point? Like a 100 sided dice or a 3d mesh of a sphere?

Id rather have the things somewhat evenly spaced like this..

Rather than this polar way..

ps. For those interested, wondering why do I want to do this? Well I'm doing these for fun, and after completing #7 I decided I'd like to represent the array of wires in 3d in Unity and watch them operate in a slowed down manner.

解决方案

Here is a simple transformation that maps a uniform sample in the rectangle [0, 2 pi] x [-1, 1] onto a uniform sample on the sphere of radius r:

T(phi, z) = (r cos(phi) sqrt(1 - z^2), r sin(phi) sqrt(1 - zˆ2), r z)

The reason why this transformation produces uniform samples on the sphere is that the area of any region T(U) obtained by transforming the region U from the rectangle does not depend on U but on the area of U.

To prove this mathematically it is enough to verify that the norm of the vectorial product

| ∂T/∂phi x ∂T/∂z |

is constant (the area on the sphere is the integral of this vectorial product w.r.t. phi and z).

Summarizing

To produce a random sample uniformly distributed in the Sphere of radius r do the following:

  • Produce a random sample (phi_1, ..., phi_n) uniformly distributed in [0, 2 pi].
  • Produce a random sample (z_1, ..., z_n) uniformly distributed in [-1, 1].

  • For every pair (phi_j, z_k) calculate T(phi_j, z_k) using the formula above.

这篇关于在3D空间中的一个点周围均匀排列X数量的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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