Arrange X number of things evenly around a point in 3d space

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

Is there an algorithm that will arrange these things somewhat evenly around a center point? Like a 100-sided cube or a 3d mesh sphere?

An identifier rather has things somewhat evenly distributed in this way. enter image description here

Instead of this polar path.

enter image description here

ps. For those who are interested, I wonder why I want to do this? Well, I do these for fun, and after completing # 7, I decided to introduce an array of wires in 3d in Unity and watch them work in slow motion.

+1
source share
2 answers

Here is a three-step approach. 1a) Make more points than you need. 1b) Remove some. 2) Adjust the rest.

1a) To make more points that you need, take any quasiregular polyhedron with sides that tessellate (triangles, squares, diamonds). Tessellate spherical gradients by subsection, creating more vertices. For example, if you use a regular icosahedron, you get geodesic domes. (Dividing by 2, you get a double value for the C 60 buckyball.) Developing exact formulas is not difficult. The number of new vertices per face is quadratic in the partition.

1b) Accidentally remove enough points to reduce you to the target number.

2) Use the force-directed layout algorithm to redistribute vertices over the sphere. The base strength graph is the one provided by the closest neighbors in your base tessellation.

There are other ways to do step 1), for example, just generate random points in any distribution. However, there is an advantage to starting with a quasiregular figure. In some cases, force-oriented algorithms have a reputation for poor convergence. Starting with something that is already basically optimal, you will get past most of all the convergence issues you may have.

0
source

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

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

The reason this transformation gives homogeneous samples on a sphere is because the area of ​​any region T(U) obtained by transforming region U from a rectangle does not depend on U , but on region U

To prove this mathematically, it suffices to verify that the norm of the vector product

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

constant (the area on the sphere is an integral of this vector product wrt phi and z ).

Mixing

To create a random sample evenly distributed in a sphere of radius r , do the following:

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

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

0
source

All Articles