% VOLLEY

% Ce script nécessite les fonctions: bonhomme, filet, sol, sphere3, traj, tube, tubed et tubeg

clear
close all
text(0.5,0.5,'Veuillez patienter...','HorizontalAlignment','center','FontSize',20)
axis off
drawnow

fondv = sol(-10*10,10*10,-5*10,5*10,0,0,0);
hold on

ligneex = sol(-9*10,9*10,-4.5*10,4.5*10,0,0,0.01);
intd = sol(2,28,-4.3*10,4.3*10,0,0,0.2);
integ = sol(-8.8*10,-3*10,-4.3*10,4.3*10,0,0,0.02*10);
inted = sol(3*10,8.8*10,-4.3*10,4.3*10,0,0,0.02*10);
intig = sol(-2.8*10,0.0,-4.3*10,4.3*10,0,0,0.02*10);
intid = sol(0.2*10,2.8,-4.3*10,4.3*10,0,0,0.02*10);

poteaud = tubed(0.2*10,0*10,-5*10,0*10,2,20);
poteauD = tubeg(0.2*10,0*10,-5*10,0,2,20);

poteaug = tubed(0.2*10,0*10,+5*10,0*10,2,20);
poteauG = tubeg(0.2*10,0*10,+5*10,0*10,2,20);

fillet = fillet(0*10,.1*10,-5*10,5*10,0*10,0*10,1*10);

hpoteaug = sphere3(0.2*10,0*10,5*10,3*10);
hpoteaud = sphere3(0.2*10,0*10,-5*10,3*10);

j1 = bonhomme(8,40,18);
rotate(j1,[0 0 -1],90,[8 40 18])
j2 = bonhomme(8,0,18);
rotate(j2,[0 0 -1],90,[8 0 18])
j3 = bonhomme(8,-30,18);
rotate(j3,[0 0 -1],90,[8 -30 18])
j4 = bonhomme(70,30,18);
rotate(j4,[0 0 -1],90,[70 30 18])
j5 = bonhomme(70,0,18);
rotate(j5,[0 0 -1],90,[70 0 18])
j6 = bonhomme(70,-30,18);
rotate(j6,[0 0 -1],90,[70 -30 18])

j7 = bonhomme(-8,30,18);
rotate(j7,[0 0 1],90,[-8 30 18])
j8 = bonhomme(-8,0,18);
rotate(j8,[0 0 1],90,[-8 0 18])
j9 = bonhomme(-8,-40,18);
rotate(j9,[0 0 1],90,[-8 -40 18])
j10 = bonhomme(-70,-30,18);
rotate(j10,[0 0 1],90,[-70 -30 18])
j11 = bonhomme(-70,0,18);
rotate(j11,[0 0 1],90,[-70 0 18])
j12 = bonhomme(-70,30,18);
rotate(j12,[0 0 1],90,[-70 30 18])

balle = sphere3(2.5,-90,1,2);


colormap white;
c1=colormap;
colormap autumn;
c2=colormap;
colormap spring;
c3=colormap;
colormap gray;
c4=colormap;
c5=[0:63;zeros(2,64)]'/63; %rouge
c6=[0:63;zeros(2,64)]'/100000; %noir
caxis([0 6]);
cperso=[c1;c2;c3;c4;c5;c6];
colormap(cperso);


c = get(fondv,'Cdata');
set(fondv,'Cdata',c+1);
c = get(ligneex,'Cdata');
set(ligneex,'Cdata',c);
c = get(integ,'Cdata');
set(integ,'Cdata',c+3);
c = get(inted,'Cdata');
set(inted,'Cdata',c+3);
c = get(intig,'Cdata');
set(intig,'Cdata',c+3);
c = get(intid,'Cdata');
set(intid,'Cdata',c+3);
c = get(intd,'Cdata');
set(intd,'Cdata',c+3);
c = get(poteaud,'Cdata');
set(poteaud,'Cdata',c+4);
c = get(poteauD,'Cdata');
set(poteauD,'Cdata',c+4);
c = get(poteaug,'Cdata');
set(poteaug,'Cdata',c+4);
c = get(poteauG,'Cdata');
set(poteauG,'Cdata',c+4);
c = get(hpoteaug,'Cdata');
set(hpoteaug,'Cdata',c+4);
c = get(hpoteaud,'Cdata');
set(hpoteaud,'Cdata',c+4);

c=get(balle,'Cdata');
set(balle,'Cdata',c+1);

axis image
axis off
shading interp

[xb,yb,zb]=traj([-50 -5 60],[2 50 12]);
xballe = get(balle,'XData');
yballe = get(balle,'YData');
zballe = get(balle,'ZData');
n=length(xb)-1;

for i = 2:length(xb)
    set(balle,'XData',xballe-xb(1)+xb(i),'YData',yballe-yb(1)+yb(i),'ZData',zballe-zb(1)+zb(i));
    drawnow
end