\n'); write('\\n'); write('\\\
\n'); write('\\n'); write('\<\/td\>\<\/tr\>\<\/table\>\n'); write('\'); write("Currently showing: '\" + fx + "\<\/strong\>'"); write('\'); timeDraw = getTimer() - timeDraw; write('Calculation time: \' + (Math.round(timeCalc / 100) / 10) + 's\<\/strong\>, drawing time: \' + (Math.round(timeDraw / 100) / 10) + 's\<\/strong\>'); write('\<\/p\>\n'); write('\<\/center\>\n'); write('\<\/body\>\n'); write('\<\/html\>\n'); close(); } } function doPlot() { var i = 0; fx = document.forms[0].fnfx.value; if(fx == "") return; isWip = true; showWip("Reading form"); xi = parseFloat(document.forms[0].xmin.value); if(isNaN(xi)) { showWip("...x-min invalid"); return; } xa = parseFloat(document.forms[0].xmax.value); if(isNaN(xa)) { showWip("...x-max invalid"); return; } if(xi > xa) { i = xi; xi= xa; xa = i; document.forms[0].xmin.value = xi; document.forms[0].xmax.value = xa; } if(xi == xa) { xa = xi + 0.0001; document.forms[0].xmax.value = xa; } yi = parseFloat(document.forms[0].ymin.value); if(isNaN(yi)) { showWip("...y-min invalid"); return; } ya = parseFloat(document.forms[0].ymax.value); if(isNaN(ya)) { showWip("...y-max invalid"); return; } if(yi > ya) { i = yi; yi= ya; ya = i; document.forms[0].ymin.value = yi; document.forms[0].ymax.value = ya; } if(yi == ya) { ya = yi + 0.0001; document.forms[0].ymax.value = ya; } showWip("...done"); showWip("Parsing function..."); fx = check(fx); if(fx == "") { showWip("...invalid function"); return; } showWip("Preparing calculations"); PicW = document.forms[0].picsize.options[document.forms[0].picsize.selectedIndex].value.split("x")[0]; PicH = document.forms[0].picsize.options[document.forms[0].picsize.selectedIndex].value.split("x")[1]; for(i = 0; i < (PicW / 8) * PicH; i++) PicData[i] = 0; showWip("...done"); showWip("Calculating..."); timeCalc = getTimer(); if(fnType == 3) doPlot3D(); else doPlot2D(); timeCalc = getTimer() - timeCalc; showWip("Generating bitmap..."); timeDraw = getTimer(); updateFrame(); showWip("...done"); // timeDraw = getTimer() - timeDraw; if(!winWip.closed) { winWip.close(); winWip = -1; } } function getTimer() { var t = new Date(); return ((60*t.getHours()+t.getMinutes())*60+t.getSeconds())*1000+t.getMilliseconds(); } function doPlot2D() { var i = 0; var x = 0; var y = 0; var lx = 0; var ly = 0; dx = (xa - xi) / PicW; dy = (ya - yi) / PicH; dxInv = 1 / dx; dyInv = 1 / dy; showWip("...drawing axes"); for(i = xi; i <= xa; i += 2 * (xa - xi) / PicW) pointSetRange(i,0); if(dx <= 0.2) { for(i = 0; i <= xa; i++) pointSetRange(i,-dy); for(i = 0; i >= xi; i--) pointSetRange(i,-dy); } for(i = yi; i <= ya; i += 2 * (ya - yi) / PicH) pointSetRange(0,i); if(dy <= 0.2) { for(i = 0; i <= ya; i++) pointSetRange(dx,i); for(i = 0; i >= yi; i--) pointSetRange(dx,i); } if(fnType == 1) { showWip("...sampling f(x)"); for(x = xi; x <= xa; x += dx) { y = eval(fx); if(!isNaN(y)) { pointSetRange(x,y); lx = x; ly = y; x += dx; break; } } for(; x <= xa; x += dx) { y = eval(fx); if(!isNaN(y)) { if(document.forms[0].pType[1].checked) lineRange(lx,ly,x,y); else pointSetRange(x,y); lx = x; ly = y; } } } else { showWip("...sampling f(y)"); for(y = yi; y <= ya; y += dy) { x = eval(fx); if(!isNaN(x)) { pointSetRange(x,y); lx = x; ly = y; y += dy; break; } } for(; y <= ya; y += dy) { x = eval(fx); if(!isNaN(x)) { if(document.forms[0].pType[1].checked) lineRange(lx,ly,x,y); else pointSetRange(x,y); lx = x; ly = y; } } } showWip("...done"); } function doPlot3D() { var x = 0; var y = 0; var z = 0; var i = 0; var j = 0; var za = -1000000; var zi = 1000000; var graph = new Array(); var sinalpha = sin(3.14159 * 30 / 180); var cosalpha = cos(3.14159 * 30 / 180); var samples = (PicW == 160) ? (12) : ((PicW <= 640) ? (20) : (30)); var cx = PicW / (samples + 0.7 * samples * cosalpha); var cy = 0.7 * cx; showWip("...sampling f(x,y)"); j = 0; for(y = yi; y <= ya; y += (ya - yi) / samples) { graph[j] = new Array(); i = 0; for(x = xi; x <= xa; x += (xa - xi) / samples) { z = eval(fx); if(!isFinite(z)) z = 0; graph[j][i++] = z; if(z < zi) zi = z; if(z > za) za = z; } while(i <= samples) { x = xa; z = eval(fx); if(!isFinite(z)) z = 0; graph[j][i++] = z; if(z < zi) zi = z; if(z > za) za = z; } j++; } while(j <= samples) { graph[j] = new Array(); y = ya; i = 0; for(x = xi; x <= xa; x += (xa - xi) / samples) { z = eval(fx); if(!isFinite(z)) z = 0; graph[j][i++] = z; if(z < zi) zi = z; if(z > za) za = z; } while(i <= samples) { x = xa; z = eval(fx); if(!isFinite(z)) z = 0; graph[j][i++] = z; if(z < zi) zi = z; if(z > za) za = z; } j++; } if(zi == za) za = zi + 0.0001; z = (PicH / 2) / (za - zi); // px1 = x * cx + y * cy * cosalpha; // py1 = y * cy * sinalpha + z * (graph[y][x] - zi); // px2 = (x+1) * cx + y * cy * cosalpha; // py2 = y * cy * sinalpha + z * (graph[y][x+1] - zi); // px3 = (x+1) * cx + (y+1) * cy * cosalpha; // py3 = (y+1) * cy * sinalpha + z * (graph[y+1][x+1] - zi); // px4 = x * cx + (y+1) * cy * cosalpha; // py4 = (y+1) * cy * sinalpha + z * (graph[y+1][x] - zi); // fillArea(px1,PicH-py1,px2,PicH-py2,px3,PicH-py3,px4,PicH-py4) if(document.forms[0].pType[0].checked) showWip("...generating standard wireframe"); else showWip("...generating patterned wireframe"); for(x = 0; x < graph.length - 1; x++) { for(y = graph[x].length - 2; y >= 0; y--) { avH = z * (graph[y][x] + graph[y][x+1] + graph[y+1][x+1] + graph[y+1][x]) / 4 - z * zi; avH = Math.floor(16 * avH / PicH); fillArea(x * cx + y * cy * cosalpha,PicH - y * cy * sinalpha - z * (graph[y][x] - zi),(x+1) * cx + y * cy * cosalpha,PicH - y * cy * sinalpha - z * (graph[y][x+1] - zi),(x+1) * cx + (y+1) * cy * cosalpha,PicH - (y+1) * cy * sinalpha - z * (graph[y+1][x+1] - zi),x * cx + (y+1) * cy * cosalpha,PicH - (y+1) * cy * sinalpha - z * (graph[y+1][x] - zi)); } } showWip("...done"); } function keep() { var f = document.forms[0]; var m = f.mem; if(f.fnfx.value == "") return; m.options[m.length] = new Option(f.fnfx.value,f.xmin.value + " " + f.xmax.value + " " + f.ymin.value + " " + f.ymax.value); m.options[m.length - 1].selected = true; } function recall() { if(document.forms[0].mem.length == 0) return; var f = document.forms[0]; var m = f.mem.options[f.mem.selectedIndex].value.split(" "); f.fnfx.value = f.mem.options[f.mem.selectedIndex].text; f.xmin.value = m[0]; f.xmax.value = m[1]; f.ymin.value = m[2]; f.ymax.value = m[3]; } function remove() { var m = document.forms[0].mem; var t = m.selectedIndex; if(m.length <= 0) return; for(var i = m.selectedIndex + 1; i < m.length; i++) { m.options[i - 1].text = m.options[i].text; m.options[i - 1].value = m.options[i].value; } if(m.length <= t + 1) t--; if(t >= 0) m.options[t].selected = true; m.length -= 1; } function showSupportedFns() { var win2 = window.open("","fn","width=400,height=220,scrollbars=yes,resizable=no,dependent=yes"); with(win2.document) { write('\\\Supported functions\<\/title\>\<\/head\>\\'); writeln('+ - * \/,'); writeln('sin, cos, tan, cot, sec, csc,'); writeln('asin, acos, atan, acot, asec, acsc,'); writeln('sinh, cosh, tanh, coth, sech, csch,'); writeln('asinh, acosh, atanh, acoth, asech, acsch,'); writeln('ln, exp, log, pow, ^, sqrt, sq,'); writeln('inv, ip, fp, abs, sgn,'); writeln('\<, \<=, ==, \>=, \>, !=, ?:'); write('\<\/pre\>'); write('\\\\\<\/form\>\<\/center\>'); write('\<\/body\>\<\/html\>'); close(); } } function showWip(showThis) { if(isWip) { if(winWip != -1 && !winWip.closed) winWip.close(); winWip = -1; } if(winWip == -1) winWip = window.open("","wip","width=400,height=450,scrollbars=yes,resizable=no,dependent=yes"); with(winWip.document) { if(isWip) { isWip = false; close(); open(); writeln('\\\wip\<\/title\>\<\/head\>\\'); } writeln(showThis); } } function showReadme() { with(winGraph.document) { close(); open(); writeln('\'); writeln('\'); writeln('\2D\/3D function plotter v2.3\<\/title\>'); writeln('\<\/head\>'); writeln('\'); writeln('\'); writeln('\'); writeln('\'); writeln('\
'); writeln('\'); writeln('\Invalid functions may produce some JavaScript errors\Those are save to ignore\<\/li\>'); writeln('\Functions are case-insensitive, i.e. sin(x) = Sin(X) = sIN(x)...\<\/li\>'); writeln('\Supports implied multiplication, e.g. 2sin(xy) <=> 2 * sin(x * y)\<\/li\>'); writeln('\Supports \^\<\/strong\> as power-function, i.e. x^3 <=> pow(x,3)\<\/li\>'); writeln('\All trigonometric functions operate in radians\<\/li\>'); writeln('\Line-mode does \not\<\/strong\> check for continuity :)\<\/li\>'); writeln('\\Plotting takes time !\<\/strong\>, even more in 3D\<\/li\>'); writeln('\This frame will be replaced by the actual drawing\<\/li\>'); writeln('\Requires \800x600\<\/strong\>+ with \IE5\<\/strong\>+ or \NS4.5\<\/strong\>+\<\/li\>'); writeln('\Netscape users: avoid 800x450+, unless you have the (virtual) memory to do so\<\/li\>'); writeln('\FAST computer recommended :)\<\/li\>'); writeln('\<\/ul\>'); writeln('\<\/td\>'); writeln('\<\/tr\>'); writeln('\<\/table\>'); writeln('\<\/center\>'); writeln('\<\/body\>'); writeln('\<\/html\>'); close(); } } function doOnLoad() { if(noIFrame) { if(top.location == self.location || self.location != parent.frames[0].location) { with(top.document) { close(); open(); writeln('\'); writeln('\'); writeln('\2D\/3D function plotter v2.3\<\/title\>'); writeln('\<\/head\>'); writeln('\'); writeln('\'); writeln('\'); writeln('\<\/frameset\>'); writeln('\<\/html\>'); close(); } return; } winGraph = parent.frames[1]; } else winGraph = window["graphhere"]; if(isNS) { window.setResizable(true); if(document.width < 750 || document.height < 440) { window.moveTo(16,10); window.resizeTo(Math.max(750,document.width),Math.max(440,document.height)); } } else { if(document.body.clientWidth < 750 || document.body.clientHeight < 560) { window.moveTo(16,10); window.resizeTo(Math.max(750,document.body.clientWidth),Math.max(560,document.body.clientHeight)); } } showReadme(); document.forms[0].reset(); document.forms[0].fnfx.focus(); } // -->
Pic. size:

Plot mode:
Standard
Solid
f(x[,y]) =
x-min: , x-max:
y-min: , y-max:

| |



Fn list...
Readme
Contact