What am I getting wrong with trying to create a sphere mesh using a golden spiral?

8 ビュー (過去 30 日間)
I have included my code, as well as an image that shows the issue. I am trying to create an equally distant number of points across the surface of a sphere. The Fibonacci method I happened upon isn't perfect, but at least I could understand how to get it working at all in Matlab. A better method would be great, but I would like to get this working first.
However, as you can see, the code I am using doesn't create an equal number of points. For some reason, there is a line of holes at longitude 0 where there are no points. Why does this happen? I changed it a bit so it starts at 0 rather than at 1, but that didn't help much.
  2 件のコメント
John D'Errico
John D'Errico 2020 年 7 月 8 日
編集済み: John D'Errico 2020 年 7 月 8 日
What did you base the code upon? Why do you think it should produce equidistant points on the sphere? The image you show does not appear to be remotely uniform so if that is your goal - a uniform mesh on the sphere, then why not look for something better? Anyway, the result is just a scattered set, a point cloud, so not a mesh at all.
Is all you are looking to do, something like this?
So, at least a moderately uniform tiling on a sphere? The example I show is not that terribly uniform, but it is not too bad either.
This?
Or is it really a quasi-uniform sampling of the sphere, and you are not interested in a tiling thereof?
What are you looking to do? What is the goal here?
Isaac Haeffner
Isaac Haeffner 2020 年 7 月 8 日
What I would like is a large, variable number of points on the sphere that are all as equidistant as possible. I need them to be exported to a txt file in two columns.
Everything else I found was in a different language and I couldn't understand the methods that were being used in order to convert them.
This is what I was basing it on: http://blog.marmakoide.org/?p=1

サインインしてコメントする。

採用された回答

John D'Errico
John D'Errico 2020 年 7 月 8 日
編集済み: John D'Errico 2020 年 7 月 8 日
So you are not looking for a mesh at all, just a uniform sampling? Simplest might be to use a random sampling, with a twist. That is, just discard those points that are most closely spaced.
ntarget = 250; % 250 final points, quasi-maximally distant on the unit sphere.
oversample = 6;
ninit = ntarget*oversample;
xyz = randn(ninit,3);
% rescale all points to lie on the surface of a unit sphere.
% this is appropriate because a muli-variate gaussian is rotationally symmetric.
xyz = xyz./sqrt(sum(xyz.^2,2));
% iteratively reduce the set, by excluding a point if it is too close
% to its neighbors.
nred = 10;
for ind = 1:(ninit-ntarget)/nred
D = pdist(xyz);
[Dmin,I] = mink(D,nred);
n = size(xyz,1);
bins = cumsum([1,(n-1):-1:1]);
ir = discretize(I,bins);
jr = ind - (ir - 1).*(2*n - ir)/2 + ir;
xyz(ir,:) = [];
end
plot3(xyz(:,1),xyz(:,2),xyz(:,3),'.')
The code is a bit of a hack. Probably as soon as I submit this post I'll have a much cleaner version. But it produces points that are reasonably close to as uniformly far apart as possible.
  1 件のコメント
Isaac Haeffner
Isaac Haeffner 2020 年 7 月 8 日
編集済み: Isaac Haeffner 2020 年 7 月 9 日
for i = 1:ntarget
longlat(i,1) = asin(xyz(i,3));
longlat(i,2) = atan2(xyz(i,2),xyz(i,1));
longlat(i,1) = ((rad2deg(longlat(i,1)))+90)*2;
longlat(i,2) = rad2deg(longlat(i,2));
end
That works just as well as what I had. However, when I convert it into longitude and latitude, it is still balanced away from longitude 0.
This is the code I am using to convert it from xyz to longitude/latitude.
Edit: Nevermind, I got it working! Thanks!

サインインしてコメントする。

その他の回答 (0 件)

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by