Question: Animation of Garage door opening

Am trying to create a gif file of  a cantilevered door opening with the aid of a coil spring.  The program is given below in text format.  At the end is a for/do loop which gives a series of pictures of the side view of the door opening.  I'd like to animate these and be able to create a gif file. The use of animate seems to require a function F(x,t) of two variables - one being time. My calculations do not involve time.  Any help gratefully received.

 

restart;
> with(plots): with(plottools):
> #Problems:
> #gif file???  Use of animate
> # - - - - - - -
> printlevel:=0:
> #h=doorheight;  h1=dist from floor to pivot point; base=dist of cantilever #connection to end of garage door
> h:=206:h1:=115:
> doorheight:=h:
> base:=24:
> #Spring data
> sbase:=0.4*base:  #sbase is height of base of spring connection point
> #Lower & upper proportions of spring length as ratio of spring length
> propn1:=0.2: propn2:=0.95:  #propn2 > propn1
> #alpha is inclination angle of coils in the spring
> alpha:=Pi/6:
> #nc is Number of Coils in Spring
> nc:=24:   #92 in my actual spring
> #Garage door (closed position lightly shown)
> gdupright:=line([0,0],[0,h], linestyle=2, color=grey):
> #cr is Cantilever Radius
> cr:=h1-base:
> #Counter-balance extension length is cr_ext
> cr_ext:=12:  # 62
> doorwidth:=0.05*h:
> guidewidth:=doorwidth*1.015:
> #macro(skyblue = COLOR(RGB, 0.1960, 0.6000, 0.8000));
> macro(palegreen=COLOR(RGB, .5607, .7372, .5607)):
> #g1 (top) & g2 are guides for door support
> #g_ext is guide extension proportion of guides above the door
> g_ext:=0:  
> g1:=line([-doorwidth/2,doorheight*(1+g_ext)+guidewidth],[doorheight*(1+g_ext),doorheight*(1+g_ext)+guidewidth], color=palegreen):
> g2:=line([-doorwidth/2,doorheight*(1+g_ext)],[doorheight*(1+g_ext),doorheight*(1+g_ext)], color=palegreen):
> garagefloor:=line([-h*.65,0],[doorheight,0], color=black):
> rooflevel:=line([-h*.65,(1.05+g_ext)*h+guidewidth],[doorheight,(1.05+g_ext)*h+guidewidth], linestyle=2,color=grey):
> #Pivot point - pivpoint
> pivp_x:=0.019*h:   #doorwidth:
> #printf("pivp_x= %8.2f doorwidth= %7.1f\n",pivp_x,doorwidth):
> pivpoint:=circle([pivp_x,h1],doorwidth/2, color=red): #doorwidth/2 for radius - #use cr to check
> #mpp is mid point of rotation
> mpp := point([pivp_x,h1], color=black):
> #connect_point[j]:=circle([pivp_x+cr_ext*sin(theta),h1+cr_ext*sin(theta)],doorwidth/2, color=red):
> lastj:=4:    #Number of angle diplays -1 (for 0)
> #printf("Rotation Angle of cantilever (degrees) & distance along the guide arm (cm)  hc   kc"):
> # - - - - - - - - - - - - - -
>
> for j from 0 to lastj do
>
> theta:=j*Pi/lastj:
> # hc was changed from cr*sin(theta)
> hc:=pivp_x-cr*sin(theta):kc:=h1-cr*cos(theta):
> x:=pivp_x-cr*sin(theta)+sqrt((h-base)^2-(h-kc)^2):
> #printf("%8.2f %7.1f    %5.2f   %5.2f\n",theta*180/Pi,x,hc,kc);
> if j=lastj then phi:=Pi/2:
>  else
> phi:=arctan((cr*sin(theta)+x-pivp_x)/(cr*(1+cos(theta))));
> end if:
> #Sides of door, starting at NW corner & going anti-clockwise
> door1 := line([x-doorwidth*cos(phi),h+doorwidth*sin(phi)],[x,h] , color=black):
> door2 := line([x,h],[x-h*sin(phi),h-h*cos(phi)] , color=black):
> door3 := line([x-h*sin(phi),h-h*cos(phi)],[x-h*sin(phi)-doorwidth*cos(phi),h-h*cos(phi)+doorwidth*sin(phi)], color=black):
> door4 := line([x-h*sin(phi)-doorwidth*cos(phi),h-h*cos(phi)+doorwidth*sin(phi)],[x-doorwidth*cos(phi),h+doorwidth*sin(phi)], color=black):
> #Counter balance arm
> cba:=line([x-(h-base)*sin(phi),h-(h-base)*cos(phi)],[pivp_x+cr_ext*sin(theta),h1+cr_ext*cos(theta)],color=blue):
> #Spring calcs # ???
> spring:=line([pivp_x,sbase],[pivp_x+cr_ext*sin(theta),h1+cr_ext*cos(theta)], linestyle=2, color=grey):
> #Turnbuckle
> tbuck1:=line([pivp_x,sbase],[pivp_x+cr_ext*propn1*sin(theta),sbase+propn1*(h1-sbase+cr_ext*cos(theta))], color=black):
> #for tbuck2 see below - it requires angle chi
> chi:=arctan(cr_ext*sin(theta)/(h1-sbase+cr_ext*cos(theta))):
> tbuck2:=arc([pivp_x,sbase],doorwidth/6,Pi/2-chi..3*Pi/2+.2, color=blue):
> #sl is spring length (l is the letter L lower case)
> sl:=sqrt(cr_ext^2+(h1-sbase)*((h1-sbase)+2*cr_ext*cos(theta))):
> for i from 0 to nc do
> x1[i]:=pivp_x+(propn1+(propn2-propn1)*i/nc)*sl*sin(chi):
> y1[i]:=sbase+(propn1+(propn2-propn1)*i/nc)*sl*cos(chi):
> connect_point:=circle([pivp_x+cr_ext*sin(theta),h1+cr_ext*cos(theta)],doorwidth/4, color=blue):
> printlevel:=1:
> #printf("x[%g] = %8.2f  y[%g] = %8.2f theta = %8.2f chi = %8.2f\n", i,x[i],i,y[i],theta*180/Pi,chi*180/Pi);
> #####---PRINT STATEMENT  (NB 2 #)
> #printf("i=%g x = %4.2f  y = %5.2f theta = %6.3f chi = %7.3f  Sp len=%5.3f\n",
> #i, x1[i],y1[i],theta*180/Pi,chi*180/Pi,sl);
>
> s_coil[i]:=line([x1[i]-doorwidth/2,y1[i]-doorwidth/2*tan(alpha-chi)], [x1[i]+doorwidth/2,y1[i]+doorwidth/2*tan(alpha-chi)], color=blue):
> end do:
> #Coords of end of spring (& counter-balance arm) are #[pivp_x+cr_ext*sin(theta),h1+cr_ext*cos(theta)]
> #Line from top of spring to kicker bolt
>
> #connectline[j]:=line([pivp_x+cr_ext*sin(theta),h1+cr_ext*cos(theta)], #[x1[nc]+doorwidth/2,y1[nc]+doorwidth/2*tan(alpha-chi)], color=green):
>
> printlevel:=-1:
> frame[j]:=plots[display](door1,door2,door3,door4,garagefloor,rooflevel,g1,g2,gdupright,pivpoint,cba,mpp,connect_point,seq(s_coil[i],i=0..nc), tbuck1,tbuck2, scaling=constrained, axes=none):
> end do;
> # - - - - - - - - - - - - - -
> printlevel:=1:
> for j from 0 to lastj do
> frame[j];
> end do;
> # - - - - - - - - -
> animate( frame[j],j=0..lastj,t=1..2,frames=50);

Please Wait...