restart: # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # Letters for JEREMY # Similar idea to KEITH - an "English version". # To Do: Letter M has errors: removed entirely and replaced with Carl Love's proc # Could do with more frames - 47 to 49. Done# # Add animation to make the R kick! Done # Put patchnogrid on R. Done # Synchronise the kicking and the ball: at present seperate # events - ball not considered yet. Ball needs to go higher to clear the post. # At present the ball starts in mid air - this was done as a "quick and dirty" # method to make to make the ball clear the bar. # Put second E behind the ball? # # # # # # # # # # # # # # # # # # # # # # # # # # # # # with(plots): with(plottools): #Ball ball:=proc(x0,y0,amaj,amin,istart,iend) local i,opts,elli, ellir, ballplot: opts:=scaling=constrained, axes=none: #Suggested values of parameters #istart:=0:iend:=48: #amaj:=4:amin:=6: for i from istart to iend do elli[i]:=ellipticArc([x0+i,y0+amin+i*(iend-i)/iend^2],amaj*(iend-i)/iend,amin*(iend-i)/iend,0..2*Pi,color=brown,filled=true,opts): ellir[i]:=rotate(elli[i],Pi*(i-istart)/iend,[x0+i,y0+amin+i*(iend-i)/iend^2]); end do: #print(`seq(elli[i] - Rugby ball`); #ballplot:=plots[display](K_stat,seq(ellir[i], i=istart..iend),insequence=true,scaling=constrained): ballplot:=seq(ellir[i],i=istart..iend),insequence=true,opts: plots[display](ballplot); end proc: #print(`ball - animation`); ball_kicked:=ball(24.5,1.9,4,6,-2,25): #Letter J makeJ:=proc(x0,y0,h,base, w ) local opts,a, J1,J2,col,soln, r1,r2,r3,ri,ro,nframes,i,framJ, l1,nframesJ,col2,rec_loop,rec_top,top_rec_anim,loop_rec_anim: col:=`green`:col2:=`white`: ro:=base/2:ri:=ro-w/2: opts:=style=patchnogrid: J1:=ellipticArc([x0+ro,y0+ro],ro,ro,Pi..2*Pi,scaling=constrained,opts, style=patchnogrid): J2:=ellipticArc([x0+ro,y0+ro],ro-w,ro-w,Pi..2*Pi,scaling=constrained,opts, style=patchnogrid): #r1 is rectangle atop lhs of J curve r1:=rectangle([x0,y0+ro+w], [x0+w,y0+ro],color=col2,opts): r2:=rectangle([x0+base-w,y0+h], [x0+base,y0+h-w],color=col2,opts): r3:=rectangle([x0+base-w,y0+h], [x0+base,y0+ro],color=col,opts): l1:=line([x0+base-w, y0+ro],[x0+base,y0+ro], color=col,opts): nframes:=43: for i from 0 to nframes do framJ[i]:= ellipticArc([x0+ro,y0+ro],ro-w+w*(1-(nframes-i)/nframes),ro-w+w*(1-(nframes-i)/nframes),Pi..2*Pi,scaling=constrained, style=patchnogrid,color=col): end do: nframesJ:=48: #96 and J was reversed for i from 0 to nframesJ do rec_loop[i]:=rectangle([x0,y0+ro+4*w*i*(nframesJ-i)/nframes^2], [x0+w,y0+ro], style=patchnogrid,color=col): rec_top[i]:=rectangle([x0+base-w,y0+h], [x0+base,y0+h-4*w*i*(nframesJ-i)/nframes^2],color=col2, style=patchnogrid): end do: loop_rec_anim:=plots[display](seq(rec_loop[i], i=0..nframesJ),insequence=true, style=patchnogrid): top_rec_anim:=plots[display](seq(rec_top[i], i=0..nframesJ),insequence=true): plots[display](l1,r1,r3,r2,loop_rec_anim,seq(framJ[i], i=0..nframes),top_rec_anim,scaling=constrained, style=patchnogrid,color=col); end proc: #J #Letter E framesE:= 48: base:= 9: height:= 12: mid:= 5.5: wid:= 1.5: macro(palegreen=COLOR(RGB, .5607, .7372, .5607)): # macro(darkgrey=COLOR(RGB, .3607, .1372, .6607)): #Not used # # Define three rectangles - all one needs # to construct the letter 'E' # r1:= rectangle( [0, height], [wid, 0] ): r2:= rectangle( [wid, wid], [base-wid, 0]): r3:= rectangle( [wid, height/2+wid/2], [mid-wid, height/2-wid/2]): p_opts:= scaling=constrained, color=palegreen, style=patchnogrid, axes=none: letE:= display( [r1, r2, r3, translate(r2, 0, height-wid)], p_opts): # Produce animation # anim1(letE); # moves l to r # Define another simple animator function - does "there and back" # rotation # nr:=16: #was 8 anim2:= x -> display ( seq ( `if` ( j 'color'= 'COLOR'('RGB', 'evalf[8](rand()/10.^12)' \$ 3): makeM:= proc(x0, y0, h, b, w) local Hm; Hm:= h/3; plots[display]( map( L-> plottools[polygon](map(`+`, L, [x0,y0]), Col2()), [ [[0,0], [0,h], [w,h], [w,0]], [[b/2,Hm], [w,.75*h], [w,h], [b/2,Hm+2*w*(h-Hm)/b]], [[b/2,Hm+2*w*(h-Hm)/b], [b-w,h], [b-w,.75*h], [b/2,Hm]], [[b-w,h], [b,h], [b,0], [b-w,0]] ] ) ) end proc: nframes:=49: #was 47 x0:=32.3: y0:=0: b:=7.8: w:=1.2: M_working:=plots[display]( [seq(makeM(x0, y0, 12-0.37*i*(1-i/nframes), b, w), i= 1..nframes)], scaling= constrained, linestyle= 1, thickness= 0, insequence= true ): # Letter Y makeY:=proc(x0,y0,h,base,w,alfa) local col, depth, lY,uY, opts,Up_leg,Y_left,Y_right, x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6,P1_x, P2_x, P3_x, P1_y, P2_y, P3_y, xM_L, yM_L, xM_R, yM_R, Y_left_Up,Y_left_Lo, nf, t, poly_YL_Up,poly_YL_Lo, pl1, pl2,pl3,Up_leg_static,P4_y: col:=`grey`: opts:=scaling=constrained,style=patchnogrid, axes=none, color=col: lY:=w/sin(alfa): depth:=(base/2-lY)*abs(tan(alfa)); #uY is length of side of upright of Y uY:=h-(base-w)/2*abs(tan(alfa)): #??? #printf("var1=tan(alfa)=%5.3f tana=%5.3f\n",var1, tana); #printf("lY=%5.3f depth=%5.3f depth2=%5.3f uY=%5.3f\n",lY, depth,depth2,uY); #NB Origin is middle of base of lower part of upright leg #Upright leg of Y must transform from #1 to #2 Up_leg_static:=rectangle([x0-w/2, y0+h-depth],[x0+w/2, y0]): #1 #Up_leg:=rectangle([x0-w/2, y0+uY+w],[x0+w/2, y0]): #2 # Y_left and Y_right are left & right arms of Y x1:=x0+w/2:y1:=y0+uY: x2:=x0+base/2:y2:=y0+h: x3:=x0-lY+base/2:y3:=y0+h: x4:=x0:y4:=y0+h-depth: xM_L:=(x1+x2)/2:yM_L:=(y1+y2)/2: xM_R:=(x3+x4)/2:yM_R:=(y3+y4)/2: Y_left_Up:=polygon([[xM_L,yM_L],[x2, y2],[x3, y3],[xM_R, yM_R]]): Y_left_Lo:=polygon([[x1,y1],[xM_L,yM_L],[xM_R, yM_R],[x4, y4]]): #Bottom left point of mid-bar of goalpost (outer & inner) x5:=x0+base/2:y5:=y0+uY: x6:=x0+base/2-w:y6:=y0+uY+w: #printf("lY=%5.3f depth=%5.3f uY=%5.3f\n",lY, depth,uY); nf:=49: for t from 0 to nf do P1_x:=xM_L+(x5-xM_L)*t/nf:P1_y:=yM_L+(y5-yM_L)*t/nf: P2_x:=xM_R+(x6-xM_R)*t/nf:P2_y:=yM_R+(y6-yM_R)*t/nf: P3_x:=x3+(x3+w-x2)*t/nf:P3_y:=y2: # Point coords for right arm morphing. These should be a reflection in # y-axis P4_y:=y0+h-depth-(h-depth-uY-w)*t/nf: #Construct general polygon poly_YL_Up[t]:=polygon([[P1_x,P1_y],[x2,y2],[P3_x, P3_y],[P2_x,P2_y]]): poly_YL_Lo[t]:=polygon([[x1,y1],[P1_x,P1_y],[P2_x,P2_y],[x4,P4_y]]): Up_leg[t]:=rectangle([x0-w/2, y0+h-depth-(h-depth-uY-w)*t/nf],[x0+w/2, y0]): end do: pl1:=plots[display](seq(poly_YL_Up[t],t=1..nf),insequence=true, opts): pl2:=plots[display](seq(poly_YL_Lo[t],t=1..nf),insequence=true, opts): pl3:=plots[display](seq(Up_leg[t],t=1..nf),insequence=true, opts): plots[display]([pl3,pl1, pl2], opts); end proc: makeLeftArmY:=proc(x0,y0,h,base,w,alfa) local col, depth, lY,uY, opts,Up_leg,Y_left,Y_right, x1,x2,x3,x4,x5,x6,y1,y2,y3,y4,y5,y6,P1_x, P2_x, P3_x, P1_y, P2_y, P3_y, xM_L, yM_L, xM_R, yM_R, Y_left_Up,Y_left_Lo, nf, t, poly_YL_Up,poly_YL_Lo, pl1, pl2,pl3,Up_leg_static,P4_y: col:=`grey`: opts:=scaling=constrained,style=patchnogrid, axes=none, color=col: lY:=w/sin(alfa): depth:=(base/2-lY)*abs(tan(alfa)); #uY is length of side of upright of Y uY:=h-(base-w)/2*abs(tan(alfa)): #??? #printf("lY=%5.3f depth=%5.3f depth2=%5.3f uY=%5.3f\n",lY, depth,depth2,uY); #NB Origin is middle of base of lower part of upright leg #Upright leg of Y must transform from #1 to #2 Up_leg_static:=rectangle([x0-w/2, y0+h-depth],[x0+w/2, y0]): #1 # Y_left and Y_right are left & right arms of Y x1:=x0-w/2:y1:=y0+uY: x2:=x0-base/2:y2:=y0+h: x3:=x0+lY-base/2:y3:=y0+h: x4:=x0:y4:=y0+h-depth: xM_L:=(x1+x2)/2:yM_L:=(y1+y2)/2: xM_R:=(x3+x4)/2:yM_R:=(y3+y4)/2: Y_left_Up:=polygon([[xM_L,yM_L],[x2, y2],[x3, y3],[xM_R, yM_R]]): Y_left_Lo:=polygon([[x1,y1],[xM_L,yM_L],[xM_R, yM_R],[x4, y4]]): #Bottom left point of mid-bar of goalpost (outer & inner) x5:=x0-base/2:y5:=y0+uY: x6:=x0-base/2+w:y6:=y0+uY+w: #printf("lY=%5.3f depth=%5.3f uY=%5.3f\n",lY, depth,uY); nf:=49: #was 48 for t from 0 to nf do P1_x:=xM_L+(x5-xM_L)*t/nf:P1_y:=yM_L+(y5-yM_L)*t/nf: P2_x:=xM_R+(x6-xM_R)*t/nf:P2_y:=yM_R+(y6-yM_R)*t/nf: P3_x:=x3+(x2+w-x3)*t/nf:P3_y:=y2: #P4_x:=x4: P4_y:=y0+h-depth-(h-depth-uY-w)*t/nf: #Construct general polygon poly_YL_Up[t]:=polygon([[P1_x,P1_y],[x2,y2],[P3_x, P3_y],[P2_x,P2_y]]): poly_YL_Lo[t]:=polygon([[x1,y1],[P1_x,P1_y],[P2_x,P2_y],[x4,P4_y]]): Up_leg[t]:=rectangle([x0-w/2, y0+h-depth-(h-depth-uY-w)*t/nf],[x0+w/2, y0]): end do: pl1:=plots[display](seq(poly_YL_Up[t],t=1..nf),insequence=true, opts): pl2:=plots[display](seq(poly_YL_Lo[t],t=1..nf),insequence=true, opts): pl3:=plots[display](seq(Up_leg[t],t=1..nf),insequence=true, opts): plots[display]([pl1, pl2], opts); end proc: # It is recommended to keep angle alfa at 1.12 LeftY:=makeLeftArmY(44.3,0,12,7.8,1.5,1.12): RightY:=makeY(44.3,0,12,7.8,1.5,1.12): LetJ:=makeJ(0,0,12,6,1.5): plots[display](RightY,LetJ, lettE,Let_R1,lettE2,ball_kicked,M_working,LeftY);