- Increase radius:
- Number of points on radius:
how to generate a circel which filed with regular points?
3 次查看(过去 30 天)
显示 更早的评论
Hi all,
I want to generate a circel which filled with regular points say 1000 points inside the circel. The point to another will be constant. How can I generate this? Thanks in advance.
0 个评论
采纳的回答
更多回答(1 个)
Walter Roberson
2020-1-9
The distance from one particles to another will be constant.
In order to get that, you need to construct a hexagon packing in a circle: https://math.stackexchange.com/questions/1283085/hexagon-packing-in-a-circle and put the particles at the vertices. That will put each point at the same distance relative to the three closest points around it (except at the edge.) This is the densest possible packing.
Perhaps for your purposes it would be good enough to construct a square mesh.
Do not place the points randomly: you will not be able to satisfy the rule that the distance from one particle to another is constant.
6 个评论
Walter Roberson
2020-1-13
You could use the Parallel Processing Toolbox to compute the points along different radii in parallel, and then bring the computed points all back together into the main thread for plotting. However this is very likely to be slower than doing it all in one thread.
Walter Roberson
2020-1-13
The algorithm that I described earlier for placing the points has a flaw: it does not place the points at constant radial distance apart from each other as you required. Placing an integer number of points at constant distance along circles can only be done at very carefully selected radii, except that the task is made easier if the constant distance is a simple fraction of Pi.
The algorithm I described earlier does not use constant distance: at each radius it modifies the constant distance slightly to get the closest approximation of the distance that permits an exact integer number of points to be placed.
The number of points that are appropriate for each radius will differ, and the appropriate number would be the same for two radii only if the two radii differ by less than 1/(2*pi) approximately.
The calculation of linspace(0,2*pi,N+1) is difficult to vectorize for multiple N values.
It would be possible to use the same N value for multiple radii even though they "should" have different N values, but if you do so then you have the problem that the "constant distance" requirement gets more and more violated.
What might be worth doing is calculating all of the points for each radii in a loop, storing the results in a cell array, then cell2mat() to create a single list of x and single list of y coordinates, and scatter() with that -- thus reducing down to a single scatter object instead of one per radius.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!