rectangleDepart = matrix(RR, [[13,13,17,17],[48,52,52,48],[1,1,1,1]])
rectangleDepart2 = matrix(RR, [[13,13,17,17],[25,29,29,25],[1,1,1,1]])
rectangleDepart3 = matrix(RR, [[0,0,4,4],[25,29,29,25],[1,1,1,1]])
LDepart = matrix(RR, [[13,17,17,15,15,13],[54,54,52,52,48,48],[1,1,1,1,1,1]])
LDepart2 = matrix(RR, [[13,17,17,15,15,13],[31,31,29,29,25,25],[1,1,1,1,1,1]])
LDepart3 = matrix(RR, [[13,17,17,15,15,13],[27,27,33,33,29,29],[1,1,1,1,1,1]])
LDepart4 = matrix(RR, [[13,17,17,15,15,13],[2,2,8,8,4,4],[1,1,1,1,1,1]])
TDepart = matrix(RR, [[13,15,15,17,17,19,19,13],[50,50,48,48,50,50,52,52],[1,1,1,1,1,1,1,1]])
TDepart2 = matrix(RR, [[13,15,15,17,17,19,19,13],[27,27,25,25,27,27,29,29],[1,1,1,1,1,1,1,1]])
TDepart3 = matrix(RR, [[15,15,17,17,15,15,13,13],[27,25,25,31,31,29,29,27],[1,1,1,1,1,1,1,1]])
TDepart4 = matrix(RR, [[4,4,6,6,4,4,2,2],[27,25,25,31,31,29,29,27],[1,1,1,1,1,1,1,1]])
ZDepart = matrix(RR, [[13,13,15,15,17,17,15,15],[48,52,52,54,54,50,50,48],[1,1,1,1,1,1,1,1]])
ZDepart2 = matrix(RR, [[13,13,15,15,17,17,15,15],[25,29,29,31,31,27,27,25],[1,1,1,1,1,1,1,1]])
ZDepart3 = matrix(RR, [[13,13,15,15,17,17,15,15],[2,6,6,8,8,4,4,2],[1,1,1,1,1,1,1,1]])
IDepart = matrix (RR, [[13,15,15,13],[48,48,56,56],[1,1,1,1]])
IDepart2 = matrix(RR, [[13,15,15,13],[25,25,33,33],[1,1,1,1]])
IDepart3 = matrix(RR, [[10,18,18,10],[28,28,30,30],[1,1,1,1]])
NonLDepart = matrix(RR, [[13,17,17,15,15,13],[54,54,48,48,52,52],[1,1,1,1,1,1]])
NonLDepart2 = matrix(RR, [[13,17,17,15,15,13],[31,31,25,25,29,29],[1,1,1,1,1,1]])
NonLDepart3 = matrix(RR, [[13,15,15,19,19,13],[25,25,27,27,29,29],[1,1,1,1,1,1]])
contourBas = matrix(RR, [[0,0,24,24],[0,2,2,0],[1,1,1,1]])
erase = matrix(RR, [[0,0,24,24],[2,4,4,2],[1,1,1,1]])
erase2 = matrix(RR, [[0,0,24,24],[4,6,6,4],[1,1,1,1]])
Frame = 10
t = (pi)/Frame
t2 = ((-pi)/2)/Frame
t3 = ((pi)/2)/Frame
centreRotationL=matrix (RR, [[15, 29,1]])
centreRotationT=matrix (RR, [[16, 28,1]])
centreRotationI=matrix (RR, [[14, 29,1]])
centreRotationNonL=matrix (RR, [[15, 29,1]])
VecteurMvtCarreJaune1 = vector([0/Frame,-23/Frame,1])
VecteurMvtCarreJaune2 = vector([-13/Frame,0/Frame,1])
VecteurMvtLpt2 = vector([0/Frame,-25/Frame,1])
VecteurMvtLpt3 = vector([-9/Frame,0/Frame,1])
VecteurMvtT= vector([-11/Frame,0/Frame, 1])
VecteurMvtTDesc = vector([0/Frame, -21/Frame,1])
VecteurInverse = vector([-5/Frame,0,1])
VecteurMvtLpt4 = vector([-3/Frame,0/Frame,1])
VecteurI = vector([6/Frame,-26/Frame,1])
VecteurNonL= vector([1/Frame, -23/Frame,1])
VecteurNul = vector([0,0,1])
def TranslationLineaire(VecteurTranslation,polygone):
M = matrix([[1,0,VecteurTranslation[0]],[0,1,VecteurTranslation[1]],[0,0,VecteurTranslation[2]]]
return M * polygone
def Rotation(t,centreRotationx,centreRotationy):
MCmoins = matrix([[1,0,-centreRotationx],[0,1,-centreRotationy],[0,0,1]])
M = matrix([[cos(t), -sin(t),0],[sin(t),cos(t),0],[0,0,1]])
MCplus = matrix([[1,0,centreRotationx],[0,1,centreRotationy],[0,0,1]])
return MCplus*M*MCmoins
def RotationPolygone(t,centreRotationx,centreRotationy,polygone):
M = Rotation(t,centreRotationx,centreRotationy)
return M*polygone
def Stocker(VecteurTranslation,polygone,color,yMin):
ListFrame= []
polygoneFrame = polygone
ListFrame = ListFrame+[Dessine(polygoneFrame,color, yMin)]
for i in [1..Frame]:
polygoneFrame=TranslationLineaire(VecteurTranslation, polygoneFrame)
ListFrame=ListFrame+[Dessine(polygoneFrame,color,yMin)]
return ListFrame
def StockerRotation(t,VecteurTranslation,centreRotation, polygone,color,yMin):
ListFrame=[]
polygoneFrame = polygone
ListFrame = ListFrame+[Dessine(polygoneFrame,color,yMin)]
for j in [1..Frame]:
polygoneFrame = RotationPolygone(t,centreRotation[0,0],centreRotation[0,1],polygoneFrame)
ListFrame = ListFrame+[Dessine(polygoneFrame,color, yMin)]
return ListFrame
def Dessine(carre, color,yMin):
carreTraceX = [carre[0,j] for j in [0..carre.ncols() -1]]
carreTraceY = [carre[1,j] for j in [0..carre.ncols() -1]]
return polygon(zip(carreTraceX,carreTraceY),fill=true,rgbcolor=color,xmin= -2.5, xmax=24, ymin=yMin, ymax=50, axes=False)
S=Stocker(VecteurNul,contourBas,'black',0)
S=[S[j]+Dessine(contourBas,'black',0) for j in [0..len(S)-1]]
graphe=S[-1]
temp=Stocker(VecteurMvtCarreJaune1, rectangleDepart,'goldenrod',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurMvtCarreJaune2, rectangleDepart2,'goldenrod',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurMvtCarreJaune1, rectangleDepart3,'goldenrod',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
graphe=S[-1]
temp=Stocker(VecteurMvtCarreJaune1, LDepart, 'blue',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=StockerRotation(t,VecteurNul,centreRotationL, LDepart2, 'blue',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurMvtLpt2, LDepart3,'blue',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurMvtLpt3, LDepart4,'blue',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
graphe=S[-1]
temp=Stocker(VecteurMvtCarreJaune1, TDepart,'purple',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=StockerRotation(t2,VecteurNul,centreRotationT, TDepart2, 'purple',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurMvtT,TDepart3, 'purple',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurMvtTDesc,TDepart4, 'purple',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
graphe=S[-1]
temp=Stocker(VecteurMvtCarreJaune1,ZDepart, 'red',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurMvtCarreJaune1,ZDepart2, 'red',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurInverse,ZDepart3, 'red',1)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
graphe=S[-1]
temp=Stocker(VecteurMvtCarreJaune1,LDepart, 'blue',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=StockerRotation(t,VecteurNul,centreRotationL, LDepart2, 'blue',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurMvtLpt2, LDepart3,'blue',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurMvtLpt4, LDepart4,'blue',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
graphe=S[-1]
temp=Stocker(VecteurMvtCarreJaune1, IDepart,'aqua',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=StockerRotation(t2,VecteurNul,centreRotationI, IDepart2, 'aqua',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurI, IDepart3,'aqua',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
graphe=S[-1]
temp=Stocker(VecteurMvtCarreJaune1, NonLDepart,'orangered',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=StockerRotation(t3,VecteurNul,centreRotationNonL, NonLDepart2, 'orangered',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
temp=Stocker(VecteurNonL, NonLDepart3,'orangered',0)
S=S+[temp[j]+graphe for j in [0..len(temp)-1]]
graphe=S[-1]
temp=Stocker(VecteurNul, erase, 'white',0)
S=S+[graphe+temp[j] for j in [0..len(temp)-1]]
graphe=S[-1]
temp=Stocker(VecteurNul, erase, 'black',2)
S=S+[graphe+temp[j] for j in [0..len(temp)-1]]
graphe=S[-1]
temp=Stocker(VecteurNul, contourBas, 'white',2)
S=S+[graphe+temp[j] for j in [0..len(temp)-1]]
animation= animate(S)
animation.show(delay = 10)