Question: Animation

The code generates lines parallel to the opposite side of a given triangle. How can I control the animation to stop at x=10 or not to go outside the triangle. restart; with(geometry): with(Maplets[Elements]): with(plots): _EnvHorizontalName := x: _EnvVerticalName := y: AA:=50; BB:=70; CC:=60;side3:=10; #AA:=100; BB:=50; CC:=30;side3:=10; theta:=evalf((Pi/180)*AA); adj:=evalf(side3*sin((Pi/180)*70)/sin((Pi/180)*60)); opp:=evalf(side3*sin((Pi/180)*50)/sin((Pi/180)*60)); xx:=evalf(adj*cos(theta)); yy:=evalf(adj*sin(theta)); ps:=point(A,[0,0]), point(B,[side3,0]), point(C,[xx,yy]); triangle(ABC,[ps]); mAC:=slope(A,C); mBC:=slope(B,C); par:=Tri(opp,adj,side3,theta); STri:=proc(con,thi,sca,col) return(connect=con,thickness=thi,scaling=sca,color=col); end proc: PTri:=proc(sym,symsz,sca,col) return(symbol=sym,symbolsize=symsz,scaling=sca,color=col); end proc: Tri:=proc(opp, adj, side3, theta) local xx, yy, pt1, pt2, pt3, ps, ABC, AB, AC, BC, m1, m2, m3; uses plots, Maplets:-Tools; _EnvHorizontalName := x: _EnvVerticalName := y: xx:=adj*cos(theta); yy:=adj*sin(theta); ps:=point(A,[0,0]),point(B,[side3,0]),point(C,[xx,yy]): triangle(ABC,[ps]): m1:=map(coordinates,DefinedAs(segment(AB,[A,B]))); m2:=map(coordinates,DefinedAs(segment(AC,[A,C]))); m3:=map(coordinates,DefinedAs(segment(BC,[B,C]))); plots[display]( pointplot(m1,STri(true,2,constrained,blue)), pointplot(m1,PTri(solidcircle,20,constrained,blue)), pointplot(m2,STri(true,2,constrained,blue)), pointplot(m2,PTri(solidcircle,20,constrained,blue)), pointplot(m3,STri(true,2,constrained,blue)), pointplot(m3,PTri(solidcircle,20,constrained,blue)) ); end proc: ball:=proc(x,y) local mAC,mBC,x1; mAC:=slope(A,C); mBC:=slope(B,C); x1:=((mBC-mAC)/mBC)*x; plots[display]( pointplot([[x1,0],[x,mAC*x]],STri(true,2,constrained,green)), pointplot([[x1,0],[x,mAC*x]],PTri(solidcircle,20,constrained,red)) ); end proc: h1:=animate(ball,[t,mAC*t],t=0..side3,frames=10,trace=7, background=par, scaling=constrained); animator := Maplet( [Plotter[P](h1, continuous=false), [ Button("play",SetOption(P('play')=true))], [ "continuous", CheckBox[CONTINUOUS](value=false, onchange=SetOption(target=P, `option`='continuous', Argument(CONTINUOUS))) ], Button("ok",Shutdown()) ]): Maplets:-Display(animator); >

Please Wait...