Equidistant points through a cube

I need to initialize some three-dimensional points, and I want them to be evenly distributed throughout the cube. Are there any creative ways to do this?

I use an iterative algorithm to maximize expectations, and I want my initial vectors to evenly distribute the space.

For example, suppose I have eight points that I want to place equally in a 1x1x1 cube. I would like to get points in the corners of a cube with a side length of 0.333 centered in a larger cube.

Below is an example of 2D. Note that the red dots are equidistant from each other and the edge. I want the same for 3D.

Equidistant points

In cases where the number of points does not have an integer cubic root, I am fine, leaving some โ€œspacesโ€ in the layout.

Currently, I take the root of the cube from the number of points and use it to calculate the number of points and the desired distance between them. Then I iterate over the points and increase the coordinates of X, Y and Z (in a checkerboard pattern so that Y does not increase until X returns to 0, which is the same for Z given Y).

If MATLAB has an easy way to do this, I would love to use it.

+4
source share
5 answers

You will need to define the problem in more detail for cases where the number of points is not an ideal cube. Hovever, for cases where the number of points is a cube, you can use:

l=linspace(0,1,n+2); x=l(2:n+1); y=x; z=x; [X, Y, Z] = meshgrid(x, y, z); 

Then, for each position in the matrices, the coordinates of this point are set by the corresponding elements X, Y and Z. If you want the points listed in one matrix, such that each row is a point, with three columns for the coordinates x, y and z, you can say:

 points(:,1) = reshape(X, [], 1); points(:,2) = reshape(Y, [], 1); points(:,3) = reshape(Z, [], 1); 

Now you have a list of points n^3 on the grid in the entire unit cube, excluding the borders. Like others, you can probably accidentally delete some points if you want less points. This would be easy to do using randi([0 n^3], a, 1) to generate the indices a deleted points. (Remember to check for duplicates in the matrix returned by randi() , otherwise you cannot remove enough points.)

+3
source

The sampling strategy that you propose is known as the Sukharev grid, which is the optimal low dispersion sampling strategy, http://planning.cs.uiuc.edu/node204.html . In cases where the number of samples is not equal to n ^ 3, the choice of which indicates lowering from the grid, it does not matter from the point of view of the sample.

In practice, you can use low-frequency (quasi-random) sampling methods to achieve very good results in three dimensions, http://planning.cs.uiuc.edu/node210.html . You might want to look at the Halton and Hammersley sequences.

+5
source

This is due to the scope of packaging .

+1
source

Select points randomly in the cube, and then calculate the vectors for the nearest neighbor or wall. Then we expand the end points of the smallest vector with an exponentially decaying step size. If you do iteratively, the points should converge to the optimal solution. This even works if the number of points is not cubic.

0
source

A good random generator may be the first usable first approximation. possibly with a later filter to re-position (again randomly) the worst offenders.

-1
source

All Articles