0001 function satellites = genRandomSatellites( nsats, dist, varargin )
0002 rho = dist;
0003 a = pi/16; b = (7*pi)/16; c = 2*pi;
0004
0005 rand('state',sum(100*clock));
0006 nargs = length(varargin);
0007 if nargs == 0,
0008 phi = a + (b-a).*rand(nsats+1,1);
0009 theta = a + (c-a).*rand(nsats+1,1);
0010 else
0011
0012 phi = a + (b-a).*rand(nsats,1);
0013 theta = a + (c-a).*rand(nsats,1);
0014 for k = 2:nsats+1,
0015 phi(k) = 0.975*phi(1) + (phi(1)*0.05)*rand();
0016 theta(k) = .975*theta(1) + (theta(1)*.05)*rand();
0017 end
0018 phi(1) = phi(nsats+1);
0019 theta(1) = theta(nsats+1);
0020 end
0021
0022 sat = struct( ...
0023 'x', rho*cos(phi(1))*cos(theta(1)), ...
0024 'y', rho*cos(phi(1))*sin(theta(1)), ...
0025 'z', rho*sin(phi(1)), 't', 0 );
0026 for k = 2:nsats,
0027 sat(k).x = rho*cos(phi(k))*cos(theta(k));
0028 sat(k).y = rho*cos(phi(k))*sin(theta(k));
0029 sat(k).z = rho*sin(phi(k));
0030 sat(k).t = 0;
0031 end
0032
0033 satellites = sat;
0034 end