/////// buttons //////// //Focus Ptpos("A",-pF); //Play resetclock(); playanimation(); Animeflg=1; Dirflg=1; sorg=Current; initflg=1; //Stop stopanimation(); Animeflg=""; sstart=Current; initflg=1; ////// ketlib ////////// use("KetCindyPlugin"); Dircdy=loaddirectory; setdirectory(plugindirectory); import("ketcindy.ini"); //PathW=""; Ketinit(); Setplaybuttons([-5,-5],16,[1]);//no ketjs on Movetojs(Text60,[3.5,-5],16); Movetojs(Text65,[-5.8,4.5],15); Movetojs(Text68,[-5.8,3.5],15); Movetojs(Text66,[1.2,4.5],15); Movetojs(Text67,[1.2,3.6],15);//no ketjs off cmdL=[ //no ketjs on "f=x^2/a^2+y^2/b^2-1",[], "eq=f==0/.{x->x0+u0*t,y->y0+v0*t}",[], "ans=Solve[eq,t]",[], "t1=t/.ans[[1]]",[], "x1=x0+u0*t1",[], "y1=y0+v0*t1",[], "t2=t/.ans[[2]]",[], "x2=x0+u0*t2",[], "y2=y0+v0*t2",[], "L={t1,x1,y1,t2,x2,y2,t1-t2,Numerator[t1-t2]}",[], "L=Simplify[L,a>0&&b>0]",[], "L[[1]]::L[[2]]::L[[3]]::L[[4]]::L[[5]]::L[[6]]::L[[7]]::L[[8]]",[] ]; CalcbyW("ans0",cmdL,[""]); cmdL=[ "f=x^2/a^2+y^2/b^2-1",[], "nv={D[f,x],D[f,y]}",[], "nv=nv/Norm[nv]",[], "tv={-nv[[2]],nv[[1]]}",[], "V0={u0,v0}",[], "V1=Simplify[tv.V0*tv-nv.V0*nv, a>0&&b>0&&Element[x,Reals]&&Element[y,Reals]]",[], "V1[[1]]::V1[[2]]",[] ]; CalcbyW("ans",cmdL,[""]); Ketcindyjsdata(["ans0",ans0,"ans",ans]);//no ketjs off Deffun("fans0(a,b,tpv)",[ "regional(eps,x0,y0,u0,v0,t,P,t1,x1,y1,t2,x2,y2)", "eps=10^(-4)", "x0=tpv_2_1;y0=tpv_2_2;u0=tpv_3_1;v0=tpv_3_2", "t1="+ans0_1,"x1="+ans0_2,"y1="+ans0_3, "t2="+ans0_4,"x2="+ans0_5,"y2="+ans0_6, "if(abs(t1-t2)=t2+eps,t=t1;P=[x1,y1],t=t2;P=[x2,y2])", "re([tpv_1+t,P,tpv_3])" ]); Deffun("fans(a,b,tpv1)",[ "regional(eps,tpv,u0,v0,x,y,u1,v1)", "eps=10^(-4)", "tpv=fans0(a,b,tpv1)", "x=tpv_2_1;y=tpv_2_2;u0=tpv_3_1;v0=tpv_3_2", "u1="+ans_1,"v1="+ans_2, "if((abs(y)Elliptical Billiard"]; poL=["_;(vx,vy) is the initial direction vector.", "
_;tmax is the maximum time in seconds.", "
_;The speed can be changed with the slider below.", "_;A.x is movable on the x-axes if the box of A.x blank." ]; Ketcindyjsmain(prL,poL);//no ketjs off Setwindow([-6,6],[-5.5,5]); Slider("T",[-5,-4],[5,-4]); Addax(0); A.y=0; a=4;b=3; A.x=min(max(-a,A.x),a); pF=[-sqrt(a^2-b^2),0]; Putpoint("C",pF); //tmax=500; //vx=-1; vy=1; str0="A.x=";// no ketjs on str3="tmax=500"; str1="vx=-1"; str2="vy=1";// no ketjs off //str0=Textedit(65);// only ketjs on //str3=Textedit(68); //str1=Textedit(66); //str2=Textedit(67);// only ketjs off A.x=Getcindystr(str0,""); tmax=Getcindystr(str3,500); vx=Getcindystr(str1,-1); vy=Getcindystr(str2,1); vec=[vx,vy]; vec=vec/|vec|; Arrowdata("0",[A.xy,A.xy+vec],["dr,2","Color=red","border->false"]); Drwxy(); fun=Assign("[a*cos(t),b*sin(t)]",["a",a,"b",b]); Paramplot("1",fun,"t=[0,2*pi]"); Pointdata("1",C,["Size=3","Color=red","border->false"]); if(initflg==1, tpv=[0,A.xy,vec]; pL=[tpv]; flg=0; while((tpv_11, plist=select(pL,#_1<=ss); plist=apply(plist,[#_1,#_2]); nn=length(plist); tp1=plist_nn; if(tp1_1