// グラフィックライブラリ:glib // 1998.7.16 ver-1.2 小山智史(弘前大学) // 2001.9.1 ver-1.3g ...NN4, NN6, IE5に対応, circle(), ellipse()などを追加 // 2004.3.5 ver-2.0 ...任意サイズの文字や画像の出力など河合雅司氏による拡張を組み込みglib2.jsに改称 // 2004.10.25 ver-2.0a ...Gclose()中で空欄のデータは表示しない。Gdata()でgsymbolとgcolorが設定値を超えた場合は繰り返す // 2004.11.29 ver-2.0b ...plotcの描画位置の微調整 // 2004.12.6 ver-2.0c ...gplotの変数の最大数(NCHAIN)を10から20に変更。gcolorの配色を変更 // 2005.2.15 ver-2.0d ...gplotの変数の最大数(NCHAIN)を20から30に変更。 // 2005.11.18 ver-2.0e ...plot(...,size), line(...,size)などサイズ指定を追加 // 2006.1.24 ver-2.0f ...farrow()を追加 // 2006.8.30 ver-2.0g ...Circle()を修正(河内伸浩氏からの指摘による) // ※注意: ver-2.0〜(glib.js→glib2.js)の大きな変更 // グラフィックを独立窓に表示する場合はgopen(...,gwin)でgwinを-1にする // 現在位置に表示する場合はgwinを-2にする // フレーム表示の場合はgwinを0〜のフレーム番号にする // (なお、従来のバージョンもglib.jsのまま残しています) var ON=1, OFF=0, SWIDTH=6, SHEIGHT=12; // glib_fontsize0〜2は河合雅司氏による拡張 var glib_fontsize0=10; // 不明(pixel) var glib_fontsize1=8; // 座標軸目盛文字サイズ(pixel) var glib_fontsize2=10; // 座標軸説明文字サイズ(pixel) var glib_BGCOLOR, IXMAX, IYMAX, ILINE=1; var IXPOS=0, IYPOS=0, DM=1, KX=0, KY=0, KZ=0; var XOF=0, YOF=0, ZOF=0, XFS=0, YFS=0, ZFS=0, XCK=1, YCK=1, ZCK=1, XSPAN=1, YSPAN=1, ZSPAN=1,XSTEP=0, YSTEP=0, ZSTEP=0; var c1=new Array(1,.966,.866,.707,.5,.259,0); var iflag=new Array(); ixtable=new Array(), iytable=new Array(); var gwin=-1; var NCHAIN=30; var gcolor=new Array("RED","BLUE","GREEN","MAGENTA","ORANGE","#0000b0","LIMEGREEN","GOLD","BROWN","BLACK"); var gsymbol=new Array("×","●","▲","■","◆","*","○","△","□","◇","◎"); // グラフィックの開始... // bgcolor:背景色, ixmax:幅,iymax:高さ, s:タイトル, gwin:-2で独立窓, -1で現在位置, 0〜でフレーム var agt=navigator.userAgent.toLowerCase(); var is_major= parseInt(navigator.appVersion); var is_nav =((agt.indexOf('mozilla')!=-1) && (agt.indexOf('compatible')==-1)); var is_nav4 =(is_nav && (is_major==4)); var is_nav4up=(is_nav && (is_major>=4)); var is_nav5up=(is_nav && (is_major>=5)); var is_ie =(agt.indexOf("msie")!=-1); var is_ie3 =(is_ie && (is_major< 4)); var is_ie4 =(is_ie && (is_major==4) && (agt.indexOf("msie 5.0")==-1) ); var is_ie4up=(is_ie && (is_major>=4)); var is_ie5up=(is_ie && !is_ie3 && !is_ie4); function gopen(bgcolor,ixmax,iymax,s,gw){ GWIN=gw; glib_BGCOLOR=bgcolor||"cornsilk"; IXMAX=ixmax||400; IYMAX=iymax||200; ILINE=1; IXPOS=IYPOS=0; DM=1; KX=KY=KZ=0; XOF=YOF=ZOF=0; XCK=YCK=ZCK=1; if(GWIN==-1){ // ウィンドウ版 gwin=window.open("","gwin1","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+IXMAX+",height="+IYMAX); gwin.focus();gwin.document.open(); gwin.document.write(""+s+""); if(is_ie) gwin.document.bgColor=glib_BGCOLOR; // 河合氏による修正 // else gwin.document.write(""); else gwin.document.write(""); gwin.document.write("

"+s+"

"); }else if(GWIN==-2){ // 現在位置 if(is_nav4) document.write("

"+s+"

"); else if(is_ie4up) document.write("

"+s+"

"); else if(is_nav5up) document.write("

"+s+"

"); }else with(parent.frames[GWIN].document){ // フレーム版 open(); if(is_nav4) write("

"+s+"

"); else if(is_ie4up) write("

"+s+"

"); else if(is_nav5up) write("

"+s+"

"); } } // グラフィック終了 function gclose(){ if(GWIN==-1){ // ウィンドウ版 gwin.document.write(""); gwin.document.close(); }else if(GWIN==-2){ // 現在位置 if(is_nav4) document.write("

"); else if(is_ie4up) document.write("

"); else if(is_nav5up){ document.write("

"); // グラフ表示後の位置調整(NN6) for(var i=0;i"); } }else with(parent.frames[GWIN].document){ // フレーム版 if(is_nav4) write("

"); else if(is_ie4up) write("
"); else if(is_nav5up){ write("
"); // グラフ表示後の位置調整(NN6) for(var i=0;i"); } } } function ixx(ix){return (DM==2||DM==3)?(IXPOS-ix):(IXPOS+ix);} function iyy(iy){return (DM==3||DM==4)?(IYPOS+iy):(IYPOS-iy);} function xyinit(ix0,iy0,dm,kx0,ky0,kz0){IXPOS=ix0;IYPOS=iy0;DM=dm; KX=kx0; KY=ky0; KZ=kz0;} function xyzcv1(x, y, z, P){ var kx1,ky1,kz1,kx2,ky2,kz2,kz3,zz,x1,y1,x2,y2,cx1,cy1,cz; kx1=(KX<0)?(1-KX):(1+KX); ky1=(KY<0)?(1-KY):(1+KY); kz1=(KZ<0)?(1-KZ):(1+KZ); kz2=Math.floor((kz1-1)/10); kz1=Math.floor(kz1-(10*kz2)); kx2=8-kx1; ky2=8-ky1; kz3=8-kz1; if(KX!=KY) kz1=kz3=1; P.x=x/XCK; P.y=y/YCK; zz=z/ZCK; x1=c1[kx1-1]*P.x; y1=c1[ky1-1]*P.y; cy1=(-c1[ky2-1]); cx1=c1[kx2-1]; if((KY<0)^(DM==2 || DM==4)) cy1=(-cy1); if((KX<0)^(DM==2 || DM==4)) cx1=(-cx1); x2=x1+cy1*P.y; y2=y1+cx1*P.x; cz=c1[kz3-1]; if(kz2==0){ if((KZ<0)&&(DM==2 || DM==3)) cz=(-cz); x2=c1[kz1-1]*x2+cz*zz; }else if(kz2==1){ if((KZ<0)&&(DM==3 || DM==4)) cz=(-cz); y2=c1[kz1-1]*y2+cz*zz; } P.x=Math.floor(100*x2); P.y=Math.floor(100*y2); } function xyzcv(x, y, z, P){ var POF=new Array(); xyzcv1(x,y,z,P); xyzcv1(XOF,YOF,ZOF,POF); P.x-=POF.x; P.y-=POF.y; } function goffset(x, y, z){ XOF=x; YOF=y; ZOF=z; } // オフセット指定 function gscale(cx, cy, cz){ XCK=cx; YCK=cy; ZCK=cz; } // 軸感度指定 function plot(color,x,y,s){ if(!s) s=1; if(isNaN(s)) symbol(color,x,y,s); else{ var ds=Math.floor(s/2); if(GWIN==-1){ // ウィンドウ版 if(is_nav4) gwin.document.write(""); else if(is_ie4up||is_nav5up) gwin.document.write(""); }else if(GWIN==-2){ // 現在位置 if(is_nav4) document.write(""); else if(is_ie4up||is_nav5up) document.write(""); }else{ // フレーム版 if(is_nav4) parent.frames[GWIN].document.write(""); else if(is_ie4up||is_nav5up) parent.frames[GWIN].document.write(""); } } } function plotk(color,font_size,x,y,s){ if(s) symbolk(color,font_size,x,y,s); } function fplot(color, x, y, z, s){ var P=new Array(); if(s) fsymbol(color,x,y,z,s); else{xyzcv(x,y,z,P); plot(color,P.x,P.y);} } function plot0(color,x,y,s){ if(s && !isNaN(s)) plot(color,x,y,s); // sが数値ならplot() else if(GWIN==-1){ // ウィンドウ版 if(is_nav4) gwin.document.write(""+s+""); else if(is_ie4up||is_nav5up) gwin.document.write(""+s+""); }else if(GWIN==-2){ // 現在位置 if(is_nav4) document.write(""+s+""); else if(is_ie4up||is_nav5up) document.write(""+s+""); }else{ // フレーム版 if(is_nav4) parent.frames[GWIN].document.write(""+s+""); else if(is_ie4up||is_nav5up) parent.frames[GWIN].document.write(""+s+""); } } function plotc(color, s, str){ var ixpos1=IXPOS, iypos1=IYPOS, dm1=DM, kx1=KX, ky1=KY, kz1=KZ; // var ix=IXMAX-100-str.length*SWIDTH-SWIDTH; var iy=-(SHEIGHT+2)*(ILINE++); xyinit(0,0,0,0,0,0); symbol(color,IXMAX-140,iy,str); // 2004.11.29 iy-=(SHEIGHT/2); plot0(color,IXMAX-150,iy,s); // 2004.11.29 xyinit(ixpos1,iypos1,dm1,kx1,ky1,kz1); } function circle(color,x0,y0,r){ var x=r, y=0; while(x>=y){ plot(color,x0+x,y0+y); plot(color,x0+x,y0-y); plot(color,x0-x,y0+y); plot(color,x0-x,y0-y); plot(color,x0+y,y0+x); plot(color,x0+y,y0-x); plot(color,x0-y,y0+x); plot(color,x0-y,y0-x); if((r-=(y++ <<1))<0) r+=(x-- -1)<<1; } } function fcircle(color, x0, y0, z0, r){ var P0=new Array(); xyzcv(x0,y0,z0,P0); circle(color,P0.x,P0.y,Math.round(r*100)); } function Circle(color,x0,y0,r){ r=Math.round(r); // 2006.8.30 河内伸浩氏からの指摘による追加 var x=r, y=0; while(x>=y){ hline(color,x0+x,y0+y,x0-x); hline(color,x0+x,y0-y,x0-x); hline(color,x0+y,y0+x,x0-y); hline(color,x0+y,y0-x,x0-y); if((r-=(y++ <<1))<0) r+=(x-- -1)<<1; } } function fCircle(color, x0, y0, z0, r){ var P0=new Array(); xyzcv(x0,y0,z0,P0); Circle(color,P0.x,P0.y,Math.round(r*100)); } function ellipse(color, x0, y0, rx, ry){ var x, x1, y, y1, r; if(rx>=ry){ x=r=rx; y=0; while(x>=y){ x1=Math.round(x*ry/rx); y1=Math.round(y*ry/rx); plot(color,x0+x,y0+y1); plot(color,x0+x,y0-y1); plot(color,x0-x,y0+y1); plot(color,x0-x,y0-y1); plot(color,x0+y,y0+x1); plot(color,x0+y,y0-x1); plot(color,x0-y,y0+x1); plot(color,x0-y,y0-x1); if((r-=(y++ <<1)-1)<0) r+=(x-- -1)<<1; } }else{ x=r=ry; y=0; while(x>=y){ x1=Math.round(x*rx/ry); y1=Math.round(y*rx/ry); plot(color,x0+x1,y0+y); plot(color,x0+x1,y0-y); plot(color,x0-x1,y0+y); plot(color,x0-x1,y0-y); plot(color,x0+y1,y0+x); plot(color,x0+y1,y0-x); plot(color,x0-y1,y0+x); plot(color,x0-y1,y0-x); if((r-=(y++ <<1)-1)<0) r+=(x-- -1)<<1; } } } function fellipse(color, x0, y0, z0, rx, ry){ var P0=new Array(); xyzcv(x0,y0,z0,P0); ellipse(color,P0.x,P0.y,Math.round(rx*100),Math.round(ry*100)); } function Ellipse(color, x0, y0, rx, ry){ var x, x1, y, y1, r; if(rx>=ry){ x=r=rx; y=0; while(x>=y){ x1=Math.round(x*ry/rx); y1=Math.round(y*ry/rx); hline(color,x0+x,y0+y1,x0-x); hline(color,x0+x,y0-y1,x0-x); hline(color,x0+y,y0+x1,x0-y); hline(color,x0+y,y0-x1,x0-y); if((r-=(y++ <<1)-1)<0) r+=(x-- -1)<<1; } }else{ x=r=ry; y=0; while(x>=y){ x1=Math.round(x*rx/ry); y1=Math.round(y*rx/ry); hline(color,x0+x1,y0+y,x0-x1); hline(color,x0+x1,y0-y,x0-x1); hline(color,x0+y1,y0+x,x0-y1); hline(color,x0+y1,y0-x,x0-y1); if((r-=(y++ <<1)-1)<0) r+=(x-- -1)<<1; } } } function fEllipse(color, x0, y0, z0, rx, ry){ var P0=new Array(); xyzcv(x0,y0,z0,P0); Ellipse(color,P0.x,P0.y,Math.round(rx*100),Math.round(ry*100)); } function hline(color,x1,y1,x2,size){ if(x1==x2){ plot(color,x1,y1,size); return; } if(!size) size=1; var ixx1=ixx(x1), iyy1=iyy(y1)-Math.floor(size/2), ixx2=ixx(x2), t; if(ixx1>ixx2){ t=ixx1; ixx1=ixx2; ixx2=t; } if(GWIN==-1){ // ウィンドウ版 if(is_nav4) gwin.document.write(""); else if(is_ie4up||is_nav5up) gwin.document.write(""); }else if(GWIN==-2){ // 現在位置 if(is_nav4) document.write(""); else if(is_ie4up||is_nav5up) document.write(""); }else{with(parent.frames[GWIN].document){ // フレーム版 if(is_nav4) write(""); else if(is_ie4up||is_nav5up) write(""); }} } function vline(color,x1,y1,y2,size){ if(y1==y2){ plot(color,x1,y1,size); return; } if(!size) size=1; var ixx1=ixx(x1)-Math.floor(size/2), iyy1=iyy(y1), iyy2=iyy(y2), t; if(iyy1>iyy2){ t=iyy1; iyy1=iyy2; iyy2=t; } if(GWIN==-1){ // ウィンドウ版 if(is_nav4) gwin.document.write(""); else if(is_ie4up||is_nav5up) gwin.document.write(""); }else if(GWIN==-2){ // 現在位置 if(is_nav4) document.write(""); else if(is_ie4up||is_nav5up) document.write(""); }else{with(parent.frames[GWIN].document){ // フレーム版 if(is_nav4) write(""); else if(is_ie4up||is_nav5up) write(""); }} } function arrow(color,x1,y1,x2,y2){ var x1=Math.round(x1), y1=Math.round(y1); var x2=Math.round(x2), y2=Math.round(y2); if(x1==x2){ vline(color,x1,y1,y2); if(y1>y2){ line(color,x2,y2,x2+3,y2+10);line(color,x2,y2,x2-3,y2+10);} else{ line(color,x2,y2,x2+3,y2-10);line(color,x2,y2,x2-3,y2-10);} }else if(y1==y2){ hline(color,x1,y1,x2); if(x1>x2){ line(color,x2,y2,x2+10,y2+3);line(color,x2,y2,x2+10,y2-3);} else{ line(color,x2,y2,x2-10,y2+3);line(color,x2,y2,x2-10,y2-3);} }else{ var co=0.2914568, dist=10.4; line(color,x1,y1,x2,y2); var x=x1-x2, y=y1-y2, th=Math.atan(x/y); if(y<0) th=Math.PI+th; var th1=th+co, th2=th-co; var xx=dist*Math.sin(th1)+x2; xx=Math.round(xx); var yy=dist*Math.cos(th1)+y2; yy=Math.round(yy); line(color,x2,y2,xx,yy); xx=dist*Math.sin(th2)+x2; xx=Math.round(xx); yy=dist*Math.cos(th2)+y2; yy=Math.round(yy); line(color,x2,y2,xx,yy); } } function farrow(color, x1, y1, z1, x2, y2, z2){ var P1=new Array(), P2=new Array(); xyzcv(x1,y1,z1,P1);xyzcv(x2,y2,z2,P2);arrow(color,P1.x,P1.y,P2.x,P2.y); } function line(color,x1,y1,x2,y2,size){ var x1=Math.round(x1), y1=Math.round(y1); var x2=Math.round(x2), y2=Math.round(y2); if(x1==x2) vline(color,x1,y1,y2,size); else if(y1==y2) hline(color,x1,y1,x2,size); else{ var dx=Math.abs(x2-x1), dy=Math.abs(y2-y1), s, step, x0, y0; if(dx>dy){ if(x1>x2){ step=(y1>y2)?1:-1; s=x1; x1=x2; x2=s; y1=y2; }else step=(y1>1; while(++x1<=x2){ if((s-=dy)<0){hline(color,x0,y1,x1,size);x0=x1;s+=dx;y1+=step;} } hline(color,x0,y1,x1,size); }else{ if(y1>y2){ step=(x1>x2)?1:-1; s=y1; y1=y2; y2=s; x1=x2; }else step=(x1>1 while(++y1<=y2){ // if((s-=dx)<0){s+=dy; x1+=step;} // plot(color,x1,y1); if((s-=dx)<0){vline(color,x1,y0,y1,size);y0=y1;s+=dy;x1+=step;} } // vline(color,x1,y0,y1,size); } } } function fline(color, x1, y1, z1, x2, y2, z2, size){ var P1=new Array(), P2=new Array(); xyzcv(x1,y1,z1,P1);xyzcv(x2,y2,z2,P2);line(color,P1.x,P1.y,P2.x,P2.y,size); } function gbox(color, ix1, iy1, ix2, iy2){ if(ix1==ix2 || iy1==iy2){ if(color==color.toUpperCase()) line("BLACK",ix1,iy1,ix2,iy2); else line(color,ix1,iy1,ix2,iy2); return; } if(color==color.toLowerCase()){ line(color,ix1,iy1,ix1,iy2); line(color,ix1,iy1,ix2,iy1); line(color,ix1,iy2,ix2,iy2); line(color,ix2,iy1,ix2,iy2); }else{ var ixx1=ixx(ix1), iyy1=iyy(iy1), ixx2=ixx(ix2), iyy2=iyy(iy2); if(ixx1>ixx2){ t=ixx1; ixx1=ixx2; ixx2=t; } if(iyy1>iyy2){ t=iyy1; iyy1=iyy2; iyy2=t; } if(GWIN==-1){ // ウィンドウ版 if(is_nav4) gwin.document.write(""); else if(is_ie4up||is_nav5up) gwin.document.write(""); }else if(GWIN==-2){ // 現在位置 if(is_nav4) document.write(""); else if(is_ie4up||is_nav5up) document.write(""); }else{ // フレーム版 if(is_nav4) parent.frames[GWIN].document.write(""); else if(is_ie4up||is_nav5up) parent.frames[GWIN].document.write(""); } if(color==color.toUpperCase()){ line("BLACK",ix1,iy1,ix1,iy2); line("BLACK",ix1,iy1,ix2,iy1); line("BLACK",ix1,iy2,ix2,iy2); line("BLACK",ix2,iy1,ix2,iy2); } } } function fbox(color, x1, y1, z1, x2, y2, z2){ var P1=new Array(), P2=new Array(); xyzcv(x1,y1,z1,P1); xyzcv(x2,y2,z2,P2); gbox(color,P1.x,P1.y,P2.x,P2.y); } function symbol(color, ix, iy, str){ if(DM==3 || DM==4) iy-=SHEIGHT; if(GWIN==-1){ // ウィンドウ版 if(is_nav4) gwin.document.write(""+str+"") else if(is_ie4up||is_nav5up) gwin.document.write(""+str+""); }else if(GWIN==-2){ // 現在位置 if(is_nav4) document.write(""+str+"") else if(is_ie4up||is_nav5up) document.write(""+str+""); }else{ // フレーム版 if(is_nav4) parent.frames[GWIN].document.write(""+str+"") else if(is_ie4up||is_nav5up) parent.frames[GWIN].document.write(""+str+""); } } function symbolk(color,font_size, ix, iy, str){ // 河合雅司氏による拡張 if(DM==3 || DM==4) iy-=SHEIGHT if(GWIN==-1){ // ウィンドウ版 if(is_nav4) gwin.document.write(""+str+""); else if(is_ie4up||is_nav5up) gwin.document.write(""+str+""); }else if(GWIN==-2){ // 現在位置 if(is_nav4) document.write(""+str+""); else if(is_ie4up||is_nav5up) document.write(""+str+""); }else{ // フレーム版 if(is_nav4) parent.frames[GWIN].document.write(""+str+""); else if(is_ie4up||is_nav5up) parent.frames[GWIN].document.write(""+str+""); } } function glib_image(ix, iy, glib_width,glib_height,str,glib_imgid){ // 河合雅司氏による拡張 if(DM==3 || DM==4) iy-=SHEIGHT; if(GWIN==-1){ // ウィンドウ版 if(is_ie4up||is_nav4up) gwin.document.write(""); }else if(GWIN==-2){ // 現在位置 if(is_ie4up||is_nav4up) document.write(""); }else{ // フレーム版 if(is_ie4up||is_nav4up) parent.frames[GWIN].document.write(""); } } function glib_imagemove(ix,iy,glib_imgname){ // 河合雅司氏による拡張 if(DM==3 || DM==4) iy-=SHEIGHT; if(GWIN==-1){ // ウィンドウ版 if(is_ie){ with(gwin.document.images[glib_imgname].style){pixelLeft=ixx(ix);pixelTop=iyy(iy);} }else{ with(gwin.document.images[glib_imgname].style){left=ixx(ix);top=iyy(iy);} } }else if(GWIN==-2){ // 現在位置 if(is_ie){ with(document.images[glib_imgname].style){pixelLeft=ixx(ix);pixelTop=iyy(iy);} }else{ with(document.images[glib_imgname].style){left=ixx(ix);top=iyy(iy);} } }else{ // フレーム版 if(is_ie){ with(parent.frames[GWIN].document.images[glib_imgname].style){pixelLeft=ixx(ix);pixelTop=iyy(iy);} }else{ with(parent.frames[GWIN].document.images[glib_imgname].style){left=ixx(ix);top=iyy(iy);} } } glib_imageon(glib_imgname); } function glib_imageoff(glib_imgname){ // 河合雅司氏による拡張 if(GWIN==-1){ // ウィンドウ版 gwin.document.images[glib_imgname].style.display="none"; }else if(GWIN==-2){ // 現在位置 document.images[glib_imgname].style.display="none"; }else{ // フレーム版 parent.frames[GWIN].document.images[glib_imgname].style.display="none"; } } function glib_imageon(glib_imgname){ // 河合雅司氏による拡張 if(GWIN==-1){ // ウィンドウ版 with(gwin.document.images[glib_imgname]) {style.display="block";} }else if(GWIN==-2){ // 現在位置 document.images[glib_imgname].style.display="block"; }else{ // フレーム版 parent.frames[GWIN].document.images[glib_imgname].style.display="block"; } } function fsymbol(color, x, y, z, str){ var P=new Array(); xyzcv(x,y,z,P); symbol(color,P.x,P.y,str); } function fpconv(w, ref, W){ W.ww=w; var ref10=10*ref; for(var i=0;i<100;i++) if(Math.abs(W.ww)<=ref10){ break;}else{W.ww/=10;} for(var j=0;j<100;j++) if(Math.abs(W.ww)>ref){ break;}else{W.ww*=10;} W.np=i-j } function fltx(wof, span, W){ fpconv(span,1.1,W); if(W.ww>5.1) W.unit=2; else if(W.ww>=0) W.unit=1; else if(W.ww>(-5.1))W.unit=(-1); else W.unit=(-2); W.unit*=Math.pow(10,W.np); var ifix=Math.floor(wof/W.unit); W.org=ifix*(W.unit); var w1=wof+1.1*span; if(wof<=w1){W.min=wof; W.max=w1;} else{ W.min=w1; W.max=wof;} } function cdisp(unit, color, ix, iy, w1, size){ unit=Math.round(unit*1000000)/1000000+""; if(DM==2 || DM==3) ix+=SWIDTH; if(DM==3 || DM==4) iy-=SHEIGHT; if(DM!=2 && DM!=3) ix-=SWIDTH*(unit.length-1); if(is_nav4) symbol(color,ix,iy,""+unit+""); else if(is_ie4up||is_nav5up) symbol(color,ix,iy,""+unit+""); } function xscale(color, fs, str, step){ var P=new Array(), W=new Array(); XFS=fs; XSPAN=fs-XOF; if(XSPAN==0) return; var x1=XOF+XSPAN; fline(color,XOF,YOF,ZOF,x1,YOF,ZOF,1); if(str!=""){ x1=XOF+1.1*XSPAN; xyzcv(x1,YOF,ZOF,P); P.x-=SWIDTH; P.y+=SHEIGHT/2; if(DM==2 || DM==3) P.x+=SWIDTH; if(DM==3 || DM==4) P.y-=SHEIGHT; symbol(color,P.x,P.y,str); } if(step){ if(step>0){ XSTEP=step; for(x1=XOF;x1<=XOF+XSPAN;x1+=step){ xyzcv(x1,YOF,ZOF,P); line(color,P.x,P.y,P.x,P.y-4,1); cdisp(x1,color,P.x-SWIDTH,P.y-2,x1); } }else if(step<0){ XSTEP=step; for(x1=XOF;x1>=XOF+XSPAN;x1+=step){ xyzcv(x1,YOF,ZOF,P); line(color,P.x,P.y,P.x,P.y-4,1); if(x1!=XOF) cdisp(x1,color,P.x-SWIDTH,P.y-2,x1); } } }else{ fltx(XOF,XSPAN,W); XSTEP=W.unit; for(x1=W.org;((XSPAN<0)&&(x1>=W.min))||((XSPAN>0)&&(x1<=W.max));x1+=W.unit){ xyzcv(x1,YOF,ZOF,P); line(color,P.x,P.y,P.x,P.y-4,1); cdisp(x1,color,P.x-SWIDTH,P.y-2,x1); } } } function yscale(color, fs, str, step){ var P=new Array(), W=new Array(), yy; YFS=fs; YSPAN=fs-YOF; if(YSPAN==0) return; var y1=YOF+YSPAN; fline(color,XOF,YOF,ZOF,XOF,y1,ZOF); if(str!=""){ y1=YOF+1.1*YSPAN; xyzcv(XOF,y1,ZOF,P); P.x-=SWIDTH; P.y+=SHEIGHT/2; if(DM==2 || DM==3) P.x+=SWIDTH; if(DM==3 || DM==4) P.y-=SHEIGHT; symbol(color,P.x,P.y,str,2); } if(step){ if(step>0){ YSTEP=step; for(y1=YOF;y1<=YOF+YSPAN;y1+=step){ xyzcv(XOF,y1,ZOF,P); line(color,P.x,P.y,P.x-4,P.y); cdisp(y1,color,P.x-10,P.y+SHEIGHT/2,y1); } }else if(step<0){ YSTEP=step; for(y1=YOF;y1>=YOF+YSPAN;y1+=step){ xyzcv(XOF,y1,ZOF,P); line(color,P.x,P.y,P.x-4,P.y); cdisp(y1,color,P.x-10,P.y+SHEIGHT/2,y1); } } }else{ fltx(YOF,YSPAN,W); YSTEP=W.unit; for(y1=W.org;(YSPAN<0&&y1>=W.min)||(YSPAN>0&&y1<=W.max);y1+=W.unit){ xyzcv(XOF,y1,ZOF,P); line(color,P.x,P.y,P.x-4,P.y); cdisp(y1,color,P.x-10,P.y+SHEIGHT/2,y1); } } } function xygrid(color){ for(var x=XOF;x<=XFS;x+=XSTEP) fline(color,x,YOF,0,x,YFS,0); for(var y=YOF;y<=YFS;y+=YSTEP) fline(color,XOF,y,0,XFS,y,0); } function zscale(color, fs, str, step){ var P=new Array(), W=new Array(), ix,iy,ix1,iy1, org,z1,zz; ZFS=fs; ZSPAN=fs-ZOF; if(ZSPAN==0) return; z1=ZOF+ZSPAN; fline(color,XOF,YOF,ZOF,XOF,YOF,z1); if(str!=""){ z1=ZOF+1.1*ZSPAN; xyzcv(XOF,YOF,z1,P); P.x-=SWIDTH; P.y+=SHEIGHT/2; if(DM==2 || DM==3) P.x+=SWIDTH; if(DM==3 || DM==4) P.y-=SHEIGHT; symbol(color,P.x,P.y,str,2); } if(step){ ZSTEP=step; for(z1=ZOF;z1<=ZOF+ZSPAN;z1=z1+step){ xyzcv(XOF,YOF,z1,P); ix1=P.x; iy1=P.y; if(KZ>=-6 && KZ<=6) iy1+=3; else ix1+=4; line(color,P.x,P.y,ix1,iy1); P.x-=4; P.y-=2; if(KZ<-6 || KZ>6){ P.x-=6; P.y+=6; } cdisp(z1,color,P.x,P.y,z1); } }else{ fltx(ZOF,ZSPAN,W); ZSTEP=W.unit; for(z1=W.org;(ZSPAN<0 && z1>=W.min) || (ZSPAN>0 && z1<=W.max);z1=z1+W.unit){ xyzcv(XOF,YOF,z1,P); ix1=P.x; iy1=P.y; if(KZ>=-6 && KZ<=6) iy1+=3; else ix1+=4; line(color,P.x,P.y,ix1,iy1); P.x-=4; P.y-=2; if(KZ<-6 || KZ>6){ P.x-=6; P.y+=6; } cdisp(z1,color,P.x,P.y,z1); } } } function gplot(ichain, color, x, y, z, s, size){ var ix0,iy0,ix1,iy1,ix2,iy2, i,n,k, x1,y1,z1,x2,y2,z2,d,xk,yk; var P=new Array(), P0=new Array(); if(ichain<0) for(i=1;i<=NCHAIN;i++) iflag[i]=OFF; //chainの初期化 else{ xyzcv(x,y,z,P); if(s=="||"){ xyzcv(x,YOF,z,P0); gbox(color,P.x,P.y,P.x+10,P0.y);} else if(s=="|"){xyzcv(x,YOF,z,P0); gbox(glib_BGCOLOR,P.x,P.y,P.x+10,P0.y);} else if(s=="="){xyzcv(XOF,y,z,P0); gbox(color,P.x,P.y,P0.x,P.y+10);} else if(s=="-"){xyzcv(XOF,y,z,P0); gbox(glib_BGCOLOR,P.x,P.y,P0.x,P.y+10);} else plot0(color,P.x,P.y,s); plot(color,P.x,P.y); if(ichain>=1 && ichain<=NCHAIN){ ix1=ixtable[ichain]; iy1=iytable[ichain]; ixtable[ichain]=P.x; iytable[ichain]=P.y; if(iflag[ichain]==ON) line(color,P.x,P.y,ix1,iy1, size); iflag[ichain]=ON; } } } function sinc(x){with(Math){ //sinc(x)=sin(PI*x)/(PI*x) if(x==0) return 1; else return sin(PI*x)/(PI*x); }} function sinca(x){with(Math){ //sinca(x)=sin(PI*x)/{PI*x*(1-x**2)} var x1; if(x==0) return 1; else if((x1=1-x*x)==0) return .5; else return sin(PI*x)/(PI*x*x1); }} function gauss(v){with(Math){ //zero-mean Gaussian random variable var x=sqrt(-2.*log(random())*v); return x*cos(2.*PI*random()); }} function GRopen(c,x,y,s,m){ gopen(c,x,y,s,m); GRlabel=new Array(); GRarray=new Array(); gplot(-1); } function GRdata(){ GRlabel[GRarray.length]=arguments[0]; gsymbol[GRarray.length]=arguments[1]; gcolor[GRarray.length]= arguments[2]; GRarray[GRarray.length]=new Array(); var row=GRarray[GRarray.length-1]; for(var i=3; ixmax) xmax=GRarray[i][0]; if(GRarray[i][0]