How to pick well known points on a sphere ?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello, Here I am again, I implemented this code acording to an algorithm presented in this article so normally it is like this :
function [ x,y,z ] = RegularPlacement( R,N )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
Ncpt = 0;
a = 4*pi*R*R/N ;
d = sqrt(a);
Mv = round(pi/d);
dv = pi/Mv;
dphi = a/dv;
for m = 0 : Mv-1
v = pi*(m+0.5)/Mv;
Mphi = round(2*pi*sin(v)/dphi);
for n = 0 : Mphi-1
phi = 2*pi*n/Mphi;
i = n+1;
x(i) = R*sin(v)*cos(phi);
y(i) = R*sin(v)*sin(phi);
z(i) = R*cos(v);
Ncpt = Ncpt +1;
end
end
end
So I get 3 arrays, and my objectif is to pick those points on a sphere.
I am sorry I m not used with matlab and I really found a difficulties to understand how should it works. waht I tried is like this :
[ x,y,z ] = RegularPlacement( 1,300 )
m = [x;y;z]
m = bsxfun(@rdivide,m,sqrt(sum(m.^2,1)));
plot3(m(1,:),m(2,:),m(3,:),'.');
axis equal;
But it doen't give me what I am seeking about.
0 件のコメント
採用された回答
Roger Stafford
2016 年 6 月 20 日
The problem is with the line “i = n+1” in your function. It is located inside the inner loop whose index is n. This means that it repeats the values of i for each trip through the outer loop, and all you get are about 31 values, since most of values have been overwritten.
Instead of that line you should put i = 0 before you enter either loop. Then inside you should have i = i+1. That way you will get all the values of x, y, and z that are generated in the two loops.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!