function [mass,xyz,vxyz] = gen_nbody(n)
% GEN_NBODY : Generate dataset for nbody simulation
%
% [mass,xyz,vxyz] = gen_nbody(n);
%
% Output is a three arrays of initial values for n-body simulation.
%    mass : n-by-1 array of masses in kg
%    xyz  : n-by-3 array of positions in m
%    vxyz : n-by-3 array of velocities in m/sec
%
% If input argument n is omitted, generate the 10-body solar system.
%
% John R. Gilbert  18 Jan 2010, last updated 12 Jun 2015

if nargin == 0, [mass,xyz,vxyz] = gen_solar; return; end;
   
% generate n bodies with random masses and positions, zero velocity

mass = 1e30 * rand(n,1);    % masses up to about 1/2 solar mass
dist = .5e13 * rand(n,1);   % coords up to about solar system radius
theta = 2*pi*rand(n,1);     % random directions from origin
xyz = [dist.*cos(theta) dist.*sin(theta) 1e11*(rand(n,1)-.5)]; % flattish disk
vxyz = zeros(n,3);          % initial velocities all zero
