// Copyright (C) 2014 Setsuo Takato, KETCindy Japan project team // //This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see // // s: 2014.12.01 v1.0.0 // e: 2014.12.03 v1.0.1 // e: 2014.12.05 v1.0.2 // Paramplot debugged ( negative number ) // e: 2014.12.09 v1.1.0 // Setscaling changed ( Setwindow() added ) // Arrowdata debugged ( Arrowhead options ) // Arrowheadata debugged (Scaling ) // Writetosci changed (XMIN,... assigned ) // Coordinate System changed // Pcrd used for GCLIST, Lcrd used calculating // Extractdata added // Plotdata debugged (Exc option) // Assign added // Plotdata, Paramplot changed ( Assign used ) // e: 2014.12.11 // Circledata through 3 pts supported // e: 2014.12.14 // ReadOutData changed ( for 3d ) // e: 2014.12.16 v1.1.1 // nodata option added // Makeshell added // e: 2014.12.17 // Extractdata changed (GLIST ) // e: 2014.12.18 // Exptractdata changed ( case of list length==1) // Integrate changed ( for scaling ) // IntersectcrvPhy, Intersectcrv, Meetcurve changed ( for scaling) // Arrowheaddata debugged ( for scaling ) // e: 2014.12.19 // Windispg changed ( empty case ) // hatchdata changed ( Extractdata used ) // e: 2014.12.20 // Assign debugged ( case of .x ) // Plotdata, Paramplot changed ( Num changed to number of intervals ) // e: 2014.12.21 // ReadOutData changed ( comment if headchar="#" ) // e: 2014.12.22 // Windispg changed ( case of empty data ) // ReadOutData debugged // Flattenlist, WriteOutData added // e: 2014.12.24 // Divoptions added // Addgraph added ( need to be revised ) // e: 2014.12.27 // Dotprod, Crossprod moved from 3dlib // BezierCurve added // e: 2014.12.28 // Bezier changed (2 & 3 ) // e: 2014.12.30 // ViewTeX added // Bezier changed ( choosable 2/3 ) // Hatchdata debugged ( iostr to list ) // v1.1.3 // e: 2014.12.31 // Bezier changed ( varirous forms of Num, ctrlist usable) // Pointdata changed ( opcindy supported ) // e: 2015.01.01 // Bezier(list) supported ([ptlist,ctrlist,name]); // Readpcsvsla, Putbezierdata added // e: 2015.01.02 // Bezier changed ( corresponded to Bezier in ketsciL5.1.4 ) // Mkbezierptcrv added // e: 2015.01.03 // Mkbeziercrv added // Putbezierdata changed (option "Size=") // BezierNumber added to Ketinit // Mkbezierptcrv changed ( ptctrLL returned ) // Shade changed ( case of not defined yet ) // e: 2015.01.04 v1.1.4 // ketcindylogo added // e: 2015.01.05 // CRspline added // e: 2015.01.05 // CRspline changed ( "Rat=" added ) // Com2ndpre added ( ex) shade // e: 2015.01.07 // Com2ndpre added // Shade changed ( Com2ndpre used ); // Bzspline added // e: 2015.01.08 // Shade (Com2nd ) restored // Bzsspline added // Bspline added ( Usui ) // e:2015.01.11 // Beziersmooth, Beziersym = Bzspline, Bzsspline // Arrowheaddata,Arrowhead, Arrowdata changed ( option etc) // e: 2015.01.12 // Setunitlen changed (added to GLIST ) // e: 2015.01.13 // Makeshell, Makebat changed ( case of Texmain==""); // Divoptions used for options of all commands // e: 2015.01.14 // Arrowhead debugged // e: 2015.01.15 // Makesh, Makebat debugged and changed ( Warning message ) // e: 2015.01.17 // WriteOutData changed ( list of Gname permitted) // e: 2015.01.20 // Setpt changed ( written to COM2nd ) // AddGraph debugged & changed // e: 2015.01.22 // AddGraph changed ( for, stringdata, for pointdata) // MeasureDepth changed ( singlepoint =0) // Mkbezierptcrv changed (label of points ) // Setcolor changed ( Setcolor (ketpic)command supported) // e: 2015.01.27 // Plist, Vlist changed (format(. , 5 ) used ) // e: 2015.01.31 // Windispg(pltlist) added (changed from Windispg(GoutL)) // e: 2015.02.05 // format(.., 5) changed ( to remove "i" ) // e: 2015.02.06 // Defvar(name,value) changed (parse executed ) // WritetoSci changed ( VLIST ) // e: 2015.02.08 // Defvar(name,value) debugged // Bezierpt changed ( available for 3d ) // e: 2015.02.09 // Changestyle, ChangeTablestyle, Textformat added // Assign changed (Textformat used ) // e: 2015.02.13 // Tabledata, Putpttable changed ( made from up to down ) // e: 2015.02.14 // Putpttable changed ( R0 fixed ) // e: 2015.02.15 // Putpttable debugged // Mksegments, Mkcircles added // PtonLine, PtonSeg added // e: 2015.02.16 // Finddef added // e: 2015.02.18 // Rotatedata,... debugged ( for pdlist ) // e: 2015.02.19 // Findgeoinfo,Sortpointlist added // e: 2015.02.21 // Pointdata changed ( for non list, and "size=" added ) // e: 2015.02.22 // Letter, Expr changed ( ` ) // PtonLine,... renamed to PutonLine,.. // Pne, Psw renamed to NE, SE // e: 2015.02.23 // help(example) added // Mkbezierptcrv changed ( available for BezierNumber >26) // Makehelplist,Makecmdlist,Savecmdlist,Quicksort,Lessstr added // Helplist,Help added // e: 2015.02.24 // Help ( PointonCurve ) revised // e: 2015.02.25 v1.2.1 // Helplist changed // Dependgeo, Viewprocess added // e: 2015.02.27 // Drawprocess renamed to Workprocess // Help changed ( Capital transform quitted ) // e: 2015.02.28 // Makecmd changed ( Dirlb ) // Mkbezierptcrv debugged ( name ) // Shade changed ( err message removed ) // system help added // e: 2015.03.05 // CRspline changed (cinderella options available ) // e: 2015.03.06 v1.2.2 // Findarea added // e: 2015.03.07 // Findlength added // e: 2015.03.11 v1.2.3 // Mkbezierptcrv changed ( A,... => a,... ) // e: 2015.03.12 // Bowdata debugged //help:drawimage([0,0],"picture.jpg",scale->2,alpha->0.4); //help:system(list=append(list,"a");); //help:system(list=concat(list,["a","b"]);); Ketinit():=Ketinit(1); //help:Ketinit(); Ketinit(sy):=Ketinit(sy,[-5,5],[-5,5]); Ketinit(sy,rangex,rangey):=( regional(pt,tmp,tmp1,tmp2); println("KETCindy V.1.2.3(2015.03.13)"); PenThickInit=8; ULEN="1cm"; KETPICLAYER=20; MilliIn=1/2.54*1000; PenThick=round(MilliIn*0.02); PenThickInit=PenThick; TenSizeInit=0.02; TenSize=TenSizeInit; YaSize=1; YaAngle=18; YaPosition=1; YaThick=1; YaStyle='tf'; KETPICCOUNT=1; KCOLOR=[0,0,0]; GLIST=[]; GCLIST=[]; // GDATALIST=[]; GOUTLIST=[]; POUTLIST=[]; VLIST=[]; FUNLIST=[]; LETTERlist=[]; COM0thlist=[]; COM1stlist=[]; COM2ndlist=[]; SCIWRLIST=[]; SCIRELIST=[]; ADDAXES="1"; LFmark=unicode("000a"); Dq=unicode("0022"); setdirectory(Dirwork); Fnametex=Fhead+".tex"; Fnamesci=Fhead+".sce"; Fnamescibody=Fhead+"body.sce"; Fnameout=Fhead+".txt"; ArrowlineNumber=1; // 15.01.05 ArrowheadNumber=1; BezierNumber=1; //15.01.03 SCALEX=1; SCALEY=sy; // Setscaling(sy); XMIN=rangex_1/SCALEX; XMAX=rangex_2/SCALEX; YMIN=rangey_1/SCALEY; YMAX=rangey_2/SCALEY; Setwindow(); ); Changestyle(nameL,style):=( //help:Changestyle("sgAB",["da"]); regional(nmL,name,Ltype,Ltypeorg,Noflg,opcindy,tmp); tmp=Divoptions(style); Ltypeorg=tmp_1; Noflg=tmp_2; opcindy=tmp_(length(tmp)); if(islist(nameL),nmL=nameL,nmL=[nameL]); forall(nmL,name, Ltype=Ltypeorg; GCLIST=select(GCLIST,#_1!=name); COM2ndlist=select(COM2ndlist,indexof(#,name)==0); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); ); ); Finddef(G):=( regional(def,tmp,tmp1,tmp2,tmp3); if(isstring(G),tmp=parse(G),tmp=G); def=text(inspect(tmp,"definition")); tmp1=indexof(def,"("); tmp2=indexof(def,";"); tmp3=indexof(def,")"); tmp=[substring(def,0,tmp1-1)]; if(tmp2>0, tmp=append(tmp,substring(def,tmp1,tmp2-1)); if(indexof(def,")",tmp3+1)==0, tmp=append(tmp,substring(def,tmp2,tmp3-1)); , tmp=append(tmp,substring(def,tmp2,tmp3)); ); , tmp=append(tmp,substring(def,tmp1-1,tmp3)); ); tmp; ); Findgeoinfo(geo):=( regional(out,tmp,tmp1,tmp2); tmp=Finddef(geo); if(ispoint(parse(tmp_2)), out=[tmp_2,tmp_3]; , tmp1=Findgeoinfo(parse(tmp_2)); if(ispoint(parse(tmp1_1)), out=[tmp1_1,tmp1_2]; , tmp2=Findgeoinfo(parse(tmp1_2)); out=[tmp2_1,tmp2_2]; ); ); if(ispoint(geo), if(!ispoint(parse(tmp_2)), tmp1=Finddef(parse(tmp_2)); , tmp1=tmp; ); out=append(out,tmp1_3); , out=append(out,tmp_3); ); out; ); Dependgeo(geo):=( regional(tmp,tmp1,tmp2,out); tmp=Finddef(geo); if(!iscircle(geo), out=[text(geo)]; , // out=[geo]; ); if(length(tmp)<3, out=concat(out,[tmp_1,[]]); , out=concat(out,[tmp_1]); tmp1=[tmp_2,tmp_3]; tmp=parse(tmp1_2); if(islist(tmp) % isreal(tmp), tmp1=[tmp1_1]; ); out=append(out,tmp1); ); out; ); Workprocess():=Workprocess(300); Workprocess(nn):=Drawprocess(nn); Drawprocess():=Drawprocess(300); Drawprocess(nn):=( //help:Workrocess(); regional(All,added,remain,out,flg,tmp,tmp1,tmp2); tmp=remove(allpoints(),[NE,SW,TH,FI]); tmp1=select(tmp, substring(text(#),length(text(#))-1,length(text(#)))!="z"); tmp1=concat(tmp1,alllines()); // tmp1=concat(tmp1,allcircles()); All=apply(tmp1,Dependgeo(#)); added=select(All,length(#_3)==0); out=sort(apply(added,#_1)); remain=remove(All,added); flg=0; repeat(nn, if(flg==0, tmp1=select(remain,remove(#_3,out)==[]); tmp2=sort(apply(tmp1,#_1)); out=concat(out,tmp2); remain=remove(remain,tmp1); if(length(remain)==0,flg=1); ); ); println("Process of drawing"); forall(out, println(Dependgeo(parse(#))); ); out; ); Sortpointlist(list):=( regional(plist,ilist,jj,kk,flg,p1,p2,in1,in2, tmp,tmp1,tmp2,out); out=list; plist=list_1; ilist=list_2; flg=0; forall(1..length(plist),jj, p1=plist_jj; in1=ilist_jj; forall((jj+1)..length(plist),kk, if(flg==0, p2=plist_kk; in2=ilist_kk; if(contains(in1,p2), tmp1=plist_(1..(jj-1)); tmp1=append(tmp1,p2); tmp1=concat(tmp1,plist_((jj+1)..(kk-1))); tmp1=append(tmp1,p1); tmp1=concat(tmp1,plist_((kk+1)..length(plist))); tmp2=ilist_(1..(jj-1)); tmp2=append(tmp2,in2); tmp2=concat(tmp2,ilist_((jj+1)..(kk-1))); tmp2=append(tmp2,in1); tmp2=concat(tmp2,ilist_((kk+1)..length(plist))); out=Sortpointlist([tmp1,tmp2]); flg=1; ); ); ); ); out; ); Textformat(value,dig):=( //help:Textformat(2/3,4); regional(vv,tmp,tmp1); if(islist(value), tmp1="["; forall(value, tmp1=tmp1+Textformat(#,dig)+","; ); tmp1=substring(tmp1,0,length(tmp1)-1)+"]"; , if(ispoint(value), vv=Lcrd(value); tmp1=Textformat(vv,dig); , tmp1=format(value,dig); ); ); tmp1; ); Assign(str):=( // old regional(out); out=str; forall(VLIST, tmp=substring(#_1,0,length(#_1)-1); out=replace(out,tmp,"("+#_2+")"); ); out; ); Assign(funstr,varname,rep):=( //help:Assign("x^2+a*x","a","1.3"); regional(repstr,ii,jj,tmp,tmp1,tmp2,Notvar,Flg); if(isstring(rep),repstr=rep,repstr=Textformat(rep,5)); // 15.02.09 tmp=[46]; // 12.20 tmp=concat(tmp,48..57); tmp=concat(tmp,65..90); tmp=concat(tmp,97..122); Notvar=apply(tmp,unicode(text(#),base->10)); tmp2=""; forall(1..100, ii=indexof(funstr,varname); if(ii>0, Flg=0; if(ii>1, tmp=substring(funstr,ii-2,ii-1); if(contains(Notvar,tmp), tmp2=tmp2+substring(funstr,0,ii); funstr=substring(funstr,ii,length(funstr)); Flg=1; ); ); if(Flg==0, jj=ii-1+length(varname); if(jj0, if(indexof(#,"tex")>0,Noflg=1); if(indexof(#,"disp")>0,Noflg=2); if(indexof(#,"data")>0,Noflg=3); flg=1; ); ); if(flg==0, if(indexof(#,"=")>0, eqL=append(eqL,#); flg=1; ); ); if(flg==0, if(indexof(#,"->")>0, opcindy=opcindy+","+#; flg=1; ); ); if(flg==0, if(indexof(#,"out")+indexof(#,"Out")>0, Outflg=1; flg=1; ); ); if(flg==0, if(indexof(#,"in")+indexof(#,"In")>0, Inflg=1; flg=1; ); ); if(flg==0, tmp=substring(#,0,2); tmp1=indexof(tmp,"dr")+indexof(tmp,"Dr"); tmp1=tmp1+indexof(tmp,"da")+indexof(tmp,"Da"); tmp1=tmp1+indexof(tmp,"id")+indexof(tmp,"Id"); tmp1=tmp1+indexof(tmp,"do")+indexof(tmp,"Do"); tmp1=tmp1+indexof(tmp,"dp")+indexof(tmp,"Dp"); if(tmp1>0, Ltype=#; flg=1; ); if(flg==0, strL=append(strL,#); opstr=opstr+","+Dq+#+Dq; ); ); ); [Ltype,Noflg,Inflg,Outflg,eqL,realL,strL,opstr,opcindy]; ); Dotprod(v1,v2):=( //help:Dotprod(vec1,vec2); v1*v2; ); Crossprod(a,b):=( //help:Crossprod(vec1,vec2); regional(tmp1,tmp2,tmp3,Out); if(length(a)==3, tmp1=a_2*b_3-a_3*b_2; tmp2=a_3*b_1-a_1*b_3; tmp3=a_1*b_2-a_2*b_1; Out=[tmp1,tmp2,tmp3]; , Out=a_1*b_2-a_2*b_1; ); Out; ); Ptstart(Fig):=( //help:Ptstart("gr1"); regional(tmp); if(isstring(tmp),tmp=parse(Fig),tmp=Fig); tmp_1; ); Ptend(Fig):=( //help:Ptend("gr1"); regional(tmp); if(isstring(tmp),tmp=parse(Fig),tmp=Fig); tmp_(length(Fig)); ); Numptcrv(Fig):=( //help:Numptcrv("gr1"); regional(tmp); if(isstring(tmp),tmp=parse(Fig),tmp=Fig); length(tmp); ); Ptcrv(Num,Fig):=( //help:Ptcrv("gr1"); regional(tmp); if(isstring(tmp),tmp=parse(Fig),tmp=Fig); tmp_Num; ); Invert(Fig):=( //help:Invert("gr1"); regional(tmp); if(isstring(tmp),tmp=parse(Fig),tmp=Fig); reverse(tmp); ); Paramoncrv(pP,Gdata):=( regional(Tmp,PtL); // Eps=10^(-8); if(isstring(Gdata),PtL=parse(Gdata),PtL=Gdata); Tmp=Nearestpt(pP,PtL); Tmp_2; ); ParamonCurve(pP,nN,plist):=( //help:ParamonCurve(A,10,"gr1"); regional(PtL,Out,Pa,Pb,vV,vW,sS); if(isstring(plist),PtL=parse(plist),PtL=plist); if(nN==length(PtL), Out=nN; , Pa=PtL_nN; Pb=PtL_(nN+1); vV=Pb-Pa; vW=pP-Pa; sS=vV*vW/|vV|^2; sS=min([max([sS,0]),1]); Out=nN+sS; ); Out; ); Pointoncrv(tT,PtL):=PointonCurve(tT,PtL); PointonCurve(tT,Gdata):=( //help:PointonCurve(20.5,"gr1"); regional(Out,Eps,nN,sS,Pa,Pb,PtL); if(isstring(Gdata),PtL=parse(Gdata),PtL=Gdata); if(length(PtL)==1,PtL=PtL_1); Eps=10^(-4); nN=floor(tT+Eps); sS=max([tT-nN,0]); if(nN==length(PtL), Out=PtL_nN; , Pa=PtL_nN; Pb=PtL_(nN+1); Out=(1-sS)*Pa+sS*Pb; ); Out; ); Koutenseg(pA,pB,pC,pD):=Koutenseg(pA,pB,pC,pD,[]); Koutenseg(pA,pB,pC,pD,options):=( regional(Eps0,Eps,Eps2,pV,Sv2,Out,pP,pQ,Flg,p1,p2,q1,q2, em1,eM1,em2,eM2,rT,Tmp1,Tmp2); Eps0=10^(-4); pV=pB-pA; Sv2=|pV|; pP=pC-pA; pQ=pD-pA; Eps=10^(-3); Eps2=0.2; Tmp1=0; forall(options, if(Tmp1==0, Eps=#; Tmp1=1; , Eps2=#; ); ); Flg=0; if(Sv2<10^(-3), Out=["inf","inf"]; Flg=1; ); if(Flg==0, Eps=min([Eps2,Eps/Sv2]); p1=pP*pV/Sv2^2; p2=[pP_2,-pP_1]*pV/Sv2^2; q1=pQ*pV/Sv2^2; q2=[pQ_2,-pQ_1]*pV/Sv2^2; em1=-Eps; eM1=1+Eps; em2=-Eps; eM2=Eps; if(max([p1,q1])eM1, Out=["inf","inf"]; Flg=1; ); if(max([p2,q2])eM2, Out=["inf","inf"]; Flg=1; ); ); if(Flg==0 & p2*q2<0, rT=p1-(q1-p1)/(q2-p2)*p2; if(rT>em1 & rT-Eps0 & rT<1+Eps0, Tmp1=pA+rT*pV; Tmp2=min([max([rT,0]),1]); Out=[Tmp1,Tmp2,0]; , Tmp1=pA+rT*pV; Tmp2=min([max([rT,0]),1]); Out=[Tmp1,Tmp2,1]; ); Flg=1; ); if(Flg==0 & (p1eM1 % p2eM2), if(q1eM1 % q2eM2, Out=["inf","inf"]; Flg=1; ); if(Flg==0, rT=min([max([q1,0]),1]); Tmp1=pA+rT*pV; Out=[Tmp1,rT,1]; Flg=1; ); if(Flg==0, rT=min([max([p1,0]),1]); Tmp1=pA+rT*pV; Out=[Tmp1,rT,1]; Flg=1; ); ); ); if(Flg==0 & (p1 > -Eps0 & p1 < 1 + Eps0 & p2 > -Eps0 & p2 < Eps0), rT= p1; Tmp1=pA+rT*pV; Out= [Tmp1, rT, 0]; Flg=1; ); if(Flg==0 & (q1 > -Eps0 & q1 < 1 + Eps0 & q2 > -Eps0 & q2 < Eps0), rT= q1; Tmp1=pA+rT*pV; Out=[Tmp1,rT,0]; Flg=1; ); if(Flg==0 & (p1eM1 % p2eM2), if(q1eM1 % q2eM2, Out=["inf","inf"]; Flg=1; ); if(Flg==0, rT=min([max([q1,0]),1]); Tmp1=pA+rT*pV; Out=[Tmp1,rT,1]; Flg=1; ); ); if(Flg==0 & (q1eM1% q2eM2), rT=min([max([p1,0]),1]); Tmp1=pA+rT*pV; Out=[Tmp1,rT,1]; Flg=1; ); if(Flg==0, if(abs(p2)0, Tmp=KL1_1; pP=Tmp_1; rT=Tmp_2; Ni=Tmp_3; Nj=Tmp_4; Tmp=[pP,Ni+rT,Nj]; Out=[Tmp]; ); forall(2..length(KL1),Ni, Tmp=KL1_Ni; pP=Tmp_1; Tmp2=0; Flg=0; forall(1..length(Out),Nj, if(Flg==0, Tmp=Out_Nj; if(|pP-Tmp_1|Eps, rT=(-a2*v2-v1*a1+v1*x1+x2*v2)/Tmp; if(rT<-Eps, pP=[a1,a2]; , if(rT>1+Eps, pP=[b1,b2]; , pP=[a1+rT*v1,a2+rT*v2]; ); ); sS=|pP-pA|; if(sSrange_1 & #_1value & va2>value) % (va10, tmp=tmp+","+text(options_1); ); Com2nd(tmp+")"); ); GetLinestyle(str,name):=( regional(noflg,tmp,tmp1,tmp2,Dop,Ltype); Ltype=-1; Dop=""; tmp1=indexof(str,","); if(tmp1>0, Dop=","+substring(str,tmp1,length(str)); ); noflg=parse(substring(str,0,1)); tmp1=substring(str,1,3); if(tmp1=="dr" % tmp1=="Dr", Ltype=0; if(noflg==0, Drwline(name+Dop); ); ); if(tmp1=="da" % tmp1=="Da", Ltype=1; if(noflg==0, Dashline(name+Dop); ); ); if(tmp1=="id" % tmp1=="Id", Ltype=1; if(noflg==0, Invdashline(name+Dop); ); ); if(tmp1=="do" % tmp1=="Do", Ltype=3; if(noflg==0, Dottedline(name+Dop); ); ); if(tmp1=="dp" % tmp1=="Dp", Ltype=0; tmp1=parse(name); tmp2=""; forall(tmp1, tmp2=tmp2+text(#_1)+","; ); tmp2=substring(tmp2,0,length(tmp2)-1); if(noflg==0, Drwpt(tmp2+Dop); ); ); if(tmp1=="no" % tmp1=="No", Ltype=10; ); Ltype; ); AddGraph(nm,pltdata):=AddGraph(nm,pltdata,[]); AddGraph(nm,pltdata,options):=( //help:AddGraph("1",[[2,4],[4,1]],[]); regional(name,Ltype,Noflg,opcindy,pdata,tmp); name="ad"+nm; println("generate addgraph "+name); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_9; if(isstring(pltdata),pdata=parse(pltdata),pdata=pltdata); // 15.01.22 pdata=Flattenlist(pdata); tmp1=[]; forall(pdata,tmp2, tmp=apply(tmp2,Pcrd(#)); tmp1=append(tmp1,tmp); ); if(length(tmp1)==1,tmp1=tmp1_1); pdata=tmp1; if(Noflg<3, tmp=name+"="+text(pdata); parse(tmp); if(MeasureDepth(pdata)==1, tmp1=name+"=Listplot("+text(pdata)+")"; , tmp1="list("; forall(1..length(pdata), tmp=name+"p"+text(#)+"="; if(length(pdata_#)>1, // 15.01.22 tmp=tmp+"Listplot("+text(pdata_#)+")"; , tmp=tmp+"Pointdata("+text(pdata_#_1)+")"; ); GLIST=append(GLIST,tmp); tmp1=tmp1+name+"p"+text(#)+","; ); tmp1=name+"="+substring(tmp1,0,length(tmp1)-1)+")"; ); GLIST=append(GLIST,tmp1); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); ); Joincrvs(nm,plotstrL):=Joincrvs(nm,plotstrL,[]); Joincrvs(nm,plotstrL,options):=( //help:Joincrvs("1",["sgAB","sgDCB"]); regional(plotlist,PtL,Eps,QdL,Flg,Ni,Qd,pP,pS,pQ,pR,rMN, opcindy,tmp,tmp1,tmp2,str,name,Ltype,Noflg); name="join"+nm; plotlist=[]; forall(plotstrL,str, if(isstring(str), tmp=parse(str); tmp=apply(tmp,LLcrd(#)); , tmp=str; ); plotlist=append(plotlist,tmp); ); Eps=10^(-4); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); tmp1=tmp_6; if(length(tmp1)>0,Eps=tmp1_1); QdL=[]; forall(plotlist,Qd, if(ispoint(Qd_1) % !islist(Qd_1_1), QdL=concat(QdL,[Qd]); , forall(Qd, QdL=concat(QdL,[#]); ); ); ); Flg=0; if(length(QdL)==0, PtL=[]; Flg=1; ); if(Flg==0, PtL=QdL_1; forall(2..length(QdL),Ni, Qd=QdL_Ni; if(Numptcrv(Qd)>1, pP=Ptend(PtL); pS=Ptstart(PtL); pQ=Ptstart(Qd); pR=Ptend(Qd); rMN=min([|pP-pQ|,|pP-pR|,|pS-pQ|,|pS-pR|]); if(rMN==|pP-pR|, Qd=reverse(Qd); , if(rMN==|pS-pQ|, PtL=reverse(PtL); , if(rMN==|pS-pR|, PtL=reverse(PtL); Qd=reverse(Qd); ); ); ); ); if(rMN>Eps, PtL=concat(PtL,Qd); , PtL=concat(PtL,Qd_(2..length(Qd))); ); ); ); if(Noflg<3, println("generate joincurve "+name); tmp1=apply(PtL,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); tmp1=""; forall(plotstrL, tmp1=tmp1+#+","; ); tmp1=substring(tmp1,0,length(tmp1)-1); GLIST=append(GLIST,name+"=Joincrvs("+tmp1+")"); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); PtL; ); Partcrv(nm,pA,pB,PkLstr):=Partcrv(nm,pA,pB,PkLstr,[]); Partcrv(nm,pA,pB,PkLstr,options):=( //help:Partcrv("1",A,B,"sgABC"); //help:Partcrv("1",1.3,2.5,"sgABC"); regional(PkL,Ans,Eps,Npt,Out1,Out2,tmp,tmp1,Flg,nS,nE,PPL,pP, opcindy,Ta,Tb,name,Ltype,Noflg,DepthFlg); name="part"+nm; if(isstring(PkLstr),PkL=parse(PkLstr),PkL=PkLstr); DepthFlg=0; if(MeasureDepth(PkL)==2, PkL=PkL_1; DepthFlg=1; ); PkL=apply(PkL,LLcrd(#)); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); Eps=10^(-3); Flg=0; if(isreal(pA), if(pA>pB+Eps, Npt=Numptcrv(PkL); Out1=Partcrv("",pA,Npt,PkLstr,["nodata"]); Out2=Partcrv("",1,pB,PkLstr,["nodata"]); tmp=Ptstart(PkL)-Ptend(PkL); if(|tmp|nE+Eps, pP=(1-pB+nE)*PkL_nE+(pB-nE)*PkL_(nE+1); PPL=concat(PPL,[pP]); ); Ans=PPL; Flg=1; ); ); if(Flg==0, tmp=Nearestpt(LLcrd(Pcrd(pA)),PkL); Ta=tmp_2; tmp=Nearestpt(Lcrd(Pcrd(pB)),PkL); Tb=tmp_2; Ans=Partcrv("",Ta,Tb,PkL,["nodata"] ); Ans=apply(Ans,Pcrd(#)); ); if(Noflg<3, println("generate partcrv "+name); tmp1=apply(Ans,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); GLIST=append(GLIST, if(DepthFlg==0, tmp=PkLstr; , tmp=PkLstr+"(1)"; ); tmp1=name+"=Partcrv("+text(Lcrd(pA))+","+text(Lcrd(pB))+","+tmp+")"); GLIST=append(GLIST,tmp1); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); Ans; ); Pointdata(nm,list):=Pointdata(nm,list,[]); Pointdata(nm,list,options):=( //help:Pointdata("1",[2,4],["Size=5"]); //help:Pointdata("2",[[2,3],[4,1]]); regional(name,nameL,ptlist,opstr,opcindy, eqL,size,tmp,tmp1,tmp2,tmp3,Ltype,Noflg); name="pt"+nm; nameL=name+"L"; println("generate pointdata "+name); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); opstr=tmp_(length(tmp)-1); size=""; eqL=tmp_5; if(length(eqL)>0, forall(eqL, tmp=substring(#,0,1); if(tmp=="s" % tmp=="S", tmp=indexof(#,"="); size=substring(#,tmp,length(#)); ); ); ); tmp=MeasureDepth(list); if(tmp>0, // 2015.02.21 if(tmp==1,ptlist=list,ptlist=list_1); tmp=apply(ptlist,[textformat(Pcrd(#),5)]); tmp1=text(tmp); tmp2=substring(tmp1,1,length(tmp1)-1); tmp3=tmp1; , ptlist=list; tmp1=textformat(Pcrd(ptlist),5); tmp2=tmp1; tmp3="["+tmp1+"]"; ); tmp=name+"="+tmp1; parse(tmp); tmp=nameL+"="+tmp3; parse(tmp); if(Noflg<3, GLIST=append(GLIST,name+"=Pointdata("+tmp2+")"); ); if(Noflg<2, tmp=[nameL,0,opcindy]; GCLIST=append(GCLIST,tmp); if(Noflg==0, if(length(size)>0, Com2nd("Setpt("+size+")"); ); Com2nd("Drwpt(list("+name+")"+opstr+")"); if(length(size)>0, Com2nd("Setpt("+textformat(TenSize/TenSizeInit,1)+")"); ); ); ); ptlist; ); Listplot(nm,list,options):=( //help:Listplot([A,B]); //help:Listplot("1",[[2,1],[3,3]]); regional(name,tmp,tmp1,ptlist,Ltype,opcindy,Noflg); name="sg"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); if(Noflg<3, println("generate Listplot "+name); ptlist=apply(list,Pcrd(#)); tmp=name+"="+text(ptlist); parse(tmp); GLIST=append(GLIST,name+"=Listplot("+list+")"); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); tmp1=apply(list,Lcrd(#)); tmp1; ); Listplot(Arg1,Arg2):=( regional(name,list,options,str); if(isstring(Arg1), name=Arg1; list=Arg2; Listplot(name,list,[]); , list=Arg1; options=Arg2; str=text(list); str=substring(str,1,length(str)-1); name=""; n=indexof(str,","); while(n>0, name=name+substring(str,0,n-1); str=substring(str,n,length(str)); n=indexof(str,","); ); name=name+str; Listplot(name,list,options); ); ); Listplot(list):=Listplot(list,[]); Lineplot(nm,list,options):=( //help:Lineplot([A,B]); //help:Lineplot("1",[[2,1],[3,3]]); regional(name,Out,tmp,tmp1,opstr,opcindy,Mag,Semi, Vec,pA,pB,Ltype,Noflg); name="ln"+nm; Mag=100; Semi=""; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); opstr=tmp_(length(tmp)-1); tmp1=tmp_6; if(length(tmp1)>0,Mag=tmp1_1); tmp1=tmp_7; if(length(tmp1)>0,Semi=tmp1_1); pA=Lcrd(list_1); pB=Lcrd(list_2); Vec= Mag/dist(pA,pB)*(pB-pA); if(length(Semi)==0, Out=[pA-Vec,pA+Vec]; , if(Semi=="+", Out=[pA,pA+Vec]; , Out=[pA-Vec,pA]; ); ); if(Noflg<3, println("generate Lineplot "+name); tmp1=apply(Out,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); GLIST=append(GLIST,name+"=Lineplot("+list+opstr+")"); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); Out; ); Lineplot(Arg1,Arg2):=( regional(name,list,options,str); if(isstring(Arg1), name=Arg1; list=Arg2; Lineplot(name,list,[]); , list=Arg1; options=Arg2; str=text(list); str=substring(str,1,length(str)-1); name=""; n=indexof(str,","); while(n>0, name=name+substring(str,0,n-1); str=substring(str,n,length(str)); n=indexof(str,","); ); name=name+str; Lineplot(name,list,options); ); ); Lineplot(list):=Lineplot(list,[]); Plotdata(name1,func,variable):=Plotdata(name1,func,variable,[]); Plotdata(name1,func,variable,options):=( //help:Plotdata("1","sin(x)","x",["Num=100"]); //help:Plotdata("1","x^2","x=[-1,1]"); regional(Fn,Va,tmp,tmp1,tmp2,eqL,name,Vname,x1,x2,dx,PdL,QdL, Num,Ec,Dc,Fun,Exfun,x,opstr,opcindy,Ltype,Ke,Eps,Pa,Noflg); name="gr"+name1; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); eqL=tmp_5; Num=50; Ec=[]; Exfun=""; Dc=1000; forall(eqL, tmp=indexof(#,"="); tmp1=substring(#,tmp,length(#)); opstr=opstr+",'"+#+"'"; if(substring(#,0,1)=="N", Num=parse(tmp1); ); if(substring(#,0,1)=="E", if(substring(tmp1,0,1)=="[", Ec=parse(tmp1); , Exfun=tmp1; ); ); if(substring(#,0,1)=="D", Dc=parse(tmp1); ); ); Eps=10^(-3); tmp=replace(func,LFmark,""); tmp=tokenize(variable,"="); Vname=tmp_1; if(length(tmp)>1, tmp=tmp_2; tmp=parse(tmp); x1=tmp_1; x2=tmp_2; , x1=XMIN; x2=XMAX; ); // dx=(x2-x2)/Num; Ec=append(sort(Ec),10000); Fun=Assign(func,Vname, "xx"); Exfun=Assign(Exfun,Vname, "xx"); PdL=[]; Ke=1; forall(0..Num, xx=x1+#*(x2-x1)/Num; // differs from Scilab ( / Num-1) if(length(Exfun)>0, tmp=parse(Exfun); if(abs(tmp)0, PdL=concat(PdL,["inf"]); ); ); , Pa=[]; if(xx-Ec_Ke<-Eps, Pa=[xx,parse(Fun)]; ); if(abs(xx-Ec_Ke)<=Eps, if(length(PdL)>0, if(PdL_length(PdL)_1!="inf", Pa=["inf"]; ); ); ); if(xx-Ec_Ke>Eps, Pa=[xx,parse(Fun)]; Ke=Ke+1; ); if(length(Pa)>0, if(Pa_1=="inf", PdL=concat(PdL,[Pa]); , if(length(PdL)==0, PdL=[Pa]; , tmp=PdL_length(PdL); if(tmp_1=="inf", PdL=concat(PdL,[Pa]); , if(dist(tmp,Pa)tmp, tmp1=concat(tmp1,[PdL_(tmp..(#-1))]) ); tmp=#+1; ); if(tmp0, if(Out_length(Out)_1!="inf", pa=["inf"]; ); ); ); if(tt-Ec_ke>Eps, pa=parse(func); ke=ke+1; ); if(length(pa)>0, if(pa_1=="inf", Out=append(Out,pa); , if(length(Out)==0, Out=[pa]; , tmp=Out_length(Out); if(tmp_1=="inf", Out=append(Out,pa); , if(|tmp-pa|tmp, tmp1=concat(tmp1,[Out_(tmp..(#-1))]) ); tmp=#+1; ); if(tmp10*Eps, println("points are in a line"); ra=0; , Ctr=1/2*(pA+pB)+1/2*d2/d1*tmp1; ra=|pA-Ctr|; tmp=name+"center="+Ctr; parse(tmp); Defvar(name+"center",Ctr); ); ); if(ra>0, Out=[]; forall(0..Num, Th=Rg_1+#*(Rg_2-Rg_1)/Num; Out=append(Out,Ctr+ra*[cos(Th),sin(Th)]); ); , Out=Lineplot("1",[pA,pB],["nodata"]); ); if(Noflg<3, println("generate Circledata "+name); tmp1=apply(Out,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); if(length(cenrad)==2, tmp=name+"=Circledata("+cenrad+opstr+")"; , if(ra>0, tmp=name+"=Circledata(["+Ctr+","+cenrad_1+"]"+opstr+")"; , tmp=name+"=Lineplot("+cenrad_1+","+cenrad_2+")"; ); ); GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); Out; ); Framedata():=( regional(pA); pA=(SW+NE)/2; Framedata("win",[pA,NE]); ); Framedata(list):=Framedata(list,[]); Framedata(Arg1,Arg2):=( regional(name,list,options,str); if(isstring(Arg1), name=Arg1; list=Arg2; Framedata(name,list,[]); , list=Arg1; options=Arg2; str=text(list); str=substring(str,1,length(str)-1); name=""; n=indexof(str,","); while(n>0, name=name+substring(str,0,n-1); str=substring(str,n,length(str)); n=indexof(str,","); ); name=name+str; Framedata(name,list,options); ); ); Framedata(nm,list,options):=( //help:Framedata(); //help:Framedata([A,B]); //help:Framedata("1",[A,B]); regional(name,Out,tmp,tmp1,pA,pB,x1,x2,y1,y2,dx,dy, opcindy,Ltype,Noflg); name="fr"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); pA=Lcrd(list_1); pB=Lcrd(list_2); dx=abs(pB_1-pA_1); dy=abs(pB_2-pA_2); x1=pA_1-dx; x2=pA_1+dx; y1=pA_2-dy; y2=pA_2+dy; Out=[[x1,y1],[x2,y1],[x2,y2],[x1,y2],[x1,y1]]; if(Noflg<3, println("generate Framedata "+name); tmp1=apply(Out,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); GLIST=append(GLIST,name+"=Framedata("+pA+","+dx+","+dy+")"); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); Out; ); Framedata(nm,cent,dx,dy):=Framedata(nm,cent,dx,dy,[]); Framedata(nm,cent,dx,dy,options):=( regional(name,Out,tmp,tmp1,x1,y1,x2,y2,Ltype,opcindy,Noflg); name="fr"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); x1=cent.x-dx; x2=cent.x+dx; y1=cent.y-dy; y2=cent.y+dy; Out=[[x1,y1],[x2,y1],[x2,y2],[x1,y2],[x1,y1]]; if(Noflg<3, println("generate Framedata "+name); tmp1=apply(Out,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); GLIST=append(GLIST,name+"=Framedata("+cent.xy+","+dx+","+dy+")"); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); Out; ); Ovaldata(nm,Pdata):=Ovaldata(nm,Pdata,[]); Ovaldata(nm,Pdata,options):=( //help:Ovaldata("1",[A,B],[2]); regional(name,Graph,Ctr,Dx,Dy,Rc,Out,Point,Graph, opstr,opcindy,tmp,tmp1,tmp2,tmp3,Ltype,Noflg); name="ov"+nm; println("generate Ovaldata "+name); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); opstr=tmp_(length(tmp)-1); Rc=0.2; tmp1=tmp_6; if(length(tmp1)>0,Rc=tmp1_1*Rc); Ctr=Lcrd(Pdata_1); if(ispoint(Pdata_2) % islist(Pdata_2), tmp1=Lcrd(Pdata_2); Dx=abs(tmp1_1-Ctr_1); Dy=abs(tmp1_2-Ctr_2); , Dx=Pdata_2; Dy=Pdata_3; ); Point=Ctr+[Dx-Rc,Dy-Rc]; tmp1=Circledata("1",[Point,Point+[Rc,0]], ["Rng=[0,pi/2]","Num=10","nodata"]); tmp2=Listplot("1",[Ctr+[Dx-Rc,Dy],Ctr+[0,Dy]], ["nodata"]); tmp3=Listplot("2",[Ctr+[Dx,0],Ctr+[Dx,Dy-Rc]], ["nodata"]); Graph=Joincrvs("1",[tmp3,tmp1,tmp2],["nodata"]); tmp1=Reflectdata("1",[Graph],[Ctr,Ctr+[0,1]],["nodata"]); Graph=Joincrvs("1",[Graph,tmp1],["nodata"]); tmp2=Reflectdata("2",[Graph],[Ctr,Ctr+[1,0]], ["nodata"]); Graph=Joincrvs("2",[Graph,tmp2],["nodata"]); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); tmp1=apply(Graph,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); tmp=text(Ctr)+","+text(Dx)+","+text(Dy); GLIST=append(GLIST, name+"=Ovaldata("+tmp+opstr+")"); ); Graph; ); Arrowheaddata(point,direction):=Arrowheaddata(point,direction,[]); Arrowheaddata(point,direction,options):=( regional(list,Ookisa,Hiraki,Futosa,Houkou,Str,Flg,tmp,Ev,Nv,pA,pB, pP,rF,gG,Flg,Nj,Eps,tmp1,scx,scy); Eps=10^(-3); pP=point; Ookisa=0.2*YaSize; Hiraki=YaAngle; Futosa=0; Str=YaStyle; tmp=Divoptions(options); tmp1=tmp_6; if(length(tmp1)>0,Ookisa=Ookisa*tmp1_1); if(length(tmp1)>1, tmp=tmp1_2; if(tmp<5, Hiraki=Hiraki*tmp; , Hiraki=tmp; ); ); Flg=0; Hiraki=Hiraki*pi/180; if(isstring(direction),Houkou=parse(direction),Houkou=direction); if(MeasureDepth(Houkou)==2,Houkou=Houkou_1); if(islist(Houkou_1), // pP=Lcrd(pP); // pP=Doscaling(pP); // Houkou=Dosscaling(Houkou); pP=Pcrd(pP); scy=SCALEY; SCALEY=1; tmp=Nearestpt(pP,Houkou); pA=tmp_1; rF=floor(tmp_2); if(rF==1, if(|Ptend(Houkou)-Ptstart(Houkou)|0, Houkou=pP-tmp_1_1; Flg=1; ); pA=pB; ); ); SCALEY=scy; if(Flg==0, println("Arrowhead may be too large (no intersect)"); Flg=2; ); if(Flg==1, Houkou=Unscaling(Houkou); pP=Unscaling(pP); ); ); if(Flg<2, // pP=Doscaling(pP); // Houkou=Doscaling(Houkou); pP=Pcrd(pP); if(!ispoint(point), Houkou=Pcrd(Houkou); ); // if(MeasureDepth(Houkou)==0,Houkou=Pcrd(Houkou)); Ev=-1/|Houkou|*Houkou; Ev=Lcrd(Ev); Nv=[-Ev_2, Ev_1]; if(indexof(Str,"c")>0, pP=pP-0.5*Ookisa*cos(Hiraki)*Ev; ); if(indexof(Str,"b")>0, pP=pP-Ookisa*cos(Hiraki)*Ev; ); pA=pP+Ookisa*cos(Hiraki)*Ev+Ookisa*sin(Hiraki)*Nv; pB=pP+Ookisa*cos(Hiraki)*Ev-Ookisa*sin(Hiraki)*Nv; list=[pA,pP,pB]; list=apply(list,LLcrd(#)); // Out=Unscaling(Out); list; ); ); Arrowhead(point,Houkou):=Arrowhead(point,Houkou,[]); Arrowhead(point,Houkou,options):=( //help:Arrowhead(B,B-A,[1.5,30]); // global ArrowheadNumber regional(name,Ltype,Noflg,opstr,opcindy,ptstr,hostr,tmp,tmp1,list); name="arh"+text(ArrowheadNumber); ArrowheadNumber=ArrowheadNumber+1; ptstr=text(point); if(isstring(Houkou), // 15.01.11 tmp=parse(Houkou); if(MeasureDepth(tmp)<2, hostr=Houkou; , hostr=Houkou+"(1)"; ); , if(ispoint(point), hostr=text(LLcrd(Houkou)); , hostr=text(Houkou); ); ); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); list=Arrowheaddata(point,Houkou,options); if(Noflg<3, // println("generate Arrowhead "+name); tmp1=apply(list,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); // GLIST=append(GLIST,name+"=Listplot("+list+")"); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(1)+Ltype,name); , // if(Noflg==1,Ltype=0); Ltype=0; ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); if(Noflg==0, Com2nd("Arrowhead("+ptstr+","+hostr+opstr+")"); ); ); Arrowdata(ptlist):=Arrowdata(ptlist,[]); Arrowdata(Arg1,Arg2):=( regional(tmp,nm,ptlist,flg,pA,pB,options); flg=0; if(isstring(Arg1), nm=Arg1; ptlist=Arg2; Arrowdata(nm,ptlist,[]); flg=1; ); if(flg==0, tmp=MeasureDepth(Arg1); if(tmp==0, pA=Arg1; pB=Arg2; Arrowdata(pA,pB,[]); , ptlist=Arg1; options=Arg2; nm=text(ArrowlineNumber); ArrowlineNumber=ArrowlineNumber+1; Arrowdata(nm,ptlist,options); ); ); ); Arrowdata(Arg1,Arg2,options):=( //help:Arrowdata([A,B],[2,10]); regional(Retflg,nm,ptlist,name,opstr,opcindy, flg,Ltype,Noflg,tmp,tmp1,tmp2,pA,pB,segpos); Retflg=0; Noflg=0; Ltype=0; if(!isstring(Arg1), pA=Arg1; pB=Arg2; Arrowdata(pA,pB,options,"old"); Retflg=1; ptlist=[pA,pB]; ); if(Retflg==0, nm=Arg1; ptlist=Arg2; name="ar"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); segpos=1; tmp1=tmp_5; if(length(tmp1)>2, segpos=tmp1_3; ); if(Noflg<3, // println("generate Arrowdata "+name); tmp1=apply(ptlist,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); GLIST=append(GLIST,name+"=Listplot("+ptlist+")"); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); tmp=text(ptlist); tmp=substring(tmp,1,length(tmp)-1); tmp1=indexof(tmp,"],["); if(tmp1>0, pA=substring(tmp,0,tmp1); pB=substring(tmp,tmp1+1,length(tmp)); , tmp1=indexof(tmp,","); pA=substring(tmp,0,tmp1-1); pB=substring(tmp,tmp1,length(tmp)); ); tmp1="Lcrd("+pA+")+"+text(segpos)+"*(Lcrd("+pB+")-"+"Lcrd("+pA+"))"; tmp1=parse(tmp1); tmp2="Lcrd("+pB+")-Lcrd("+pA+")"; tmp2=parse(tmp2); Arrowhead(tmp1,tmp2,options); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); ); ptlist; ); Arrowdata(pA,pB,options,str):=( regional(ptA,ptB,opstr,Astr,Bstr,name,tmp,opcindy); Astr=text(pA); Bstr=text(pB); name="ar"+pA.name+pB.name; println("generate Arrow "+name); opstr=""; opcindy=""; forall(options, if(isstring(#), if(indexof(#,"->")>0, opcindy=opcindy+","+#; , tmp="'"+#+"'"; ); , tmp=text(#); ); opstr=opstr+","+tmp; ); ptA=Lcrd(pA); ptB=Lcrd(pB); Arrowheaddata(ptB,ptB-ptA,options); tmp="connect("+text([ptA,ptB])+",linecolor->"+text(KCOLOR)+opcindy+");"; parse(tmp); // 14.11.17 Com2nd("Arrowline("+Astr+","+Bstr+opstr+")"); // 14.10.04 ); Anglemark(plist):=Anglemark(plist,[]); Anglemark(plist,options):=( //help:Anglemark([A,B,C],["E=\theta",2]); regional(name,Out,pB,pA,pC,Ctr,ra,sab,sac,ratio,opstr,Bname,Bpos, Brat,tmp,tmp1,tmp2,Num,opcindy,Ltype,eqL,realL,Rg,Th,Noflg); tmp=text(plist); tmp=replace(tmp,",",""); tmp=substring(tmp,1,length(tmp)-1); name="ag"+tmp; ra=0.5; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); eqL=tmp_5; realL=tmp_6; Bname=""; Brat=1.5; Num=20; if(length(realL)>0, ra=realL_1*ra; opstr=opstr+","+text(realL_1); ); forall(eqL, if(substring(#,0,1)=="L",Bname="Letter("); if(substring(#,0,1)=="E",Bname="Expr("); Bpos="md"+name; Bname=Bname+Dq+Bpos+Dq+","+Dq+"c"+Dq+","+Dq; tmp=substring(#,indexof(#,"="),length(#)); tmp1=indexof(tmp,","); Bname=Bname+substring(tmp,tmp1,length(tmp))+Dq+")"; if(tmp1>0, Brat=parse(substring(tmp,0,tmp1-1)); ); ); pB=Lcrd(plist_1); pA=Lcrd(plist_2); pC=Lcrd(plist_3); Ctr=Lcrd(pA); sab=pB-pA; sac=pC-pA; Rg=[arctan2(sab)+0,arctan2(sac)+0]; if(Rg_20, Th=(Rg_1+Rg_2)/2; tmp1=Ctr+Brat*ra*[cos(Th),sin(Th)]; tmp="Defvar("+Dq+Bpos+"="+text(tmp1)+Dq+");"; parse(tmp); parse(Bname); ); if(Noflg<3, println("generate anglemark "+name); tmp1=apply(Out,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); tmp1=substring(text(plist),1,length(text(plist))-1); tmp=name+"=Anglemark("+tmp1+opstr+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); Out; ); Paramark(plist):=Paramark(plist,[]); Paramark(plist,options):=( //help:Paramark([A,B,C],["E=\theta"]); regional(name,Out,pB,pA,pC,ra,sab,sac,ratio,opstr,Bname,Bpos, Brat,tmp,tmp1,tmp2,Ltype,Noflg,eqL,realL,opcindy); tmp=text(plist); tmp=replace(tmp,",",""); tmp=substring(tmp,1,length(tmp)-1); name="pm"+tmp; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); eqL=tmp_5; realL=tmp_6; ra=0.5; Bname=""; Brat=1.2; if(length(realL)>0, tmp=realL_1; ra=tmp*ra; opstr=opstr+","+text(tmp); ); forall(eqL, if(substring(#,0,1)=="L",Bname="Letter("); if(substring(#,0,1)=="E",Bname="Expr("); Bpos="md"+name; Bname=Bname+Dq+Bpos+Dq+","+Dq+"c"+Dq+","+Dq; tmp=substring(#,indexof(#,"="),length(#)); tmp1=indexof(tmp,","); Bname=Bname+substring(tmp,tmp1,length(tmp))+Dq+")"; if(tmp1>0, Brat=parse(substring(tmp,0,tmp1-1)); ); ); pB=Lcrd(plist_1); pA=Lcrd(plist_2); pC=Lcrd(plist_3); Ctr=Lcrd(pA); Out=[]; Out=append(Out,pA+ra*(pB-pA)/|pB-pA|); Out=append(Out,pA+ra*(pB-pA)/|pB-pA|+ra*(pC-pA)/|pC-pA|); Out=append(Out,pA+ra*(pC-pA)/|pC-pA|); if(length(Bname)>0, tmp1=pA+Brat*ra*(pB-pA)/|pB-pA|+Brat*ra*(pC-pA)/|pC-pA|; tmp="Defvar("+Dq+Bpos+"="+text(tmp1)+Dq+");"; parse(tmp); parse(Bname); ); if(Noflg<3, println("generate paramark "+name); tmp1=apply(Out,Pcrd(#)); tmp=name+"="+text(tmp1); parse(tmp); tmp1=substring(text(plist),1,length(text(plist))-1); tmp=name+"=Paramark("+tmp1+opstr+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); Out; ); MakeBowdata(pA,pB,Hgt):=( regional(angle,pB2,pH2,pC2,pC,tmp,Th1,Th2,ra,dMA); angle=arctan2(pB-pA)+0; pB2=Rotatepoint(pB,-angle,pA); tmp=Lcrd(pA); pH2=[(tmp_1+pB2_1)/2,tmp_2-Hgt]; dMA=|tmp-pB2|/2; ra=(dMA^2+Hgt^2)/(2*Hgt); pC2=[pH2_1,pB2_2+(ra-Hgt)]; pC=Rotatepoint(pC2,angle,pA); Th1=arctan2(pA-pC2)+angle; Th2=arctan2(pB2-pC2)+angle; [pC,ra,Th1,Th2]; ); Bowdata(plist):=Bowdata(plist,[]); Bowdata(plist,options):=( regional(nm,tmp); tmp=text(plist); tmp=replace(tmp,",",""); nm=substring(tmp,1,length(tmp)-1); Bowdata(nm,plist,options); ); Bowdata(nm,plist,options):=( //help:Bowdata([C,A],[2,1.2,"Expr=10","da"]); regional(name,Out,pB,pA,pC,ra,tmp,tmp1,tmp2,Ltype,eqL,realL, Bname,Bpos,Th,Cut,Num,Hgt,opstr,opcindy,Ydata,pC, Th1,Th2,Noflg,Bops); name="bw"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); eqL=tmp_5; realL=tmp_6; pA=Lcrd(plist_1); pB=Lcrd(plist_2); Hgt=1/2*|pB-pA|*0.2; Cut=0; Num=24; Bname=""; if(length(realL)>0, Hgt=realL_1; if(length(realL)>1,Cut=realL_2); ); forall(eqL, tmp=substring(#,0,1); if(tmp=="L" % tmp=="l", if(indexof(#,"rot")>0, Bname="Letterrot("; , Bname="Letter("; ); ); if(tmp=="E" % tmp=="e", if(indexof(#,"rot")>0, Bname="Exprrot("; , Bname="Expr("; ); ); Bops=#; ); Ydata=MakeBowdata(pA,pB,Hgt); pC=Ydata_1; ra=Ydata_2; Th=(Ydata_3+Ydata_4)*0.5; BOWMIDDLE=[pC_1+ra*cos(Th),pC_2+ra*sin(Th)]; if(length(Bname)>0, Bpos="md"+name; tmp="Defvar("+Dq+Bpos+"="+text(BOWMIDDLE)+Dq+");"; parse(tmp); Bname=Bname+Dq+Bpos+Dq+","; if(indexof(Bname,"rot")>0, tmp1=pB-pA; if(tmp1_1<0, tmp1=-tmp1); tmp2=indexof(Bops,","); if(tmp2>0, tmp=substring(Bops,0,tmp2-1); if(indexof(tmp,"u")>0, tmp1=-tmp1; Bops=replace(tmp,"u","")+substring(Bops,tmp2-1,length(Bops)); Bops=replace(Bops,"=,","="); ); ); Bname=Bname+text(tmp1)+","; ); tmp=substring(Bops,indexof(Bops,"="),length(Bops)); tmp1=indexof(tmp,","); if(tmp1==0, if(indexof(Bname,"rot")==0, Bname=Bname+Dq+"c"+Dq+","+Dq+tmp; , Bname=Bname+Dq+tmp; ); , Bname=Bname+Dq+substring(tmp,0,tmp1-1)+Dq+"," +Dq+substring(tmp,tmp1,length(tmp)); ); Bname=Bname+Dq+")"; parse(Bname); ); if(Cut==0, Th1=Ydata_3; Th2=Ydata_4; Out=[]; forall(0..Num, tmp=Th1+#*(Th2-Th1)/Num; Out=append(Out,pC+ra*[cos(tmp),sin(tmp)]); ); , Th1=Ydata_3; Th2=Th-Cut/(2*ra); tmp1=[]; forall(0..Num/2, tmp=Th1+#*(Th2-Th1)/(Num/2); tmp1=append(tmp1,pC+ra*[cos(tmp),sin(tmp)]); ); Th1=Th+Cut/(2*ra); Th2=Ydata_4; tmp2=[]; forall(0..Num/2, tmp=Th1+#*(Th2-Th1)/(Num/2); tmp2=append(tmp2,pC+ra*[cos(tmp),sin(tmp)]); ); Out=[tmp1,tmp2]; ); if(Noflg<3, println("generate bowdata "+name); if(MeasureDepth(Out)==1,Out=[Out]); tmp1=[]; forall(Out,tmp2, tmp=apply(tmp2,Pcrd(#)); tmp1=append(tmp1,tmp); ); tmp=name+"="+text(tmp1); parse(tmp); tmp1=substring(text(plist),1,length(text(plist))-1); tmp=name+"=Bowdata("+tmp1+opstr+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); ); Hatchdata(nm,iostr,pltlist):=Hatchdata(nm,iostr,pltlist,[]); Hatchdata(nm,iostr,pltlist,options):=( //help:Hatchdata("1",["i"],[["crAB"]],["dr,0.7","out"]); regional(name,Ltype,Noflg,PdL,tmp,tmp1,tmp2,opstr,opcindy,Str,Outflg,Inflg); name="ha"+nm; println("output hatchdata "+name); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; Inflg=tmp_3; Outflg=tmp_4; opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); Str="Hatchdata("; if(islist(iostr), tmp="list("; forall(iostr, tmp=tmp+Dq+#+Dq+","; ); Str=Str+substring(tmp,0,length(tmp)-1)+"),"; , Str=Str+Dq+iostr+Dq+","; ); PdL=pltlist; if(isstring(PdL_1) % !islist(PdL),PdL=[PdL]); forall(PdL,tmp1, tmp="list("; forall(tmp1, if(length(#)>1, tmp=tmp+#+","; , tmp=tmp+Dq+#+Dq+","; ); ); Str=Str+substring(tmp,0,length(tmp)-1)+"),"; ); Str=substring(Str,0,length(Str)-1)+opstr+")"; if(isreal(Ltype) & Noflg==0, Ltype="dr"); if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); if(Inflg==0, GLIST=append(GLIST,name+"="+Str); if(Outflg==1, SCIWRLIST=append(SCIWRLIST,name); ); , if(length(SCIRELIST)==0, ReadOutData(Fnameout); Extractdata(name,["nodisp"]); // 12.19 ); tmp1=[]; forall(GOUTLIST, if(#_1!=Fnameout,tmp1=append(tmp1,Pcrd(#))); // 14.12.04 ); GOUTLIST=tmp1; GCLIST=append(GCLIST,[name,Ltype,opcindy]); SCIRELIST=append(SCIRELIST,name); ); ); Enclosing(nm,plist,startpt):=Enclosing(nm,plist,startpt,[]); Enclosing(nm,plist,startpt,options):=( //help:Enclosing("1",["sc2","crAB","sc2","Invert(sc1)"],C,["dr"]); regional(name,Ltype,Noflg,tmp,tmp1,tmp2,opstr,Str); name="en"+nm; println("output enclosing "+name); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; Inflg=tmp_3; Outflg=tmp_4; opstr=tmp_length(tmp); Str="Enclosing("; tmp1="list("; forall(plist, tmp1=tmp1+#+","; ); Str=Str+substring(tmp1,0,length(tmp1)-1)+"),"+text(startpt)+")"; if(isreal(Ltype),Ltype="dr"); Ltype=GetLinestyle(text(Noflg)+Ltype,name); if(Inflg==0, GLIST=append(GLIST,name+"="+Str); if(Outflg==1, SCIWRLIST=append(SCIWRLIST,name); ); , if(length(SCIRELIST)==0, ReadOutData(Fnameout); Extractdata(name,["nodisp"]); // 12.19 ); tmp1=[]; forall(GOUTLIST, if(#_1!=Fnameout,tmp1=append(tmp1,Pcrd(#))); // 14.12.04 ); GOUTLIST=tmp1; GCLIST=append(GCLIST,[name,Ltype,opcindy]); SCIRELIST=append(SCIRELIST,name); ); ); Shade(plist):=Shade(plist,[]); Shade(plist,options):=( //help:Shade(["gr2","sg1"],[0.5]); regional(tmp,tmp1,tmp2,opstr,opcindy,Str,G2,flg); println("output Shade of "+plist); tmp=Divoptions(options); opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); flg=0; forall(plist, if(flg==0, if(!islist(parse(#)),flg=1); ); ); if(flg==1, // err("some data not defined yet"); , G2=Joincrvs("1",plist,["nodata"]); G2=apply(G2,Pcrd(#)); tmp1="fillpoly("+text(G2)+opcindy+");"; parse(tmp1); ); Str="Shade("; tmp1="list("; forall(plist, if(length(#)>1, tmp1=tmp1+#+","; , tmp1=tmp1+Dq+#+Dq+","; ); ); Str=Str+substring(tmp1,0,length(tmp1)-1)+")"+opstr+")"; Com2nd(Str); ); Rotatepoint(point,Theta,ctr):=( //help:Rotatepoint(A,2*pi/3,B); regional(X1,X2,Y1,Y2,Cx,Cy,tmp); tmp=Lcrd(point); X1=tmp_1; Y1=tmp_2; tmp=Lcrd(ctr); Cx=tmp_1; Cy=tmp_2; X2=Cx+(X1-Cx)*cos(Theta)-(Y1-Cy)*sin(Theta); Y2=Cy+(X1-Cx)*sin(Theta)+(Y1-Cy)*cos(Theta); [X2,Y2]; ); Translatepoint(point,mov):=( //help:Translatepoint(A,[2,3]); regional(X1,X2,Y1,Y2,Cx,Cy,tmp); tmp=Lcrd(point); X1=tmp_1; Y1=tmp_2; tmp=Lcrd(mov); Cx=tmp_1; Cy=tmp_2; X2=X1+Cx; Y2=Y1+Cy; [X2,Y2]; ); Scalepoint(point,ratio,center):=( //help:Scalepoint(A,[3,2],[0,0]); regional(X1,X2,Y1,Y2,Cx,Cy,tmp); tmp=Lcrd(point); X1=tmp_1; Y1=tmp_2; tmp=Lcrd(center); Cx=tmp_1; Cy=tmp_2; X2=Cx+ratio_1*(X1-Cx); Y2=Cy+ratio_2*(Y1-Cy); [X2,Y2]; ); Reflectpoint(point,symL):=( //help:Reflectpoint(A,B); //help:Reflectpoint(A,[[2,3]]); //help:Reflectpoint(A,[C,E]);\\ regional(X1,X2,Y1,Y2,Us,Vs,Pt1,Pt2,Cx,Cy,tmp); tmp=Lcrd(point); X1=tmp_1; Y1=tmp_2; Pt1=Lcrd(symL_1); if(length(symL)==1, Pt2=Pt1; , Pt2=Lcrd(symL_2); ); Us=Pt2_1-Pt1_1; Vs=Pt2_2-Pt1_2; if(Pt1==Pt2, X2=2*Pt1_1-X1; Y2=2*Pt1_2-Y1; , X2=(Us^2-Vs^2)/(Us^2+Vs^2)*X1+2*Us*Vs/(Us^2+Vs^2)*Y1 -2*Vs*(Us*Pt1_2-Vs*Pt1_1)/(Us^2+Vs^2); Y2=2*Us*Vs/(Us^2+Vs^2)*X1-(Us^2-Vs^2)/(Us^2+Vs^2)*Y1 +2*Us*(Us*Pt1_2-Vs*Pt1_1)/(Us^2+Vs^2); ); [X2,Y2]; ); Rotatedata(nm,plist,Theta):=Rotatedata(nm,plist,Theta,[]); Rotatedata(nm,plist,angle,options):=( //help:Rotatedata("1","crAB",pi/3,[[1,5],"dr,2"]); regional(tmp,tmp1,tmp2,pdata,Theta,Pt,Cx,Cy,PdLL,PdL, opcindy,Nj,Njj,Kj,Mj,X1,Y1,X2,Y2,Ltype,Noflg,name); name="rt"+nm; Pt=[0,0]; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); tmp1=tmp_6; if(length(tmp1)>0,Pt=Lcrd(tmp1_1)); pdata=plist; if(isstring(pdata),pdata=[pdata]); if(!isstring(pdata_1) & MeasureDepth(pdata)==1, pdata=[pdata]; ); if(isstring(angle),Theta=parse(angle),Theta=angle); Cx=Pt_1; Cy=Pt_2; PdL=[]; forall(pdata,Njj, if(isstring(Njj),Kj=parse(Njj),Kj=Njj); if(MeasureDepth(Kj)==1,Kj=[Kj]); tmp2=[]; forall(Kj,Nj, tmp1=[]; forall(Nj, tmp=LLcrd(#); X1=tmp_1; Y1=tmp_2; X2=Cx+(X1-Cx)*cos(Theta)-(Y1-Cy)*sin(Theta); Y2=Cy+(X1-Cx)*sin(Theta)+(Y1-Cy)*cos(Theta); tmp1=concat(tmp1,[[X2,Y2]]); ); tmp2=concat(tmp2,[tmp1]); ); PdL=concat(PdL,tmp2); ); if(Noflg<3, println("generate Rotatedata "+name); tmp1=[]; forall(PdL,tmp2, tmp=apply(tmp2,Pcrd(#)); tmp1=append(tmp1,tmp); ); if(length(tmp1)==1,tmp1=tmp1_1); tmp=name+"="+text(tmp1); parse(tmp); tmp1=text(plist); tmp1=replace(tmp1,"[","list("); tmp1=replace(tmp1,"]",")"); tmp=name+"=Rotatedata("+tmp1+","+text(angle)+","+text(Pt)+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); PdL; ); Translatedata(nm,plist,mov):=Translatedata(nm,plist,mov,[]); Translatedata(nm,plist,mov,options):=( regional(tmp,tmp1,tmp2,pdata,Cx,Cy,PdL,Nj,Njj,Kj, opcindy,X2,Y2,Ltype,Noflg,name); name="tr"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); pdata=plist; if(isstring(pdata),pdata=[pdata]); if(!isstring(pdata_1) & MeasureDepth(pdata)==1, pdata=[pdata]; ); tmp=Lcrd(mov); Cx=tmp_1; Cy=tmp_2; PdL=[]; forall(pdata,Njj, if(isstring(Njj),Kj=parse(Njj),Kj=Njj); if(MeasureDepth(Kj)==1,Kj=[Kj]); tmp2=[]; forall(Kj,Nj, tmp1=[]; forall(Nj, tmp=LLcrd(#); X2=tmp_1+Cx; Y2=tmp_2+Cy; tmp1=concat(tmp1,[[X2,Y2]]); ); tmp2=concat(tmp2,[tmp1]); ); PdL=concat(PdL,tmp2); ); if(Noflg<3, println("generate Translatedata "+name); tmp1=[]; forall(PdL,tmp2, tmp=apply(tmp2,Pcrd(#)); tmp1=append(tmp1,tmp); ); if(length(tmp1)==1,tmp1=tmp1_1); tmp=name+"="+text(tmp1); parse(tmp); tmp1=text(plist); tmp1=replace(tmp1,"[","list("); tmp1=replace(tmp1,"]",")"); tmp=name+"=Translatedata("+tmp1+","+text(mov)+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); PdL; ); Scaledata(nm,plist,ratioV):=( regional(tmp); tmp=Lcrd(ratioV); Scaledata(nm,plist,tmp_1,tmp_2,[]); ); Scaledata(nm,plist,Arg1,Arg2):=( //help:Scaledata("1","crAB",3,2,[[0,0]]); regional(tmp,options); if(islist(Arg2), tmp=Lcrd(Arg1); options=Arg2; Scaledata(nm,plist,tmp_1,tmp_2,options); , Scaledata(nm,plist,Arg1,Arg2,[]); ); ); Scaledata(nm,plist,rx,ry,options):=( regional(tmp,tmp1,tmp2,pdata,Theta,Pt,Cx,Cy,PdL, opcindy,Nj,Njj,Kj,X2,Y2,Ltype,Noflg,name); name="sc"+nm; Pt=[0,0]; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); tmp1=tmp_6; if(length(tmp1)>0, Pt=Lcrd(tmp1_1); ); pdata=plist; if(isstring(pdata),pdata=[pdata]); if(!isstring(pdata_1) & MeasureDepth(pdata)==1, pdata=[pdata]; ); Cx=Pt_1; Cy=Pt_2; PdL=[]; forall(pdata,Njj, if(isstring(Njj),Kj=parse(Njj),Kj=Njj); if(MeasureDepth(Kj)==1,Kj=[Kj]); tmp2=[]; forall(Kj,Nj, tmp1=[]; forall(Nj, tmp=LLcrd(#); X2=Cx+rx*(tmp_1-Cx); Y2=Cy+ry*(tmp_2-Cy); tmp1=concat(tmp1,[[X2,Y2]]); ); tmp2=concat(tmp2,[tmp1]); ); PdL=concat(PdL,tmp2); ); if(Noflg<3, println("generate Scaledata "+name); tmp1=[]; forall(PdL,tmp2, tmp=apply(tmp2,Pcrd(#)); tmp1=append(tmp1,tmp); ); if(length(tmp1)==1,tmp1=tmp1_1); tmp=name+"="+text(tmp1); parse(tmp); tmp1=text(plist); tmp1=replace(tmp1,"[","list("); tmp1=replace(tmp1,"]",")"); tmp=name+"=Scaledata("+tmp1+","+text(rx)+","+text(ry)+","+text(Pt)+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); PdL; ); Reflectdata(nm,plist,symL):=Reflectdata(nm,plist,symL,[]); Reflectdata(nm,plist,symL,options):=( //help:Reflectdata("1","crAB",[C]); regional(tmp,tmp1,tmp2,pdata,Us,Vs,Pt1,Pt2,Cx,Cy,PdL, opcindy,Nj,Njj,Kj,X1,Y1,X2,Y2,Ltype,Noflg,name); name="re"+nm; Pt=[0,0]; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opcindy=tmp_length(tmp); pdata=plist; if(isstring(pdata),pdata=[pdata]); if(!isstring(pdata_1) & MeasureDepth(pdata)==1, pdata=[pdata]; ); Pt1=Lcrd(symL_1); if(length(symL)==1, Pt2=Pt1; , Pt2=Lcrd(symL_2); ); Us=Pt2_1-Pt1_1; Vs=Pt2_2-Pt1_2; PdL=[]; forall(pdata,Njj, if(isstring(Njj),Kj=parse(Njj),Kj=Njj); if(MeasureDepth(Kj)==1,Kj=[Kj]); tmp2=[]; forall(Kj,Nj, tmp1=[]; forall(Nj, tmp=LLcrd(#); X1=tmp_1; Y1=tmp_2; if(Pt1==Pt2, X2=2*Pt1_1-X1; Y2=2*Pt1_2-Y1; , X2=(Us^2-Vs^2)/(Us^2+Vs^2)*X1+2*Us*Vs/(Us^2+Vs^2)*Y1 -2*Vs*(Us*Pt1_2-Vs*Pt1_1)/(Us^2+Vs^2); Y2=2*Us*Vs/(Us^2+Vs^2)*X1-(Us^2-Vs^2)/(Us^2+Vs^2)*Y1 +2*Us*(Us*Pt1_2-Vs*Pt1_1)/(Us^2+Vs^2); ); tmp1=concat(tmp1,[[X2,Y2]]); ); tmp2=concat(tmp2,[tmp1]); ); PdL=concat(PdL,tmp2); ); if(Noflg<3, println("generate Reflectdata "+name); tmp1=[]; forall(PdL,tmp2, tmp=apply(tmp2,Pcrd(#)); tmp1=append(tmp1,tmp); ); if(length(tmp1)==1,tmp1=tmp1_1); tmp=name+"="+text(tmp1); parse(tmp); tmp1=text(plist); tmp1=replace(tmp1,"[","list("); tmp1=replace(tmp1,"]",")"); tmp=name+"=Reflectdata("+tmp1+","+text(symL)+")"; GLIST=append(GLIST,tmp); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); PdL; ); Mksegments():=Mksegments([]); Mksegments(options):=( //help:Mksegments(); regional(segstr,p,q,r,tmp1,tmp2,tmp3); forall(allsegments(),seg, str=text(inspect(seg,"definition")); tmp1=indexof(str,"("); tmp2=indexof(str,";"); tmp3=indexof(str,")"); p=substring(str,tmp1,tmp2-1); q=substring(str,tmp2,tmp3-1); Listplot([parse(p),parse(q)]); ); ); Mkcircles():=Mkcircles([]); Mkcircles(options):=( //help:Mkcircles(): regional(seg,cir,str,p,q,r,tmp1,tmp2,tmp3,tmp4); forall(allcircles(),cir, str=text(inspect(cir,"definition")); tmp1=indexof(str,"("); tmp2=indexof(str,";"); tmp3=indexof(str,")"); tmp4=indexof(str,";",tmp2+1); if(tmp4==0, p=substring(str,tmp1,tmp2-1); q=substring(str,tmp2,tmp3-1); Circledata([parse(p),parse(q)]); , p=substring(str,tmp1,tmp2-1); q=substring(str,tmp2,tmp4-1); r=substring(str,tmp4,tmp3-1); Circledata([parse(p),parse(q),parse(r)]); ); ); ); Makesciarg(arglist):=( regional(str,tmpstr); str=""; forall(arglist, if(isstring(#), tmpstr=Dq+#+Dq; , tmpstr=text(#); ); str=str+tmpstr+","; ); str=substring(str,0,length(str)-1); str; ); Setax(arglist):=( //help:Setax(["a","x","e","y","n","O","sw"]); //help:Setax([7,"nw"]); regional(tmp); tmp=Makesciarg(arglist); Com1st("Setax("+tmp+")"); ); Htickmark(arglist):=( //help:Htickmark([1,"1",2,"sw","2"]); regional(tmp); tmp=""; tmp=Makesciarg(arglist); Com2nd("Htickmark("+tmp+")"); ); Vtickmark(arglist):=( //help:Vtickmark([1,"1",2,"sw","2"]); regional(tmp); tmp=Makesciarg(arglist); Com2nd("Vtickmark("+tmp+")"); ); Drwxy():=( //help:Drwxy(); Com2nd("Drwxy()"); Addax("0"); ); Drwpt(pstr):=Drawpoint(pstr); Drawpoint(pstr):=( regional(tmp); println("Drwpt("+pstr+")"); if(isstring(pstr), tmp=pstr; , if(ispoint(pstr) & !islist(pstr_1),tmp=[pstr],tmp=pstr); tmp=text(tmp); tmp=substring(tmp,1,length(tmp)-1); ); Com2nd("Drwpt("+tmp+")"); ); Addax(param):=( //help:Addax(0); ADDAXES=text(param); ); Expr(Pt,Dr,St):=Expr([Pt,Dr,St]); Expr(list):=Expr(list,[]); Expr(list,options):=( //help:Expr([A,"e","f(x)=x^2"]); regional(Nj,Pos,Dir,Str,Off,Dmv,Xmv,Ymv,tmp,Noflg); Noflg=0; forall(options, if(indexof(#,"notex")>0, Noflg=1; ); ); Off=-4; Dmv=8; Nj=1; while(Nj+2<=length(list), Pos=text(list_Nj); Dir=list_(Nj+1); Str=list_(Nj+2); tmp=replace(Str,".xy",""); tmp=replace(tmp,".x","(1)"); Str=replace(tmp,".y","(2)"); if(indexof(Str,"`")>0, // tmp=Dq+",Assign('"+Str+"','`',Prime()))"; tmp=Dq+",Assign('"+Str+"'))"; // 15.02.22 , tmp=Dq+","+Dq+Str+Dq+")"; ); if(Noflg==0, Com2nd("Expr("+Pos+","+Dq+Dir+tmp); ); Nj=Nj+3; Xmv=0; Ymv=0; if(indexof(Dir,"n")>0, Ymv=Dmv; ); if(indexof(Dir,"s")>0, Ymv=-Dmv; ); if(indexof(Dir,"e")>0, Xmv=Dmv; ); if(indexof(Dir,"w")>0, Xmv=-Dmv; ); Str="$"+Str+"$"; drawtext(Pcrd(parse(Pos)),Str,offset->[Off+Xmv,Off+Ymv]); ); ); Letter(Pt,Dr,St):=Letter([Pt,Dr,St]); Letter(list):=Letter(list,[]); Letter(list,options):=( //help:Letter([C,"c","Graph of f(x)"]); regional(Nj,Pos,Dir,Str,Off,Dmv,Xmv,Ymv,tmp,Noflg); Noflg=0; forall(options, if(indexof(#,"notex")>0, Noflg=1; ); ); Off=-4; Dmv=8; Nj=1; while(Nj+2<=length(list), Pos=text(list_Nj); Dir=list_(Nj+1); Str=list_(Nj+2); tmp=replace(Str,".xy",""); tmp=replace(tmp,".x","(1)"); Str=replace(tmp,".y","(2)"); if(indexof(Str,"`")>0, // tmp=Dq+",Assign('"+Str+"','`',Prime()))"; tmp=Dq+",Assign('"+Str+"'))"; // 15.02.22 , tmp=Dq+","+Dq+Str+Dq+")"; ); if(Noflg==0, Com2nd("Letter("+Pos+","+Dq+Dir+tmp); ); Nj=Nj+3; Xmv=0; Ymv=0; if(indexof(Dir,"n")>0, Ymv=Dmv; ); if(indexof(Dir,"s")>0, Ymv=-Dmv; ); if(indexof(Dir,"e")>0, Xmv=Dmv; ); if(indexof(Dir,"w")>0, Xmv=-Dmv; ); drawtext(Pcrd(parse(Pos)),Str,offset->[Off+Xmv,Off+Ymv]); ); ); Letterrot(pt,dir,str):=Letterrot(pt,dir,0,0,str); Letterrot(pt,dir,movstr,str):=( //help:Letterrot(C,B-A,"AB"): //help:Letterrot(C,B-A,"tn","AB"): regional(tmov,nmov,tmp,tmp1,tmp2); tmp1=indexof(movstr,"t"); tmp2=indexof(movstr,"n"); if(tmp1>0, if(tmp2>0,tmp=tmp2-1,tmp=length(movstr)); tmov=parse(substring(movstr,tmp1,tmp)); , tmov=0; ); if(tmp2>0, nmov=parse(substring(movstr,tmp2,length(movstr))); , nmov=0; ); Letterrot(pt,dir,tmov,nmov,str); ); Letterrot(pt,dir,tmov,nmov,str):=( Letter([pt,"c",str],["notex"]); Com2nd("Letterrot("+pt+","+dir+","+tmov+","+nmov+",'"+str+"')"); ); Exprrot(pt,dir,str):=Exprrot(pt,dir,0,0,str); Exprrot(pt,dir,movstr,str):=( //help:Exprrot(C,B-A,"ab"): regional(tmov,nmov,tmp,tmp1,tmp2); tmp1=indexof(movstr,"t"); tmp2=indexof(movstr,"n"); if(tmp1>0, if(tmp2>0,tmp=tmp2-1,tmp=length(movstr)); tmov=parse(substring(movstr,tmp1,tmp)); , tmov=0; ); if(tmp2>0, nmov=parse(substring(movstr,tmp2,length(movstr))); , nmov=0; ); Exprrot(pt,dir,tmov,nmov,str); ); Exprrot(pt,dir,tmov,nmov,str):=( Expr([pt,"c",str],["notex"]); Com2nd("Exprrot("+pt+","+dir+","+tmov+","+nmov+",'"+str+"')"); ); Putpoint(name,Pt):=Putpoint(name,Pt,Pt); Putpoint(name,Ptinit,Pt):=( //help:Putpoint("A",[1,2],[1,A.y]); regional(ptstr); ptstr=apply(allpoints(),text(#)); if(!contains(ptstr,name), createpoint(name,Pcrd([Ptinit_1,Ptinit_2])); , ptstr=name+".xy="+text(Pcrd(Pt)); parse(ptstr); ); ); Bowname(str):=Bowname("c",str); Bowname(dir,str):=( Expr([BOWMIDDLE,dir,str]); ); Bownamerot(bwdata,str):=Bownamerot(bwdata,0,0,str,1); Bownamerot(bwdata,str,updown):=Bownamerot(bwdata,0,0,str,updown); Bownamerot(bwdata,tmov,nmov,str):=Bownamerot(bwdata,tmov,nmov,str,1); Bownamerot(bwdata,tmov,nmov,str,updown):=( regional(bdata,tmp); tmp=MeasureDepth(bwdata); if(tmp==1,bdata=[bwdata],bdata=bwdata); if(length(bdata)>1, tmp=Ptend(bdata_2)-Ptstart(bdata_1); , tmp=Ptend(bdata_1)-Ptstart(bdata_1); ); if(updown<0,tmp=-tmp); Exprrot(BOWMIDDLE,tmp,tmov,nmov,str); ); Bezierpt(t,ptlist,ctrlist):=( regional(flg3,p0,p1,p2,p3,p4,p5,p6,p7,p8,p9); p0=ptlist_1; p3=ptlist_2; p1=ctrlist_1; if(length(ctrlist)==1, p2=p3; flg3=0; , p2=ctrlist_2; flg3=1; ); if(length(p0)<3, // 15.02.08 p0=Lcrd(p0); p3=Lcrd(p3); p1=Lcrd(p1); p2=Lcrd(p2); ); p4=(1-t)*p0+t*p1; p5=(1-t)*p1+t*p2; p6=(1-t)*p2+t*p3; p7=(1-t)*p4+t*p5; p8=(1-t)*p5+t*p6; p9=(1-t)*p7+t*p8; if(flg3==0,p7,p9); ); Bezier(ptctrlist):=BezierCurve(ptctrlist_3,ptctrlist_1,ptctrlist_2,[]); Bezier(ptctrlist,options):=BezierCurve(ptctrlist_3,ptctrlist_1,ptctrlist_2,options); Bezier(nm,ptlist,ctrlist):=BezierCurve(nm,ptlist,ctrlist,[]); Bezier(nm,ptlist,ctrlist,options):=BezierCurve(nm,ptlist,ctrlist,options); BezierCurve(nm,ptlist,ctrlist):=BezierCurve(nm,ptlist,ctrlist,[]); BezierCurve(nm,ptlist,ctrlistorg,options):=( //help:Bezier("1",[A,D],[B,C]); regional(name,Ltype,Noflg,opstr,opcindy,Num, tmp,tmp1,tmp2,ii,st,out,list); name="bz"+nm; tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); Num=10; tmp1=tmp_5; forall(tmp1, // 14.12.31 if(substring(#,0,1)=="N", tmp2=indexof(#,"="); Num=parse(substring(#,tmp2,length(#))); opstr=opstr+","+Dq+#+Dq; ); ); ctrlist=[]; // 14.12.31 if(length(ctrlistorg)==length(ptlist)-1, forall(ctrlistorg, if(MeasureDepth(#)==0,tmp=[#],tmp=#); ctrlist=append(ctrlist,tmp); ); , forall(1..(length(ptlist)-1),ii, tmp=ctrlistorg_((2*ii-1)..(2*ii)); ctrlist=append(ctrlist,tmp); ); ); if(!islist(Num), Num=apply(ctrlist,Num); ); list=[]; forall(1..(length(ptlist)-1),ii, tmp1=ptlist_(ii..(ii+1)); tmp2=ctrlist_ii; if(ii==1,st=0,st=1); forall(st..Num_ii, tmp=Bezierpt(#/Num_ii,tmp1,tmp2); list=append(list,tmp); ); ); if(Noflg<3, println("generate Bezier "+name); out=apply(list,Pcrd(#)); tmp=name+"="+text(out); parse(tmp); tmp1=text(ptlist); tmp1="list("+substring(tmp1,1,length(tmp1)-1)+")"; tmp2=text(ctrlist); tmp2="list("+substring(tmp2,1,length(tmp2)-1)+")"; GLIST=append(GLIST,name+"=Bezier("+tmp1+","+tmp2+opstr+")"); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); list; ); Readcsvsla(fname):=Readplotdigdata(fname,[]); Readcsvsla(fname,options):=Readplotdigdata(fname,options); Readplotdigdata(fname):=Readplotdigdata(fname,[]); Readplotdigdata(fname,options):=( regional(fsc,mv,cmdall,dataL,nd,npt,ptdata,ii,tmp,tmp1,tmp2,tmp3); tmp=Divoptions(options); tmp1=tmp_6; sc=1;//10; mv=[0,0];//[5,5]; forall(tmp1, if(!islist(#),sc=#,mv=#); ); if(indexof(fname,".")>0, tmp=load(fname); , tmp=load(fname+".txt"); ); cmdall=tokenize(tmp,"//"); dataL=[]; forall(2..length(cmdall),ii, tmp1=parse("["+cmdall_ii+"]"); dataL=append(dataL,tmp1); ); if(length(dataL_length(dataL))<2, dataL=dataL_(1..(length(dataL)-1)); ); nd=length(dataL_1)/2; npt=length(dataL); ptdata=[]; forall(1..nd,ii, tmp3=[]; forall(1..npt, tmp1=dataL_#_(2*ii-1); tmp2=dataL_#_(2*ii); if(isreal(tmp1), tmp3=append(tmp3,[tmp1,tmp2]); ); ); ptdata=append(ptdata,tmp3); ); tmp1=[]; forall(ptdata, tmp=#/sc; tmp=Translatedata("1",[tmp],-mv,["nodata"]); tmp1=append(tmp1,tmp); ); ptdata=tmp1; ptdata; ); Putbezierdata(name,ptL):=Putbezierdata(name,ptL,[]); Putbezierdata(name,ptL,options):=( regional(psize,Deg,tmp,tmp1,tmp2,pts,ctrs); tmp=Divoptions(options); psize=3; Deg=3; tmp1=tmp_5; forall(tmp1, if(substring(#,0,1)=="D", tmp=indexof(#,"="); Deg=parse(substring(#,tmp,length(#))); ); if(substring(#,0,1)=="S", tmp=indexof(#,"="); psize=parse(substring(#,tmp,length(#))); ); ); pts=[]; ctrs=[]; forall(1..length(ptL), tmp=ptL_#; if(ispoint(tmp), tmp1=text(tmp); , tmp1=name+text(#); Putpoint(tmp1,tmp,parse(tmp1+".xy")); ); inspect(parse(tmp1),"ptsize",psize); pts=append(pts,parse(tmp1)); inspect(parse(tmp1),"color",4); if(#>1, if(Deg==3, tmp=(2*ptL_(#-1)+ptL_#)/3; tmp1=name+"p"+text(#-1); Putpoint(tmp1,tmp,parse(tmp1+".xy")); inspect(parse(tmp1),"labeled",false); //15.01.22 Letter([parse(tmp1),"ne",tmp1],["notex"]); //15.01.22 inspect(parse(tmp1),"ptsize",psize); inspect(parse(tmp1),"color",3); tmp=(ptL_(#-1)+2*ptL_#)/3; tmp2=name+"q"+text(#-1); Putpoint(tmp2,tmp,parse(tmp2+".xy")); inspect(parse(tmp2),"labeled",false); //15.01.22 Letter([parse(tmp2),"ne",tmp2],["notex"]); //15.01.22 inspect(parse(tmp2),"ptsize",psize); inspect(parse(tmp2),"color",3); ctrs=append(ctrs,[parse(tmp1),parse(tmp2)]); , tmp=(ptL_(#-1)+ptL_#)/2; tmp1=name+"p"+text(#-1); Putpoint(tmp1,tmp,parse(tmp1+".xy")); inspect(parse(tmp1),"labeled",false); //15.01.22 Letter([parse(tmp1),"ne",tmp1],["notex"]); //15.01.22 inspect(parse(tmp1),"ptsize",psize); inspect(parse(tmp1),"color",3); ctrs=append(ctrs,[parse(tmp1)]); ); ); ); [pts,ctrs,name]; ); Mkbezierptcrv(ptdata):=Mkbezierptcrv(ptdata,[]); Mkbezierptcrv(ptdata,options):=( //help:Mkbezierptcrv([A,B,C,D]); //help:Mkbezierptcrv([[A,B],[C,D]]); // global BezierNumber regional(ptlist,Out,tmp,tmp1,tmp2); if(isstring(ptdata), ptlist=Readcsvsla(ptdata,options); , ptlist=ptdata; ); if(MeasureDepth(ptlist)==1,ptlist=[ptlist]); Out=[]; forall(1..length(ptlist), tmp=floor((BezierNumber-1)/26);// 15.02.23 if(tmp==0,tmp="",tmp=text(tmp)); tmp2=mod(BezierNumber,26); if(tmp2==0,tmp2=26); tmp1=unicode(text(96+tmp2),base->10)+tmp;// 15.03.11 tmp2=Putbezierdata(tmp1,ptlist_#,options); Bezier(tmp2,options); BezierNumber=BezierNumber+1; Out=append(Out,tmp2_(1..2)); ); Out; ); Mkbeziercrv(nm,ptctrL):=Mkbeziercrv(nm,ptctrL,[]); Mkbeziercrv(nm,ptctrL,options):=( //help:Mkbeziercrv("1",[[A,B,C],[[P,Q],[R,S],T]]); regional(ptctrLL,name,ptlist,ctrlist,tmp,tmp1,tmp2); if(MeasureDepth(ptctrL)==2,ptctrLL=[ptctrL],ptctrLL=ptctrL); forall(1..length(ptctrLL), name=nm+text(#); ptlist=ptctrLL_#_1; ctrlist=ptctrLL_#_2; Bezier(name,ptlist,ctrlist,options); ); ); CRspline(nm,ptL):=CRspline(nm,ptL,[]); CRspline(nm,ptL,options):=( // Catmull-Rom spline //help:CRspline("1",[A,B,C,A]); regional(name,ptlist,ctrpts,eqL,opcindy,c,v,tmp,tmp1,tmp2,ctrlist,cflg); name="crsp"+nm; if(MeasureDepth(ptL)==1,tmp=[ptL],tmp=ptL); ptlist=tmp_1; if(length(tmp)==1, cflg=1; , cflg=0; ctrpts=tmp_2; ); c=1/6; tmp=Divoptions(options); eqL=tmp_5; opcindy=tmp_length(tmp); // 15.03.05 forall(eqL, if(substring(#,0,1)=="R", tmp2=indexof(#,"="); c=parse(substring(#,tmp2,length(#))); ); ); ctrlist=[]; forall(1..(length(ptlist)-1), if(#==1, if(cflg==0, tmp1=ctrpts_1; , v=ptlist_2-ptlist_(length(ptlist)-1); tmp1=ptlist_#+c*v; ); , v=ptlist_(#+1)-ptlist_(#-1); tmp1=ptlist_#+c*v; ); if(#==length(ptlist)-1, if(cflg==0, tmp2=ctrpts_2; , v=ptlist_2-ptlist_#; tmp2=ptlist_(#+1)-c*v; ); , v=ptlist_(#+2)-ptlist_#; tmp2=ptlist_(#+1)-c*v; ); tmp=select(options,indexof(text(#),"->")>0); tmp=append(tmp,"notex"); //15.03.05 Pointdata(name+text(#),[tmp1,tmp2],tmp); ctrlist=append(ctrlist,[tmp1,tmp2]); ); Bezier(nm,ptlist,ctrlist,options); ); Beziersmooth(nm,ptL):=Bzspline(nm,ptL,[]); Beziersmooth(nm,ptL,options):=Bzspline(nm,ptL,options); Bzspline(nm,ptL):=Bzspline(nm,ptL,[]); Bzspline(nm,ptL,options):=( // smooth bezier regional(name,Eps,pt,pt1,pt2,pt3,npt,lstr, tmp,tmp1,tmp2,cflg,ctrlist); name="bzsp"+nm; Eps=10^(-3); if(|ptL_1-ptL_length(ptL)|1 % cflg==1, tmp1="c"+text(#); inspect(parse(tmp1),"alpha",0.3); ); tmp1="C"+text(#)+"p"; tmp2="C"+text(#)+"q"; inspect(parse(tmp1),"ptsize",3); inspect(parse(tmp1),"color",3); inspect(parse(tmp2),"ptsize",3); inspect(parse(tmp2),"color",3); tmp=[parse(tmp1),parse(tmp2)]; ctrlist=append(ctrlist,tmp); ); Bezier(nm,ptL,ctrlist,options); [ptL,ctrlist]; ); Beziersym(nm,ptL):=Bzsspline(nm,ptL,[]); Beziersym(nm,ptL,options):=Bzsspline(nm,ptL,options); Bzsspline(nm,ptL):=Bzsspline(nm,ptL,[]); Bzsspline(nm,ptL,options):=( // smooth bezier with symmetric control points regional(name,Eps,pt,pt1,pt2,pt3,npt,lstr, tmp,tmp1,tmp2,cflg,ctrlist); name="bzssp"+nm; Eps=10^(-3); if(|ptL_1-ptL_length(ptL)|Eps, pcl=list; pcl_1=2*list_1-list_2; pcl_k=2*list_k-list_(k-1); , pcl=concat(list,[list_2]); ); ctrl=apply(2..(length(pcl)-1),[pcl_#]); ptl=apply(1..(length(pcl)-1),(pcl_#+pcl_(#+1))/2); [ptl,ctrl]; ); Bspline(nm,ctrL):=Bspline(nm,ctrL,[]); Bspline(nm,ctrL,options):=( regional(list,tmp); list=Listbspline2bz(ctrL); tmp=BezierCurve("b"+nm,list_1,list_2,options); tmp; ); MeetCurve(Crv,Xorg,Yorg):=( regional(Cv,tmp,tmp1,tmp2,X0,Y0,x1,x2,y1,y2,Ylist,Ban,Tate); if(isstring(Crv),Cv=parse(Crv),Cv=Crv); if(MeasureDepth(Cv)==2,Cv=Cv_1); Cv=apply(Cv,LLcrd(#)); // 14.12.18 while(length(Cv)==1, Cv=Cv_1; ); Cv=apply(Cv,Lcrd(#)); tmp1=min(apply(Cv,#_1)); tmp2=max(apply(Cv,#_1)); if(isstring(Xorg),X0=parse(Xorg),X0=Xorg); if(isstring(Yorg),Y0=parse(Yorg),Y0=Yorg); if(X0tmp2, X0=tmp2; ); ); tmp1=select( 1..(length(Cv)-1),Cv_#_1<=X0 & X0<=Cv_(#+1)_1); tmp2=select( 1..(length(Cv)-1),Cv_#_1>=X0 & X0>=Cv_(#+1)_1); tmp2=remove(tmp2,common(tmp2,tmp1)); Ban=concat(tmp1,tmp2); Tate=select(Ban, abs(Cv_#_1-Cv_(#+1)_1)<= 10^(-2)*abs(Cv_#_2-Cv_(#+1)_2) ); Ban=remove(Ban,Tate); Ylist=[]; forall(Ban, tmp=Cv_#; x1=tmp_1; y1=tmp_2; tmp=Cv_(#+1); x2=tmp_1; y2=tmp_2; tmp=((x2-X0)*y1+(X0-x1)*y2)/(x2-x1); Ylist=append(Ylist,tmp); ); forall(Tate, tmp=Cv_#; x1=tmp_1; y1=tmp_2; tmp=Cv_(#+1); x2=tmp_1; y2=tmp_2; tmp1=min([y1,y2]); tmp2=max([y1,y2]); if(Y0tmp2, tmp=tmp2; , tmp=Y0; ); ); Ylist=append(Ylist,tmp); ); tmp=sort(Ylist,abs(#_1-Y0)); [X0,tmp_1]; ); PutonLine(name,p1,p2):=PtonLine(name,p1,p2,[]); PutonLine(name,p1,p2,options):=PtonLine(name,p1,p2,options); PtonLine(name,p1,p2):=PtonLine(name,p1,p2,[]); PtonLine(name,p1,p2,options):=( //help:PtonLine("C",pA,pB); regional(par,dx,dy,tmp,tmp1,tmp2); par=0.5; tmp=Divoptions(options); if(length(tmp_6)>0, par=tmp_6_1; ); dx=p2.x-p1.x; dy=p2.y-p1.y; tmp1=(1-par)*p1+par*p2; if(abs(dx)>abs(dy), tmp=name+".x"; tmp2="["+tmp+",dy/dx*("+tmp+"-p1.x)+p1.y]"; Putpoint(name,tmp1,parse(tmp2)); , if(abs(dy)>0, tmp=name+".y"; tmp2="[dx/dy*("+tmp+"-p1.y)+p1.x,"+tmp+"]"; Putpoint(name,tmp1,parse(tmp2)); , tmp2=p1.xy; Putpoint(name,tmp1,tmp2); ); ); ); PutonSeg(name,p1,p2):=PtonSeg(name,p1,p2,[]); PutonSeg(name,p1,p2,options):=PtonSeg(name,p1,p2,options); PtonSeg(name,p1,p2):=PtonSeg(name,p1,p2,[]); PtonSeg(name,p1,p2,options):=( //help:PtonSeg("C",pA,pB); regional(par,dx,dy,p,tmp,tmp1,tmp2); par=0.5; tmp=Divoptions(options); if(length(tmp_6)>0, par=tmp_6_1; ); PtonLine(name,p1,p2); dx=p2.x-p1.x; dy=p2.y-p1.y; p=parse(name); if(abs(dx)>abs(dy) & (p.x-p1.x)*(p.x-p2.x)>0, if(|p-p1|<|p-p2|, parse(name+".xy=p1.xy"); , parse(name+".xy=p2.xy"); ); ); if(abs(dx)0, if(|p-p1|<|p-p2|, parse(name+".xy=p1.xy"); , parse(name+".xy=p2.xy"); ); ); ); PutonCurve(pn,crv):=PutonCurve(pn,crv,[]); PutonCurve(pn,crv,options):=( //help:PutonCurve("A","gr1"); regional(Pmt,pstr,optionL,leftlim,rightlim,tmp,tmp1,Flg); if(!islist(options),optionL=[options],optionL=options); leftlim=XMIN; rightlim=XMAX; Flg=0; forall(optionL, if(Flg==0, leftlim=#; Flg=Flg+1; , rightlim=#; ); ); Pmt=MeetCurve(crv,leftlim,0); pstr=apply(allpoints(),text(#)); if(!contains(pstr,pn), createpoint(pn,Pcrd(Pmt)); , tmp1=parse(pn+".x"); if(tmp1< leftlim % tmp1>rightlim, if(tmp1< leftlim,tmp= leftlim, tmp=rightlim); Pmt=MeetCurve(crv,text(tmp),pn+".y"); , Pmt=MeetCurve(crv,pn+".x",pn+".y"); ); ptstr=pn+".xy="+text(Pcrd(Pmt))+";"; parse(ptstr); ); println("Put "+pn+" on Curve "+text(crv)); ); CrossPoint(name,Crv1,Crv2,range):=( regional(Mx1,Mx2,Mx3,tmp,Crs1,Crs2,Crs3,Crs4,df1,df2); Mx1=range_1; Mx2=range_2; repeat(15, Mx3=(Mx1+Mx2)/2; Crs1=MeetCurve(Crv1,Mx1,0); Crs2=MeetCurve(Crv2,Mx1,0); Crs3=MeetCurve(Crv1,Mx3,0); Crs4=MeetCurve(Crv2,Mx3,0); df1=Crs1_2-Crs2_2; df2=Crs3_2-Crs4_2; if((df1>0 & df2>0) % (df1<0 & df2<0), Mx1=Mx3; , Mx2=Mx3; ); ); Putpoint(name,Crs1); ); Setscaling(sc):=( //help:Setscaling(3); SCALEX=1; SCALEY=sc; Com0th("Setscaling("+sc+")"); Setwindow(); ); Putpttable(n,m,xsize,ysize,upleft):=( regional(tmp1,tmp2); tmp1=apply(1..m,ysize/m); tmp2=apply(1..n,xsize/n); Putpttable(tmp1,tmp2,upleft); [m,n]; ); Putpttable(xLst,yLst,upleft):=( regional(ul,n,m,xsize,ysize,tmp,tmp1,tmp2,tmp3); ul=upleft/10; n=length(xLst); m=length(yLst); xsize=sum(xLst); ysize=sum(yLst); if(!ispoint(R0), Putpoint("R0",ul); Putpoint("C0",ul); ); inspect(R0,"ptsize",3); inspect(R0,"labeled",false); inspect(C0,"ptsize",3); inspect(C0,"labeled",false); drawtext(R0.xy-[0.5,0.1],"R0"); drawtext(C0.xy-[0.2,-0.2],"C0"); forall(1..m, tmp1=parse("R"+text(#-1)+".y")-yLst_#/10; tmp2="R"+text(#); tmp=[0,tmp1]; Putpoint(tmp2,tmp,[R0.x,parse(tmp2+".y")]); inspect(parse(tmp2),"ptsize",3); inspect(parse(tmp2),"labeled",false); tmp=[0.5,0.1]; drawtext(parse(tmp2)-tmp,tmp2); ); forall(1..n, tmp1=parse("C"+text(#-1)+".x")+xLst_#/10; tmp2="C"+text(#); tmp=[tmp1,C0.y]; Putpoint(tmp2,tmp,[parse(tmp2+".x"),C0.y]); inspect(parse(tmp2),"ptsize",3); inspect(parse(tmp2),"labeled",false); tmp=[0.2,-0.2]; drawtext(parse(tmp2)-tmp,tmp2); ); forall(0..(m-1), tmp1=parse("R"+text(#)); tmp2=parse("R"+text(#+1)); tmp=(tmp1.xy+tmp2.xy)/2; drawtext(tmp-[1.2,0.1],text(abs(tmp1.y-tmp2.y)*10)); ); forall(1..n, tmp1=parse("C"+text(#-1)); tmp2=parse("C"+text(#)); tmp=(tmp1.xy+tmp2.xy)/2; drawtext(tmp+[-0.2,0.5],text((tmp2.x-tmp1.x)*10)); ); [m,n]; ); Maketable(n,m):=( regional(tmp,tmp1,tmp2,tmp3, xsize,ysize,jj,kk,vx,vy,vtx,hseg,vseg); tmp="C"+text(n)+".x"; xsize=parse(tmp); tmp="R"+"0"+".y"; ysize=parse(tmp); vx=[]; vy=[]; forall(0..m, tmp="R"+text(#)+".y"; vy=append(vy,parse(tmp)); ); forall(0..n, tmp="C"+text(#)+".x"; vx=append(vx,parse(tmp)); ); vtx=[]; forall(0..m,kk, tmp3=[]; tmp1=vy_(kk+1); forall(0..n,jj, tmp2=[vx_(jj+1),tmp1]; tmp="c"+text(jj)+"r"+text(kk)+"="+tmp2; parse(tmp); Defvar("c"+text(jj)+"r"+text(kk),tmp2); tmp3=append(tmp3,tmp2); ); vtx=append(vtx,tmp3); ); hseg=[]; forall(0..m,kk, forall(1..n,jj, tmp1="c"+text(jj-1); tmp2="c"+text(jj); tmp3="r"+text(kk)+tmp1+tmp2; tmp1=tmp1+"r"+text(kk); tmp2=tmp2+"r"+text(kk); tmp=tmp3+"=["+tmp1+","+tmp2+"];"; parse(tmp); hseg=append(hseg,tmp3); ); ); vseg=[]; forall(0..n,jj, forall(1..m,kk, tmp1="r"+text(kk-1); tmp2="r"+text(kk); tmp3="c"+text(jj)+tmp1+tmp2; tmp1="c"+text(jj)+tmp1; tmp2="c"+text(jj)+tmp2; tmp=tmp3+"=["+tmp1+","+tmp2+"];"; parse(tmp); vseg=append(vseg,tmp3); ); ); tmp1=concat(hseg,vseg); tmp1; ); Settable(sepoint):=Settable(c0r0,sepoint); Settable(arg1,arg2):=( regional(tmp1,tmp2,nwpoint,sepoint,Eps); Eps=10^(-3); Addax("0"); if(ispoint(arg1) % islist(arg1), nwpoint=Lcrd(arg1); sepoint=Lcrd(arg2); tmp1=[nwpoint_1,sepoint_1]; tmp2=[nwpoint_2,sepoint_2]; tmp1=[min(tmp1)-Eps,max(tmp1)+Eps]; tmp2=[min(tmp2)-Eps,max(tmp2)+Eps]; Setwindow(tmp1,tmp2); , Setwindow([0-Eps,arg1+Eps],[0-Eps,arg2+Eps]); ); ); Tabledata(xLst,yLst):=Tabledata(xLst,yLst,[]); Tabledata(xLst,yLst,options):=( regional(tmp,nRC,upleft); tmp=sum(yLst); upleft=[0,tmp]; tmp=Divoptions(options); if(length(tmp_6)>0, upleft=tmp_6_1; ); nRC=Putpttable(xLst,yLst,upleft); Tb=Maketable(nRC_2,nRC_1); tmp=name+"="+text(Tb); parse(tmp); forall(Tb, Listplot(#,parse(#),options); ); tmp=parse("c"+text(nRC_2)+"r"+text(nRC_1)); Settable(tmp); Tb; ); Tabledata(n,m,xsize,ysize):=Tabledata(n,m,xsize,ysize,[]); Tabledata(n,m,xsize,ysize,options):=( regional(tmp1,tmp2,Tb,nm,xLst,yLst,rmvL); if(!isstring(n), tmp1=apply(1..m,ysize/m); tmp2=apply(1..n,xsize/n); Tb=Tabledata(tmp2,tmp1,options); Tb; , nm=n; xLst=m; yLst=xsize; rmvL=ysize; Tabledata(nm,xLst,yLst,rmvL,[]); ); ); Tabledata(nm,xLst,yLst,rmvL,options):=( //help:Tabledata("",xLst,yLst,rmvL): regional(Tb,name,tmp); name="tb"+nm; Tb=Tabledata(xLst,yLst,append(options,"nodata")); Tablesegrmv(Tb,rmvL,options); tmp=name+"=Tb"; parse(tmp); Tb; ); Tabledata(nm,n,m,xsize,ysize,rmvL):= Tabledata(nm,n,m,xsize,ysize,rmvL,[]); Tabledata(nm,n,m,xsize,ysize,rmvL,options):=( regional(Tb,name,tmp,xLst,yLst); name="tb"+nm; xLst=apply(1..n,xsize/n); yLst=apply(1..m,ysize/m); Tabledata(nm,xLst,yLst,rmvL,options) ); Tablesegdiv(segstr):=( regional(tmp,tmp1,tmp2,tmp3,head,out); if(substring(segstr,0,1)=="r", tmp=indexof(segstr,"c"); head=substring(segstr,0,tmp-1); tmp3=substring(segstr,tmp,length(segstr)); tmp=indexof(tmp3,"c"); tmp1=parse(substring(tmp3,0,tmp-1)); tmp2=parse(substring(tmp3,tmp,length(tmp3))); out=[]; forall(tmp1..(tmp2-1), tmp=head+"c"+text(#)+"c"+text(#+1); out=append(out,tmp); ); , tmp=indexof(segstr,"r"); head=substring(segstr,0,tmp-1); tmp3=substring(segstr,tmp,length(segstr)); tmp=indexof(tmp3,"r"); tmp1=parse(substring(tmp3,0,tmp-1)); tmp2=parse(substring(tmp3,tmp,length(tmp3))); out=[]; forall(tmp1..(tmp2-1), tmp=head+"r"+text(#)+"r"+text(#+1); out=append(out,tmp); ); ); out; ); Tablesegjoin(segstr):=( regional(tmp,tmp1,tmp2,out); tmp=Tablesegdiv(segstr); tmp1=parse(tmp_1); tmp2=parse(tmp_length(tmp)); out="["+tmp1_1+","+tmp2_2+"]"; parse(out); ); Tableseg(strL):=Tableseg(strL,[]); Tableseg(strL,options):=( regional(name,out,tmp,tmp1); out=[]; forall(strL, tmp=Tablesegjoin(#); Listplot(#,tmp,options); out=append(out,tmp); ); println("generate tableseg : "+strL); out; ); Tablesegrmv(Tbdata,strL):=Tablesegrmv(Tbdata,strL,[]); Tablesegrmv(Tbdata,strL,options):=( regional(out,tmp); out=Tbdata; forall(strL, tmp=Tablesegdiv(#); out=remove(out,tmp); ); forall(out, Listplot(#,parse(#),options); ); println("remove tableseg : "+strL); out; ); ChangeTablestyle(nameL,style):=( //help:ChangeTablestyle(["r0c0c3"],["da"]); regional(nmL,name,tmp); if(islist(nameL),nmL=nameL,nmL=[nameL]); forall(nmL,name, tmp=Tablesegdiv(name); tmp=apply(tmp,"sg"+#); Changestyle(tmp,style); ); ); Findcell(pos1,pos2):=Findcell("",pos1,pos2); Findcell(Tbdata,pos1,pos2):=( //help:Findcell("c0r0","c2r1"); regional(tmp1,tmp2,posnw,posse,ctr,dx,dy); if(isstring(pos1), posnw=parse(pos1); posse=parse(pos2); , if(islist(pos1), posnw=pos1; posse=pos2; , tmp1="c"+text(pos1-1)+"r"+text(pos2-1); tmp2="c"+text(pos1)+"r"+text(pos2); posnw=parse(tmp1); posse=parse(tmp2); ); ); ctr=(posnw+posse)/2; dx=abs(posse_1-ctr_1); dy=abs(posnw_2-ctr_2); [ctr,dx,dy]; ); Putcell(pos1,pos2,dir,lttr):=Putcell("",pos1,pos2,dir,lttr); Putcell(Tbdata,pos1,pos2,dir,lttr):=( //help:Putcell("c0r0","c2r1","lt","abc"); //help:Putcell(2,3,"c","xyz"); regional(tmp,tmp1,tmp2,posnw,posse, posdir,posstr,ctr,dx,dy); tmp=Findcell(Tbdata,pos1,pos2); ctr=tmp_1; dx=tmp_2; dy=tmp_3; posdir=ctr; posstr=dir; if(indexof(dir,"b")>0, posdir_2=posdir_2-dy; posstr=replace(posstr,"b","n"); ); if(indexof(dir,"t")>0, posdir_2=posdir_2+dy; posstr=replace(posstr,"t","s"); ); if(indexof(dir,"l")>0, posdir_1=posdir_1-dx; posstr=replace(posstr,"l","e"); ); if(indexof(dir,"r")>0, posdir_1=posdir_1+dx; posstr=replace(posstr,"r","w"); ); Letter(posdir,posstr,text(lttr)); ); Putcellexpr(pos1,pos2,dir,ex):=Putcellexpr("",pos1,pos2,dir,ex); Putcellexpr(Tbdata,pos1,pos2,dir,ex):=( //help:Putcellexpr("c0r0","c2r1","lt","abc"); //help:Putcellexpr(2,3,"c","\sin x"); Putcell(Tbdata,pos1,pos2,dir,"$"+text(ex)+"$"); ); Putrow(nrow,dir,lttrL):=Putrow("",nrow,dir,lttrL); Putrow(Tbdata,nrow,dir,lttrL):=( //help:Putrow(1,"c",["x","y","z"]); regional(tmp,tmp1,mcol); mcol=length(lttrL); forall(1..mcol, Putcell(Tbdata,#,nrow,dir,lttrL_#); ); ); Putrowexpr(nrow,dir,exL):=Putrowexpr("",nrow,dir,exL); Putrowexpr(Tbdata,nrow,dir,exL):=( //help:Putrowexpr(2,"r",["x","y","z"]); regional(lttrL); lttrL=apply(exL,"$"+#+"$"); Putrow(Tbdata,nrow,dir,lttrL); ); PutcoL(mcol,dir,lttrL):=PutcoL("",mcol,dir,lttrL); PutcoL(Tbdata,mcol,dir,lttrL):=( //help:PutcoL(1,"c",["x","y","z"]); regional(tmp,tmp1,nrow); nrow=length(lttrL); forall(1..nrow, Putcell(Tbdata,mcol,#,dir,lttrL_#); ); ); PutcoLexpr(mcol,dir,exL):=PutcoLexpr("",mcol,dir,exL); PutcoLexpr(Tbdata,mcol,dir,exL):=( //help:PutcoLexpr(2,"r",["x","y","z"]); regional(lttrL); lttrL=apply(exL,"$"+#+"$"); PutcoL(Tbdata,mcol,dir,lttrL); ); Setwindow():=( regional(tmp,tmp1,tmp2); if((ispoint(SW) & ispoint(NE)), tmp1=Lcrd(SW); tmp2=Lcrd(NE); XMIN=tmp1_1; XMAX=tmp2_1; YMIN=tmp1_2; YMAX=tmp2_2; , // XMIN=-5; XMAX=5; // YMIN=Lcrdy(-5); YMAX=Lcrdy(5); createpoint("SW",Pcrd([XMIN,YMIN])); createpoint("NE", Pcrd([XMAX,YMAX])); ); println("Setwindow(["+XMIN+","+XMAX+"],["+YMIN+","+YMAX+"])"); layer(KETPICLAYER); autoclearlayer(KETPICLAYER,true); drawpoly([Pcrd([XMIN,YMIN]), Pcrd([XMAX,YMIN]), Pcrd([XMAX,YMAX]),Pcrd([XMIN,YMAX])],color->[1,1,1]); ); Setwindow(xrange,yrange):=( //help:Setwindow([2,3],[-1,1]); XMIN=xrange_1; XMAX=xrange_2; YMIN=yrange_1; YMAX=yrange_2; // Setwindow(); ); Sciform(list):=( regional(plotlist,comp,pos,out,strL,tmp,tmp1,tmp2,tmp3,Nj); plotlist=Flatten([list]); out=replace(plotlist_1,".xy",""); out=replace(out,".x","(1)"); out=replace(out,".y","(2)"); if(length(plotlist)==1, comp=[]; forall(1..length(out), comp=append(comp,substring(out,#-1,#)); ); out=""; pos=0; forall(comp, if(#!="'", out=out+#; , if(pos==0, tmp=indexof(out,"Assign("); if(substring(out,length(out)-7,length(out))=="Assign(", out=out+"'"; pos=1; , out=out+"Assign('"; pos=2; ); , if(pos==2, out=out+"')"; , out=out+"'"; ); pos=0; ); ); ); , forall(2..length(plotlist), comp=plotlist_#; if(isstring(comp), pos=indexof(comp,"Assign("); if(pos>0, comp=substring(comp,6,length(comp)); ); out=out+"Assign("; comp=replace(comp,".xy",""); comp=replace(comp,".x","(1)"); comp=replace(comp,".y","(2)"); out=out+"'"+comp+"'"; out=out+"),"; ); if(islist(comp), forall(comp, out=out+"'"+#+"',"; ); ); ); if(length(plotlist)>1, out=substring(out,0,length(out)-1); out=out+");"; ); ); pos=[]; forall(1..length(out), tmp=indexof(substring(out,#-1,length(out)),"Assign"); if(tmp>0, tmp1=#-1+tmp; if(length(pos)==0, pos=[tmp1]; , if(pos_length(pos)0, strL=[]; Nj=0; forall(pos, tmp=substring(out,Nj,#-1); strL=append(strL,tmp); Nj=#-1; ); strL=append(strL,substring(out,Nj,length(out))); out=""; forall(strL, if(indexof(#,"Assign")==0, out=out+#; , tmp=indexof(#,"('"); tmp1=indexof(#,"')"); tmp2=substring(#,tmp+1,tmp1-2); tmp3=substring(#,tmp1-2,length(#)); if(indexof(tmp2,"=")==0, out=out+#; , tmp=substring(tmp2,0,indexof(tmp2,"=")); out=out+"'"+tmp+"'+"+"Assign('"; tmp=substring(tmp2,indexof(tmp2,"="),length(tmp2)); out=out+tmp+tmp3; ); ); ); ); out; ); Defvar(varstr):=( regional(name,value,tmp,tmp1); parse(varstr); tmp=indexof(varstr,"="); name=substring(varstr,0,tmp-1); value=substring(varstr,tmp,length(varstr)); value=parse(value); tmp1=select(1..length(VLIST),VLIST_#_1==name+"="); if(length(tmp1)>0, tmp=tmp1_1; VLIST_tmp=[name+"=",value]; , VLIST=prepend([name+"=",value],VLIST); ); ); Defvar(name,value):=( //help:Defvar("a",0.3); regional(tmp,tmp1); if(islist(value), tmp1="["; forall(value, tmp1=tmp1+format(#,5)+","; ); tmp1=substring(tmp1,0,length(tmp1)-1)+"]"; , tmp1=format(value,5); ); tmp=name+"="+tmp1; // 15.02.06 parse(tmp); VLIST=select(VLIST,#_1!=name+"="); // 15.02.08 VLIST=prepend([name+"=",value],VLIST); ); Iftosci(str):=( regional(tmo,tmp1,Out,Pflg,Iflg,Cflg,repL); repL=[]; Pflg=0;Iflg=0; forall(1..length(str), if(substring(str,#-1,#+2)=="if(", Iflg=Iflg+1; Cflg=0; repL=append(repL,[#,"if "]); ); tmp=substring(str,#-1,#); if(tmp=="(",Pflg=Pflg+1); if(tmp==",", if(Pflg==Iflg, if(Cflg==0, repL=append(repL,[#," then "]); Cflg=1; , repL=append(repL,[#,",else, "]); Cflg=0; ); ); ); if(tmp==")", if(Pflg==Iflg, repL=append(repL,[#,",end"]); Iflg=Iflg-1; ); Pflg=Pflg-1; ); ); Out=""; tmp1=0; forall(repL, tmp=substring(str,tmp1,#_1-1)+#_2; Out=Out+tmp; if(indexof(#_2,"if")>0, tmp1=#_1+2; , tmp1=#_1; ); ); Out=replace(Out,"!","~"); Out; ); Deffun(name,bodylist):=( //help:Deffun("f(x)",["regional(y)","y=x^2*(x-3)","y"]); regional(funstr,tmp,tmp1,str,Pos); funstr=name+":=("; forall(bodylist, funstr=funstr+#+";"; ); funstr=funstr+");"; parse(funstr); tmp=bodylist_length(bodylist); str="function "+tmp+"="+name+","; forall(1..(length(bodylist)-1), tmp1=bodylist_#; Pos=indexof(tmp1,"regional")+indexof(tmp1,"local"); if(Pos==0, tmp=replace(tmp1,".xy",""); tmp=replace(tmp,".x","(1)"); tmp=replace(tmp,".y","(2)"); if(indexof(tmp,"if(")>0, tmp=iftosci(tmp); ); str=str+tmp+","; ); ); str=str+"endfunction;"; FUNLIST=append(FUNLIST,str); ); Windispg():=( regional(Nj,Nk,Dt,Vj,tmp,tmp1,tmp2,opcindy); gsave(); layer(KETPIClayer); forall(GCLIST,Nj, if(isstring(Nj_1),Dt=parse(Nj_1),Dt=Nj_1); // 11.17 if(islist(Dt) & length(Dt)>0, // 12.19,12.22 tmp=MeasureDepth(Dt); if(tmp==1,Dt=[Dt]); opcindy=Nj_3; if(Nj_2<0,tmp1=0,tmp1=Nj_2); if(tmp1<10, forall(Dt,Nk, // tmp2=apply(Nk,if(ispoint(#),Lcrd(#),#)); // tmp2=apply(tmp2,Pcrd(#)); tmp2=Nk; // 14.12.04 if(length(Nk)>1, tmp="connect("+text(tmp2)+ ",dashtype->"+text(tmp1)+",linecolor->"+KCOLOR+opcindy+")"; parse(tmp); , if(length(Nk)==1, tmp="draw("+text(tmp2_1)+opcindy+")"; // 14.12.31 parse(tmp); ); ); ); ); ); ); grestore(); layer(0); ); Windispg(pltdata):=( regional(pdata,Nj,Nk,Dt,tmp,tmp1,tmp2,opcindy); gsave(); layer(KETPIClayer); if(!islist(pltdata),tmp=[pltdata],tmp=pltdata); pdata=select(GCLIST,contains(tmp,#_1)); forall(pdata,Nj, if(isstring(Nj_1),Dt=parse(Nj_1),Dt=Nj_1); // 11.17 if(islist(Dt) & length(Dt)>0, // 12.19,12.22 tmp=MeasureDepth(Dt); if(tmp==1,Dt=[Dt]); opcindy=Nj_3; if(Nj_2<0,tmp1=0,tmp1=Nj_2); if(tmp1<10, forall(Dt,Nk, tmp2=Nk; // 14.12.04 if(length(Nk)>1, tmp="connect("+text(tmp2)+ ",dashtype->"+text(tmp1)+ ",linecolor->"+KCOLOR+opcindy+")"; parse(tmp); , if(length(Nk)==1, tmp="draw("+text(tmp2_1)+opcindy+")"; // 14.12.31 parse(tmp); ); ); ); ); ); ); grestore(); layer(0); ); WritetoSci() := WritetoSci(Fnamesci); WritetoSci(Arg) := ( regional(string,filename,shch,tmp1,tmp2); if(isstring(Arg), string=Arg; if(indexof(string,".sce")>0, filename=string; shchoice=""; , filename=Fnamesci; shch=string; ); WritetoSci(filename,shch); , if(Arg<=1,WritetoSci(Fnamesci,"all")); if(Arg==2,WritetoSci(Fnamesci,"sh")); if(Arg==3,WritetoScibody(Fnamescibody)); ); ); WritetoSci(filename,shchoice) := ( regional(Plist,Pos,Pnamelist,Pvaluelist,GrL,str,tmp,tmp1,tmp2,cmd); println("Write to Sci "+filename); Plist=[]; Pnamelist=[]; Pvaluelist=[]; forall(remove(allpoints(),[SW,NE]), tmp=Lcrd(#); tmp1=format(re(tmp_1),5);// 15.02.05 tmp2=format(re(tmp_2),5); tmp="["+tmp1+","+tmp2+"]"; Plist=append(Plist,#.name+"="+tmp+";"); Pnamelist=append(Pnamelist,#.name); Pvaluelist=append(Pvaluelist,tmp); ); SCEOUTPUT = openfile(filename); println(SCEOUTPUT,"cd('"+Dirwork+"');"); println(SCEOUTPUT,"Ketlib=lib('"+Libname+"');"); println(SCEOUTPUT,"Ketinit();"); println(SCEOUTPUT,"Fnametex='"+Fnametex+"';"); println(SCEOUTPUT,"Fnamesci='"+Fnamesci+"';"); println(SCEOUTPUT,"Fnamescibody='"+Fnamescibody+"';"); println(SCEOUTPUT,"Fnameout='"+Fnameout+"';"); println(SCEOUTPUT,"pi=%pi; i=%i;"); println(SCEOUTPUT,""); forall(COM0thlist, println(SCEOUTPUT,#+";"); ); println(SCEOUTPUT, "Setwindow(["+XMIN+","+XMAX+"], ["+YMIN+","+YMAX+"]);"); println(SCEOUTPUT,"Assignadd('pi',%pi);"); println(SCEOUTPUT,"Assignadd('XMIN',Xmin());"); println(SCEOUTPUT,"Assignadd('XMAX',Xmax());"); println(SCEOUTPUT,"Assignadd('YMIN',Ymin());"); println(SCEOUTPUT,"Assignadd('YMAX',Ymax());"); forall(1..length(Plist), print(SCEOUTPUT,Plist_#); println(SCEOUTPUT," Assignrep('"+Pnamelist_#+"',"+Pvaluelist_#+");"); ); forall(VLIST, tmp=Sciform(#_1); tmp1=#_2; // 15.02.06 if(!isstring(tmp1), if(islist(tmp1), tmp2="["; forall(tmp1, tmp2=tmp2+format(#,5)+","; ); tmp1=substring(tmp2,0,length(tmp2)-1)+"]"; , tmp1=format(tmp1,5); ); ); print(SCEOUTPUT,tmp+"evstr('"+tmp1+"')"+"; "); tmp=substring(tmp,0,length(tmp)-1); println(SCEOUTPUT," Assignrep('"+tmp+"',"+tmp1+");"); // 15.01.27 ); forall(FUNLIST, println(SCEOUTPUT,#); ); forall(GLIST, println(SCEOUTPUT,Sciform(#)+";"); ); tmp=text(Pnamelist); tmp=replace(tmp,"[","list("); Pnamelist=replace(tmp,"]",")"); println(SCEOUTPUT,"PtL="+Pnamelist+";"); tmp=select(GCLIST,#_2==-1); GrL=apply(tmp,#_1); tmp=text(GrL); tmp=replace(tmp,"[","list("); tmp=replace(tmp,"]",")"); println(SCEOUTPUT,"GrL="+tmp+";"); tmp1=""; forall(SCIWRLIST, tmp1=tmp1+","+Dq+#+Dq+","+#; ); if(length(tmp1)>0, tmp1="WriteOutData(Fnameout"+tmp1+");"; println(SCEOUTPUT,tmp1); ); if(length(SCIRELIST)>0, println(SCEOUTPUT,"Tmpout=ReadOutData(Fnameout);"); println(SCEOUTPUT,"execstr(Tmpout);"); ); if(shchoice=="sh", println(SCEOUTPUT,"//if length(fileinfo(Fnamescibody))>0"); println(SCEOUTPUT,"// Gbdy=ReadfromCindy(Fnamescibody);"); println(SCEOUTPUT,"// execstr(Gbdy)"); println(SCEOUTPUT,"//end;"); , println(SCEOUTPUT,"//if length(fileinfo(Fnamescibody))>0"); println(SCEOUTPUT,"// Gbdy=ReadfromCindy(Fnamescibody);"); println(SCEOUTPUT,"// execstr(Gbdy)"); println(SCEOUTPUT,"//end;"); ); forall(COM1stlist, println(SCEOUTPUT,#+";"); ); // forall(GOUTLIST, // if(length(#_2)>0, // tmp1=#_1; // println(SCEOUTPUT,"execstr(ReadOutData('"+tmp1+"'));"); // ); // ); println(SCEOUTPUT,""); println(SCEOUTPUT,"//Windisp(GrL,'c');"); println(SCEOUTPUT,""); println(SCEOUTPUT,"if 1==1 then"); println(SCEOUTPUT,""); println(SCEOUTPUT,"Openfile(Fnametex,'"+ULEN+"');"); forall(COM2ndlist, println(SCEOUTPUT," "+#+";"); ); if(length(GrL)>0, println(SCEOUTPUT," Drwline(GrL);"); ); // forall(GOUTLIST, // if(length(#_2)>0, // tmp1=text(#_2); // tmp1=substring(tmp1,1,length(tmp1)-1); // println(SCEOUTPUT," Drwline("+tmp1+");"); // ); // ); println(SCEOUTPUT,"Closefile('"+ADDAXES+"');"); println(SCEOUTPUT,""); println(SCEOUTPUT,"end;"); if(shchoice=="sh", println(SCEOUTPUT,""); println(SCEOUTPUT,"quit();"); , println(SCEOUTPUT,""); println(SCEOUTPUT,"//quit();"); ); closefile(SCEOUTPUT); ); WritetoScibody() := WritetoScibody(Fnamescibody); WritetoScibody(filename) := ( regional(Plist,Pos,Pnamelist,Pvaluelist,GrL,str,tmp,tmp1,cmd); println("WritetoScibody "+filename); Plist=[]; Pnamelist=[]; Pvaluelist=[]; forall(remove(allpoints(),[SW,NE]), Plist=append(Plist,#.name+"="+#.xy+";"); Pnamelist=append(Pnamelist,#.name); Pvaluelist=append(Pvaluelist,#.xy); ); SCEOUTPUT = openfile(filename); println(SCEOUTPUT, "Setwindow(["+XMIN+","+XMAX+"], ["+YMIN+","+YMAX+"]);"); println(SCEOUTPUT,"Assignadd('pi',%pi);"); println(SCEOUTPUT,"Assignadd('XMIN',Xmin());"); println(SCEOUTPUT,"Assignadd('XMAX',Xmax());"); println(SCEOUTPUT,"Assignadd('YMIN',Ymin());"); println(SCEOUTPUT,"Assignadd('YMAX',Ymax());"); forall(1..length(Plist), print(SCEOUTPUT,Plist_#); println(SCEOUTPUT," Assignrep('"+Pnamelist_#+"',"+Pvaluelist_#+");"); ); forall(VLIST, tmp=Sciform(#_1); tmp1=#_2; if(!isstring(tmp1), print(SCEOUTPUT,tmp+tmp1+"; "); , print(SCEOUTPUT,tmp+"evstr('"+tmp1+"')"+"; "); ); tmp=substring(tmp,0,length(tmp)-1); println(SCEOUTPUT," Assignrep('"+tmp+"',"+#_2+");"); ); forall(FUNLIST, println(SCEOUTPUT,#); ); forall(GLIST, println(SCEOUTPUT,Sciform(#)+";"); ); tmp=text(Pnamelist); tmp=replace(tmp,"[","list("); Pnamelist=replace(tmp,"]",")"); println(SCEOUTPUT,"PtL="+Pnamelist+";"); tmp=select(GCLIST,#_2==-1); GrL=apply(tmp,#_1); tmp=text(GrL); tmp=replace(tmp,"[","list("); tmp=replace(tmp,"]",")"); println(SCEOUTPUT,"GrL="+tmp+";"); tmp1=""; forall(SCIWRLIST, tmp1=tmp1+","+Dq+#+Dq+","+#; ); if(length(tmp1)>0, tmp1="WriteOutData(Fnameout"+tmp1+");"; println(SCEOUTPUT,tmp1); ); if(length(SCIRELIST)>0, println(SCEOUTPUT,"Tmpout=ReadOutData(Fnameout);"); println(SCEOUTPUT,"execstr(Tmpout);"); ); if(shchoice=="sh", println(SCEOUTPUT,"//if length(fileinfo(Fnamescibody))>0"); println(SCEOUTPUT,"// Gbdy=ReadfromCindy(Fnamescibody);"); println(SCEOUTPUT,"// execstr(Gbdy)"); println(SCEOUTPUT,"//end;"); , println(SCEOUTPUT,"//if length(fileinfo(Fnamescibody))>0"); println(SCEOUTPUT,"// Gbdy=ReadfromCindy(Fnamescibody);"); println(SCEOUTPUT,"// execstr(Gbdy)"); println(SCEOUTPUT,"//end;"); ); forall(COM1stlist, println(SCEOUTPUT,#+";"); ); // forall(GOUTLIST, 2014.12.18 // if(length(#_2)>0, // tmp1=#_1; // println(SCEOUTPUT,"execstr(ReadOutData('"+tmp1+"'));"); // ); // ); println(SCEOUTPUT,""); println(SCEOUTPUT,"//Windisp(GrL,'c');"); println(SCEOUTPUT,""); closefile(SCEOUTPUT); ); Extractdata(name):=Extractdata(1,name,[]); Extractdata(Arg1,Arg2):=( if(isstring(Arg1), Extractdata(1,Arg1,Arg2); , Extractdata(Arg1,Arg2,[]); ); ); Extractdata(number,name,options):=( //help:Extractdata("1","ha1"); regional(dlist,tmp,tmp1,tmp2,tmp3,File,Ltype,Noflg,opstr,opcindy); tmp=Divoptions(options); Ltype=tmp_1; Noflg=tmp_2; opstr=tmp_(length(tmp)-1); opcindy=tmp_length(tmp); tmp1=[]; forall(1..length(GOUTLIST), if(contains(GOUTLIST_#_2,name), tmp1=append(tmp1,#); ); ); if(length(tmp1)==0, println(varname+" not found"); , tmp1=tmp1_number; tmp2=GOUTLIST_tmp1; tmp=remove(tmp2_2,[name]); GOUTLIST_tmp1=[tmp2_1,tmp]; File=tmp2_1; ); if(Noflg<3, println("extract outdata "+name); tmp1=parse(name); Com0th("Tmpout=ReadOutData("+Dq+File+Dq+");"); Com0th("execstr(Tmpout);"); ); if(Noflg<2, if(isstring(Ltype), Ltype=GetLinestyle(text(Noflg)+Ltype,name); , if(Noflg==1,Ltype=0); ); GCLIST=append(GCLIST,[name,Ltype,opcindy]); ); tmp2; ); RemoveOut(pltlist):=( regional(name,tmp,tmp1,tmp2); forall(pltlist,name, tmp1=[]; forall(GOUTLIST, tmp=remove(#_2,[name]); tmp1=append(tmp1,[#_1,tmp]); ); GOUTLIST=tmp1; ); ); ReadOutData():=ReadOutData(Fnameout); ReadOutData(filename):=( //help:ReadOutData(); //help:ReadOutData("file.txt"); regional(varname,tmp,tmp1,tmp2,tmp3,tmp4, nmbr,cmdall,cmd,cmdorg,outdt,goutdt,flg3d); tmp=load(filename); cmdall=tokenize(tmp,"//"); outdt=[]; forall(cmdall,cmdorg, flg3d=0; cmd=replace(cmdorg,LFmark,""); if(length(cmd)>0, if(cmd=="start" % cmd=="end" % substring(cmd,0,1)=="[", if(cmd=="start", parse("tmp=[];"); ); if(cmd=="end", parse(varname+"=append("+varname+",tmp);"); ); if(substring(cmd,0,1)=="[", tmp1=parse(cmd); if(!islist(tmp1_1) % length(tmp1_1)<3, // 2014.12.14 tmp1=apply(tmp1,Pcrd(#)); flg3d=2; , flg3d=3; ); tmp2="["; forall(tmp1, if(flg3d==2, tmp3=format(#_1,4)+","+format(#_2,4); , tmp3=format(#_1,4)+","+format(#_2,4)+","+format(#_3,4); ); tmp2=tmp2+"["+tmp3+"],"; ); tmp2=substring(tmp2,0,length(tmp2)-1)+"]"; parse("tmp=concat(tmp,"+tmp2+")"); ); , varname=cmd; outdt=append(outdt,varname); parse(varname+"=[];"); ); ); ); goutdt=[]; forall(outdt,tmp1, tmp2=parse(tmp1); if(length(tmp2_1)==1, forall(1..length(tmp2),nmbr, tmp3=tmp1+#+"="+text(tmp2_nmbr_1)+";"; parse(tmp3); POUTLIST=append(POUTLIST,tmp1+#); ); , goutdt=append(goutdt,tmp1); ); ); GOUTLIST=append(GOUTLIST,[filename,goutdt]); println("outdata of "+filename+" : "+text(goutdt)); goutdt; ); WriteOutData(filename,ptlist):=( //help:WriteOutData("file.txt",["g1",gr1","sg",sgAB]); regional(nn,Gname,Gdata,Str,Gstr,Gj,Pt,tmp,tmp1,Flg,loopend); Flg=0; // 15.01.17 if(isstring(ptlist_length(ptlist)), Flg=1; ); SCEOUTPUT = openfile(filename); if(Flg==0, loopend=length(ptlist)/2; , loopend=length(ptlist); ); Gstr="["; forall(1..loopend,nn, if(Flg==0, Gname=ptlist_(2*nn-1); , Gname=ptlist_nn; ); Gstr=Gstr+Gname+","; println(SCEOUTPUT,Gname+"//"); if(Flg==0, Gdata=ptlist_(2*nn); , Gdata=parse(Gname); ); Gdata=Flattenlist(Gdata); forall(Gdata,Gj, println(SCEOUTPUT,"start//"); Str=""; forall(Gj,Pt, if(length(Str)>0, Str=Str+"," ); Str=Str+"["+format(Pt_1,4)+","; Str=Str+format(Pt_2,4); if(length(Pt)<3, Str=Str+"]"; , Str=Str+","+format(Pt_3,4)+"]"; ); if(length(Str)>80, println(SCEOUTPUT,"["+Str+"]//"); Str=""; ); ); if(length(Str)>0, println(SCEOUTPUT,"["+Str+"]//"); ); println(SCEOUTPUT,"end//"); ); ); closefile(SCEOUTPUT); Gstr=substring(Gstr,0,length(Gstr)-1)+"]"; println("writeoutdata "+filename+":"+Gstr); ); Makeshell():=( if(length(Texmain)>0, Makeshell(Texmain); , Makeshell(Fhead+"main"); ); ); Makeshell(texmainfile):=( regional(tmp,tmp1,tmp2,flg); tmp1=""; tmp2=Shellparent; flg=0; forall(reverse(1..length(Shellparent)), if(flg==0, tmp=substring(Shellparent,#-1,#); if(tmp=="/" % tmp=="\", // 14.01.15 tmp1=substring(Shellparent,0,#-1); tmp2=substring(Shellparent,#,length(Shellparent)); flg=1; ); ); ); // println([tmp1,tmp2]); if(length(tmp1)>0, setdirectory(tmp1); ); SCEOUTPUT = openfile(tmp2); println(SCEOUTPUT,"#!/bin/sh"); println(SCEOUTPUT,"cd "+Dirwork); println(SCEOUTPUT,Shellchild+" "+Fhead+" "+texmainfile); println(SCEOUTPUT,"exit 0"); closefile(SCEOUTPUT); setdirectory(Dirwork); err("EXECUTE kccheck.sh BEFORE kc.sh"); 14.01.15 ); Makebat():=( if(length(Texmain)>0, Makebat(Texmain); , Makebat(Fhead+"main"); ); ); Makebat(texmainfile):=( regional(drive,fname,tmp,tmp1,tmp2,flg); drive="C:"; fname=Batparent; tmp=indexof(fname,":"); if(tmp>0, drive=substring(Batparent,0,tmp); fname=substring(Batparent,tmp,length(Batparent)); ); tmp1=""; tmp2=fname; flg=0; forall(reverse(1..length(fname)), if(flg==0, tmp=substring(fname,#-1,#); if(tmp=="/" % tmp=="\" % tmp=="¥", // 14.01.15 tmp1=substring(fname,0,#-1); tmp2=substring(fname,#,length(fname)); flg=1; ); ); ); if(length(tmp1)>0, setdirectory(drive+tmp1); ); SCEOUTPUT = openfile(tmp2); fname=Dirwork; tmp=indexof(fname,":"); if(tmp>0, drive=substring(Dirwork,0,tmp); fname=substring(Dirwork,tmp,length(Dirwork)); println(SCEOUTPUT,drive); ); println(SCEOUTPUT,"cd "+fname); println(SCEOUTPUT,Batchild+" "+Fhead+" "+texmainfile); closefile(SCEOUTPUT); if(indexof(Dirwork,":")==0, // 14.01.15 drive="C:"; , drive=""; ); setdirectory(drive+Dirwork); err("EXECUTE kccheck.bat BEFORE kc.bat"); // 14.01.15 ); Viewtex():=( regional(texfile,tmp,tmp1); texfile=Fhead+"main"; SCEOUTPUT=openfile(texfile+".tex"); println(SCEOUTPUT,"\documentclass{article}"); println(SCEOUTPUT,"\usepackage{ketpic,ketlayer}"); println(SCEOUTPUT,"\usepackage{amsmath,amssymb}"); println(SCEOUTPUT,"\usepackage{graphicx,color}"); println(SCEOUTPUT,""); println(SCEOUTPUT,"\def\ketcindy{{K\kern-.20em%"); println(SCEOUTPUT,"\lower.5ex\hbox{E}\kern-.125em{TCindy}}}"); println(SCEOUTPUT,""); println(SCEOUTPUT,"\setmargin{20}{20}{20}{20}"); println(SCEOUTPUT,""); println(SCEOUTPUT,"\begin{document}"); println(SCEOUTPUT,Fhead); println(SCEOUTPUT,"\vspace{5mm}"); println(SCEOUTPUT,""); println(SCEOUTPUT,"\input{"+Fhead+".tex}"); println(SCEOUTPUT,""); println(SCEOUTPUT,"\end{document}"); closefile(SCEOUTPUT); if(length(Shellparent)>0, Makeshell(texfile) , Makebat(texfile); ); WritetoSci(2); ); Makehelplist(libname):=( regional(cmdall,cmd,flg,lev,tmp,tmp1,out); tmp=load(libname+".txt"); cmdall=tokenize(tmp,"//help:"); cmdall=remove(cmdall,[cmdall_1]); out=[]; forall(cmdall,cmd, tmp1=indexof(cmd,"("); lev=1; flg=0; forall((tmp1+1)..length(cmd), if(flg==0, tmp=substring(cmd,#-1,#); if(tmp=="(",lev=lev+1); if(tmp==")", lev=lev-1; if(lev==0, flg=1; out=append(out,substring(cmd,0,#)+";"); ); ); ); ); ); sort(out); ); Makecmdlist(libname):=( //help:Makecmdlist("ketcindylib"); regional(cmdall,cmd,flg,tmp,tmp1,tmp2,out); setdirectory(Dirlib); tmp=load(libname+".txt"); cmdall=tokenize(tmp,":="); out=[]; forall(cmdall,cmd, tmp=max([0,length(cmd)-50]); tmp1=";"+substring(cmd,tmp,length(cmd)); flg=0; forall(reverse(1..length(tmp1)), if(flg==0, if(substring(tmp1,#-1,#)==";", tmp=substring(tmp1,#,length(tmp1)); tmp2=substring(tmp,0,1); if(length(tmp)>0, if(!contains([" ","/"],tmp2), out=append(out,tmp); flg=1; ); ); ); ); ); ); setdirectory(Dirwork); tmp=length(out)-1; out=out_(2..tmp); out=sort(out); ); Savecmdlist(cmdlist,cmdfile):=( SCEOUTPUT=openfile(cmdfile+".txt"); forall(cmdlist, println(SCEOUTPUT,#); ); closefile(SCEOUTPUT); ); Quicksort(seq):=( regional(pivot,left,right,out); if(length(seq)<2, out=seq; , pivot = max(seq_1,seq_2); left = []; right = []; forall(seq, if(#< pivot, left=append(left,#); , right=append(right,#); ); ); left = Quicksort(left); right = Quicksort(right); out=concat(left,right); ); out; ); Lessstr(st1,st2):=( regional(tmp,tmp1,tmp2,out); tmp=min(length(st1),length(st2)); flg=0; forall(1..tmp, if(flg==0, tmp1=substring(st1,#-1,#); tmp2=substring(st2,#-1,#); if(tmp1tmp2, out=(1>2); flg=1; ); ); ); ); if(flg==0, if(length(st1)2); ); ); out; ); Helplist():=Helplist(Dirlib,[]); Helplist(Arg):=( if(islist(Arg), Helplist(Dirlib,Arg); , Helplist(Arg,[]); ); ); Helplist(dir,added):=( regional(files,tmp,tmp1,tmp2); setdirectory(dir); files=["ketcindylib","ketcindylib3d"]; files=concat(files,added); tmp1=[]; forall(files, tmp=Makehelplist(#); tmp1=concat(tmp1,tmp); ); HLIST=sort(tmp1); setdirectory(Dirwork); ); Help():=Help(""); Help(str):=( regional(small,tmp,tmp1,flg); if(length(str)==0, forall(HLIST, println(#); ); , // small="abcdefghijklmnopqrstuvwxyz"; // tmp=substring(str,0,1); // tmp=indexof(small,tmp); // if(tmp==0, tmp1=str; // , // tmp=tmp+64; // tmp1=unicode(text(tmp),base->10); // tmp1=tmp1+substring(str,1,length(str)); // ); flg=0; forall(HLIST, if(substring(#,0,length(str))==tmp1, println(#); flg=1; ); ); if(flg==0,println(" no example")); ); );