function draw_sphere(Electron_NEW_BS,N,r)
r= r*10;
r = Electron_NEW_BS(1).R;
j = 1;
% r =  300;
N = N;

Lsphere = length(Electron_NEW_BS)-1;

L1 = 20;
N1 = randi(Lsphere,[N,1]);


%% 2D plot
figure;
viscircles([0,0],r); hold on;
for i = 1:N
L2 = length(Electron_NEW_BS(N1(i)).X);
N2 = randi(L2,1);
ind = Electron_NEW_BS(N1(i)).IndexDraw(N2,1)-1;
plot([Electron_NEW_BS(N1(i)).Xn(N2,1),  Electron_NEW_BS(N1(i)).X(N2,1:ind)],   [Electron_NEW_BS(N1(i)).Zn(N2,1),Electron_NEW_BS(N1(i)).Zcalc(N2,1:ind)],'b-*')
plot([Electron_NEW_BS(N1(i)).Xn(N2,1),  Electron_NEW_BS(N1(i)).Xn(N2,1)],   [r+round(r/3),Electron_NEW_BS(N1(i)).Zn(N2,1)],'b--')

end
xlim([-2*r,2*r]);
ylim([-2*r,2*r]);
hold off
title('MC-Sphere')


%% 3D plot
a = [0,0,0,r];
figure
for i = 1:N
    j = randi(length(Electron_NEW_BS)-1);
ind =  Electron_NEW_BS(j).IndexDraw(i,1)-1;
X = Electron_NEW_BS(j).X(i,1:ind);
Y = Electron_NEW_BS(j).Y(i,1:ind);
Z = Electron_NEW_BS(j).Zcalc(i,1:ind);
Xn = Electron_NEW_BS(j).Xn(i,1);
Yn = Electron_NEW_BS(j).Yn(i,1);
Zn = Electron_NEW_BS(j).Zn(i,1);
[x,y,z]=sphere;


% s1=surf(x*a(1,4)+a(1,1),y*a(1,4)+a(1,2),z*a(1,4)+a(1,3));
% set(s1, 'FaceAlpha', 0.5);

m1=mesh(x*a(1,4)+a(1,1),y*a(1,4)+a(1,2),z*a(1,4)+a(1,3));
set(m1, 'FaceAlpha', 0.2);
hold on
% plot3([0,X(3)],[0,Y(3)],[0,Z(3)],'r-*')
plot3([Xn X],[Yn Y],[Zn Z],'k-+')
plot3([Xn Xn],[Yn Yn],[r+round(r/3) Zn],'k--')
xlim([-2*r,2*r])
ylim([-2*r,2*r])
zlim([-2*r,2*r])
end
xlabel('X');ylabel('Y');zlabel('Z');