function [x,y,z] = eqdsph(n,tol) % EQDSPH Equilibrium distribution of points on a sphere % [X,Y,Z] = EQDSPH(N) Calculates "equilibrium" % distribution of N points on a unit sphere. % EQDSPH(N,TOL) also can specify the tolerance for % the disbalanve of "forces". % % EQDSPH uses "electron dynamics" method - that is % "solves" kinetic equation for repellent points % moving freely along the sphere until reaching % approximately equilibrium positions. % Copyright (c) 1995 by Kirill K. Pankratov % kirill@plume.mit.edu % 05/10/95 % Defaults and parameters tol_dflt = 1e-3; % Default for tolerance iter_max = 200; l_ch = 20; part = 1/5; a = .6; e = 1e-8; % Substitute for zero if nargin<2, tol = tol_dflt; end % Scale .................. d = sqrt(2*pi/n); tol = tol*sqrt(n); % Auxillary .............. l_ch = min(l_ch,n); n_chunk = ceil(n/l_ch); o_ch = ones(1,l_ch); on = ones(n,1); % Initialization ......... R = randsph(n); x = R(:,1); y = R(:,2); z = R(:,3); % Iterate - solve "charged particles dynamics" equation % until (approximate) equilibrium vx = zeros(size(x)); vy = vx; vz = vx; vmax = 1; iter = 0; while vmax>tol & iter