How to pick well known points on a sphere ?
    2 次查看(过去 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!



