Frame 1
function doCompile(inputstring, varnames) {
function istokf1(chars) {
var _local1 = chars;
i = 0;
while (i < f1Array.length) {
if (_local1 == f1Array[i]) {
return(true);
}
i++;
}
return(false);
}
function isVar(chars) {
var _local1 = chars;
i = 0;
while (i < varnames.length) {
if (_local1 == varnames[i]) {
return(true);
}
i++;
}
return(false);
}
function istokf2(chars) {
var _local1 = chars;
i = 0;
while (i < f2Array.length) {
if (_local1 == f2Array[i]) {
return(true);
}
i++;
}
return(false);
}
function isLet(char) {
return(lets.indexOf(char) >= 0);
}
function isOper(char) {
return(opers.indexOf(char) >= 0);
}
function isNum(char) {
return(nums.indexOf(char) >= 0);
}
function setToken(curtype, curvalue, curlength) {
tokentype = curtype;
tokenvalue = curvalue;
tokenlength = curlength;
}
function nextToken(inputstring, pos) {
var _local1;
var _local3;
var inilen;
var _local2;
var cString;
cString = inputstring;
_local2 = pos;
inilen = inputstring.length;
if ((_local2 >= inilen) || (_local2 < 0)) {
return(false);
}
_local1 = cString.charAt(_local2);
if (isLet(_local1)) {
_local3 = _local1;
do {
_local2 = _local2 + 1;
if (_local2 >= inilen) {
break;
}
_local1 = cString.charAt(_local2);
if (!isLet(_local1)) {
break;
}
_local3 = _local3 + _local1;
} while (1);
if (istokf1(_local3)) {
setToken("f1", _local3, _local3.length);
return(true);
}
if (istokf2(_local3)) {
setToken("f2", _local3, _local3.length);
return(true);
}
setToken("v", _local3, _local3.length);
return(true);
}
if (isNum(_local1)) {
_local3 = _local1;
do {
_local2 = _local2 + 1;
if (_local2 >= inilen) {
break;
}
_local1 = cString.charAt(_local2);
if (!isNum(_local1)) {
break;
}
_local3 = _local3 + _local1;
} while (1);
setToken("n", _local3, _local3.length);
return(true);
}
if (isOper(_local1)) {
setToken("oper", _local1, 1);
return(true);
}
return(false);
}
function checkToks(inputstring) {
var pString;
var _local3;
var _local2;
var _local1;
var bPos;
var fchar;
var bchar;
var counter;
var matchpar;
var iscomma;
var comcounter;
pString = inputstring;
_local2 = 0;
counter = 0;
comcounter = 0;
_local3 = pString.length;
if (pString.indexOf("---") >= 0) {
callError("No need for so many minuses.");
} else {
while ((_local2 < _local3) && (counter < (_local3 * 2))) {
if (nextToken(pString, _local2)) {
_local1 = _local2 + tokenlength;
fchar = pString.charAt(_local1);
bPos = _local2 - 1;
bchar = pString.charAt(bPos);
if (tokentype == "f1") {
if (fchar != "(") {
callError(("'(' expected at position " + _local1) + ".");
return;
}
if ((_local2 > 0) && (!isOper(bchar))) {
callError(("Operator expected at position " + bPos) + ".");
return;
}
if ((_local2 > 0) && (bchar == ")")) {
callError(("Operator expected at position " + bPos) + ".");
return;
}
}
if (tokentype == "f2") {
if ((tokenvalue != "max") && (tokenvalue != "min")) {
callError(("Unknown functions at position " + _local1) + ".");
return;
}
if (fchar != "(") {
callError(("'(' expected at position " + _local1) + ".");
return;
}
matchpar = 1;
iscomma = 0;
comcounter = 0;
while ((matchpar > 0) && (comcounter < _local3)) {
comcounter = comcounter + 1;
if (pString.charAt(_local1 + comcounter) == "(") {
matchpar = matchpar + 1;
}
if (pString.charAt(_local1 + comcounter) == ")") {
matchpar = matchpar + -1;
}
if (pString.charAt(_local1 + comcounter) == ",") {
iscomma = iscomma + 1;
}
}
if (iscomma == 0) {
callError(("Two arguments expected for function at position " + _local2) + ".");
return;
}
if ((_local2 > 0) && (!isOper(bchar))) {
callError(("Operator expected at position " + bPos) + ".");
return;
}
if ((_local2 > 0) && (bchar == ")")) {
callError(("Operator expected at position " + bPos) + ".");
return;
}
}
if (tokentype == "v") {
if (!((isVar(tokenvalue) || (tokenvalue == "pi")) || (tokenvalue == "e"))) {
callError(("Unknown entries at position " + _local2) + ".");
return;
}
if ((_local2 > 0) && (!isOper(bchar))) {
callError(("Operator expected at position " + bPos) + ".");
return;
}
if ((_local2 > 0) && (bchar == ")")) {
callError(("Operator expected at position " + bPos) + ".");
return;
}
if ((_local1 < _local3) && (!isOper(fchar))) {
callError(("Operator expected at position " + _local1) + ".");
return;
}
if ((_local1 < _local3) && (fchar == "(")) {
callError(("Operator expected at position " + _local1) + ".");
return;
}
}
if (tokentype == "n") {
if ((_local2 > 0) && (!isOper(bchar))) {
callError(("Operator expected at position " + bPos) + ".");
return;
}
if ((_local2 > 0) && (bchar == ")")) {
callError(("Operator expected at position " + bPos) + ".");
return;
}
if ((_local1 < _local3) && (!isOper(fchar))) {
callError(("Operator expected at position " + _local1) + ".");
return;
}
if ((_local1 < _local3) && (fchar == "(")) {
callError(("Operator expected at position " + _local1) + ".");
return;
}
}
if (tokenvalue == "(") {
if ((_local1 < _local3) && ("^*,)+/".indexOf(fchar) >= 0)) {
callError(("Entries expected at position " + _local1) + ".");
return;
}
}
if (tokenvalue == ")") {
if ((_local1 < _local3) && ("^*+-,/)".indexOf(fchar) == -1)) {
callError(("Entries expected at position " + _local1) + ".");
return;
}
if ((bPos >= 0) && ("^*+-,/(".indexOf(bchar) >= 0)) {
callError(("Entries expected at position" + _local1) + ".");
return;
}
}
if (tokenvalue == ",") {
if ((_local2 == 0) || (_local2 == (_local3 - 1))) {
callError(("Stray comma at position " + _local2) + ".");
return;
}
if ((_local1 < _local3) && ("^*+,/)".indexOf(fchar) >= 0)) {
callError(("Entries expected at position " + _local1) + ".");
return;
}
if ((bPos >= 0) && ("^*+-,/(".indexOf(bchar) >= 0)) {
callError(("Entries expected at position " + _local1) + ".");
return;
}
}
if ("^/*-+".indexOf(tokenvalue) >= 0) {
if ("+*^/),".indexOf(fchar) >= 0) {
callError(("Entries expected at position " + _local1) + ".");
return;
}
if (("+*^/(,".indexOf(bchar) >= 0) && (tokenvalue != "-")) {
callError(("Entries expected at position " + _local1) + ".");
return;
}
}
} else {
callError("Unknown characters at position ." + _local2);
}
_local2 = _local2 + tokenlength;
counter = counter + 1;
}
}
}
function conOper(inputstring, char) {
var _local2 = char;
var _local1;
var inilen;
var mco;
var curpos;
var _local3;
var rightoper;
inilen = inputstring.length;
_local1 = inputstring;
if (_local1.indexOf(_local2) == -1) {
return(_local1);
}
if ((_local1.indexOf(_local2) == 0) && (_local2 != "-")) {
callError("Error at the first " + _local2);
return("");
}
if (_local1.charAt(_local1.length - 1) == _local2) {
callError(("Error at the last " + _local2) + ".");
return("");
}
mco = 0;
while ((_local1.indexOf(_local2) > 0) && (mco < (inilen * 6))) {
mco = mco + 1;
curpos = _local1.indexOf(_local2);
leftmove = goLeft(_local1, curpos);
if (iserror == 1) {
callError(((("Error at " + _local2) + " number ") + mco) + ".");
return("");
}
_local3 = _local1.substring(leftmove + 1, curpos);
rightmove = goRight(_local1, curpos);
if (iserror == 1) {
callError(((("Error at " + _local2) + " number ") + mco) + ".");
return("");
}
rightoper = _local1.substring(curpos + 1, rightmove);
if (_local2 == "*") {
_local1 = (((((_local1.substring(0, leftmove + 1) + "mul(") + _local3) + ",") + rightoper) + ")") + _local1.substring(rightmove, _local1.length + 1);
}
if (_local2 == "/") {
_local1 = (((((_local1.substring(0, leftmove + 1) + "div(") + _local3) + ",") + rightoper) + ")") + _local1.substring(rightmove, _local1.length + 1);
}
if (_local2 == "-") {
_local1 = (((((_local1.substring(0, leftmove + 1) + "minus(") + _local3) + ",") + rightoper) + ")") + _local1.substring(rightmove, _local1.length + 1);
}
if (_local2 == "+") {
_local1 = (((((_local1.substring(0, leftmove + 1) + "plus(") + _local3) + ",") + rightoper) + ")") + _local1.substring(rightmove, _local1.length + 1);
}
if (_local1.length > (inilen * 7)) {
callError("Oooops!");
return("");
}
}
return(_local1);
}
function conUnary(inputstring) {
var _local1;
var inilen;
var mco;
var curpos;
var _local2;
var _local3;
inilen = inputstring.length;
_local1 = inputstring;
if (_local1.indexOf("-") == -1) {
return(_local1);
}
if (_local1.charAt(_local1.length - 1) == "-") {
callError("Error at the last minus.");
return("");
}
_local2 = 0;
while (_local2 < _local1.length) {
if ((_local1.charAt(_local2) == "-") && (unaryId(_local1.charAt(_local2 - 1)))) {
_local3 = goRight(_local1, _local2);
if (iserror == 1) {
callError("Error at position " + _local2);
return("");
}
_local1 = (((_local1.substring(0, _local2) + "minus(0,") + _local1.substring(_local2 + 1, _local3)) + ")") + _local1.substring(_local3, _local1.length);
}
if (_local1.length > (9 * inilen)) {
callError("Ooops!");
return("");
}
_local2++;
}
return(_local1);
}
function unaryId(char) {
if ("+-,(/*^".indexOf(char) > -1) {
return(true);
}
return(false);
}
function goRight(inputstring, pos) {
var _local2 = inputstring;
var rightchar;
var _local1;
var _local3;
rightchar = _local2.charAt(pos + 1);
_local1 = pos + 1;
if (rightchar == "-") {
_local1 = _local1 + 1;
if (_local1 >= _local2.length) {
iserror = 1;
return(_local1);
}
rightchar = _local2.charAt(_local1);
}
if (nums.indexOf(rightchar) > -1) {
while ((nums.indexOf(_local2.charAt(_local1)) > -1) && (_local1 < _local2.length)) {
_local1 = _local1 + 1;
}
} else if (lets.indexOf(rightchar) > -1) {
while ((lets.indexOf(_local2.charAt(_local1)) > -1) && (_local1 < _local2.length)) {
_local1 = _local1 + 1;
}
if (_local2.charAt(_local1) == "(") {
_local3 = 1;
while ((_local3 > 0) && (_local1 < _local2.length)) {
_local1 = _local1 + 1;
if (_local2.charAt(_local1) == "(") {
_local3 = _local3 + 1;
}
if (_local2.charAt(_local1) == ")") {
_local3 = _local3 + -1;
}
}
}
if (_local3 > 0) {
iserror = 1;
return(_local1);
}
} else if (rightchar == "(") {
_local3 = 1;
while ((_local3 > 0) && (_local1 < _local2.length)) {
_local1 = _local1 + 1;
if (_local2.charAt(_local1) == "(") {
_local3 = _local3 + 1;
}
if (_local2.charAt(_local1) == ")") {
_local3 = _local3 + -1;
}
}
_local1 = _local1 + 1;
if (_local3 > 0) {
iserror = 1;
return(_local1);
}
} else {
iserror = 1;
return(_local1);
}
return(_local1);
}
function goLeft(inputstring, pos) {
var _local2 = inputstring;
var leftchar;
var _local1;
var _local3;
leftchar = _local2.charAt(pos - 1);
_local1 = pos - 1;
if (nums.indexOf(leftchar) > -1) {
while ((nums.indexOf(_local2.charAt(_local1)) > -1) && (_local1 >= 0)) {
_local1 = _local1 + -1;
}
} else if (lets.indexOf(leftchar) > -1) {
while ((lets.indexOf(_local2.charAt(_local1)) > -1) && (_local1 >= 0)) {
_local1 = _local1 + -1;
}
} else if (leftchar == ")") {
_local3 = 1;
if (_local1 == 0) {
iserror = 1;
return(_local1);
}
while ((_local3 > 0) && (_local1 > 0)) {
_local1 = _local1 + -1;
if (_local2.charAt(_local1) == ")") {
_local3 = _local3 + 1;
}
if (_local2.charAt(_local1) == "(") {
_local3 = _local3 + -1;
}
}
_local1 = _local1 + -1;
if (_local3 > 0) {
iserror = 1;
return(_local1);
}
if ((_local1 >= 0) && (nums.indexOf(_local2.charAt(_local1)) > -1)) {
iserror = 1;
return(_local1);
}
if (((_local1 == 0) && (_local2.charAt(_local1) != "-")) && (_local2.charAt(_local1) != "(")) {
iserror = 1;
return(_local1);
}
if ((_local1 > 0) && (lets.indexOf(_local2.charAt(_local1)) > -1)) {
while ((lets.indexOf(_local2.charAt(_local1)) > -1) && (_local1 >= 0)) {
_local1 = _local1 + -1;
}
}
} else {
iserror = 1;
return(_local1);
}
return(_local1);
}
function conCaret(inputstring) {
var _local1;
var inilen;
var _local3;
var _local2;
var leftmove;
var rightmove;
var base;
var expon;
inilen = inputstring.length;
_local1 = inputstring;
if (_local1.indexOf("^") == -1) {
return(_local1);
}
if (_local1.indexOf("^") == 0) {
callError("Error at the first ^.");
return("");
}
if (_local1.charAt(_local1.length - 1) == "^") {
callError("Error at the last ^.");
return("");
}
_local3 = 0;
while ((_local1.indexOf("^") > 0) && (_local3 < (inilen * 6))) {
_local3 = _local3 + 1;
_local2 = _local1.lastIndexOf("^");
leftmove = goLeft(_local1, _local2);
if (iserror == 1) {
callError(("Error at ^ number " + _local3) + " from the end.");
return("");
}
base = _local1.substring(leftmove + 1, _local2);
rightmove = goRight(_local1, _local2);
if (iserror == 1) {
callError(("Error at ^ number " + _local3) + " from the end.");
return("");
}
expon = _local1.substring(_local2 + 1, rightmove);
_local1 = (((((_local1.substring(0, leftmove + 1) + "pow(") + base) + ",") + expon) + ")") + _local1.substring(rightmove, _local1.length + 1);
if (_local1.length > (inilen * 7)) {
callError("Oooops!");
return("");
}
}
return(_local1);
}
function whiteSpaces(inputstring) {
var _local2;
var _local1;
var inilen;
var _local3 = 0;
inilen = inputstring.length;
_local1 = inputstring.toLowerCase();
while ((_local1.indexOf(" ") > -1) && (_local3 < (inilen + 1))) {
_local2 = _local1.indexOf(" ");
_local1 = _local1.substring(0, _local2) + _local1.substring(_local2 + 1, _local1.length);
_local3 = _local3 + 1;
}
return(_local1);
}
function checkLegal(inputstring) {
var _local3 = inputstring;
var _local2;
var legal;
var _local1;
if (_local3 == "") {
callError("Empty input.");
return(false);
}
_local2 = 0;
while (_local2 < _local3.length) {
_local1 = _local3.charAt(_local2);
legal = (nums.indexOf(_local1) + lets.indexOf(_local1)) + opers.indexOf(_local1);
if (legal == -3) {
callError("Unknown characters.");
return(false);
}
_local2++;
}
return(true);
}
function checkPars(inputstring) {
var _local2 = inputstring;
var i;
var _local1;
var matchpar;
var left = 0;
var right = 0;
var _local3 = 0;
i = 0;
while (i < _local2.length) {
if (_local2.charAt(i) == "(") {
left = left + 1;
}
if (_local2.charAt(i) == ")") {
right = right + 1;
}
i++;
}
if (left != right) {
callError("Mismatched parenthesis.");
return(false);
}
_local1 = 0;
while (_local1 < _local2.length) {
if (_local2.charAt(_local1) == "(") {
matchpar = 1;
_local3 = 0;
while ((matchpar > 0) && (_local3 < _local2.length)) {
_local3 = _local3 + 1;
if (_local2.charAt(_local1 + _local3) == "(") {
matchpar = matchpar + 1;
}
if (_local2.charAt(_local1 + _local3) == ")") {
matchpar = matchpar + -1;
}
}
if (matchpar > 0) {
_local1 = _local1 + 1;
callError("Mismatched parenthesis at position number " + _local1);
return(false);
}
}
_local1++;
}
_local1 = 0;
while (_local1 < _local2.length) {
if (_local2.charAt(_local1) == ")") {
matchpar = 1;
_local3 = 0;
while ((matchpar > 0) && (_local3 < _local2.length)) {
_local3 = _local3 + 1;
if (_local2.charAt(_local1 - _local3) == ")") {
matchpar = matchpar + 1;
}
if (_local2.charAt(_local1 - _local3) == "(") {
matchpar = matchpar + -1;
}
}
if (matchpar > 0) {
_local1 = _local1 + 1;
callError("Mismatched parenthesis at position number " + _local1);
return(false);
}
}
_local1++;
}
return(true);
}
function makeStack(inputstring) {
var mString;
var minilen;
var mPos;
var mStack;
var checkStack;
var checkExpr;
var counter;
mString = inputstring;
mPos = 0;
mStack = [];
checkStack = [];
minilen = mString.length;
checkExpr = [];
checkResult = [];
counter = 0;
while ((mPos < minilen) && (counter < (minilen * 2))) {
if (nextToken(mString, mPos)) {
if (tokentype == "f1") {
mStack.push(eval (tokenvalue));
mStack.push("f1");
checkStack.push(sin);
checkStack.push("f1");
}
if (tokentype == "f2") {
mStack.push(eval (tokenvalue));
mStack.push("f2");
checkStack.push(plus);
checkStack.push("f2");
}
if (tokentype == "v") {
mStack.push(tokenvalue);
mStack.push("v");
checkStack.push("x");
checkStack.push("v");
}
if (tokentype == "n") {
mStack.push(Number(tokenvalue));
mStack.push("n");
checkStack.push(Number(tokenvalue));
checkStack.push("n");
}
} else {
callError("Unknown characters.");
return([]);
}
mPos = mPos + tokenlength;
counter = counter + 1;
}
mStack.reverse();
checkExpr = checkStack.reverse();
checkEval(checkExpr);
if (iserror == 1) {
return([]);
}
return(mStack);
}
function callError(mess) {
errorMes = "Syntax error. " + mess;
iserror = 1;
}
function checkEval(compiledExpression) {
var _local3 = "";
var _local1 = [];
var arg1;
var arg2;
var _local2 = 0;
while (_local2 < compiledExpression.length) {
_local3 = compiledExpression[_local2++];
if (_local3 == "n") {
_local1.push(compiledExpression[_local2]);
} else if (_local3 == "v") {
_local1.push(1);
} else if (_local3 == "f1") {
if (_local1.length < 1) {
callError("Check number of arguments in your functions.");
return;
}
_local1.push(compiledExpression[_local2](_local1.pop()));
} else if (_local3 == "f2") {
if (_local1.length < 2) {
callError("Check number of arguments in your functions.");
return;
}
arg1 = _local1.pop();
arg2 = _local1.pop();
_local1.push(compiledExpression[_local2](arg1, arg2));
} else {
callError("Can't evaluate.");
return;
}
_local2++;
}
if (_local1.length != 1) {
callError("");
} else if (isNaN(_local1[0])) {
callError("");
}
}
var iserror = 0;
var errorMes = "";
var stepString;
var conString;
var tokenvalue;
var tokentype;
var tokenlength;
var nums = "0123456789.";
var lets = "abcdefghijklmnopqrstuwvxzy";
var opers = "^*+-/(),";
var fStack = [];
stepString = whiteSpaces(inputstring);
checkLegal(stepString);
if (iserror == 1) {
return([[], errorMes, 1]);
}
checkPars(stepString);
if (iserror == 1) {
return([[], errorMes, 1]);
}
checkToks(stepString);
if (iserror == 1) {
return([[], errorMes, 1]);
}
conString = conOper(conOper(conOper(conOper(conUnary(conCaret(stepString)), "/"), "*"), "-"), "+");
if (iserror == 1) {
return([[], errorMes, 1]);
}
fStack = makeStack(conString);
if (iserror == 1) {
return([[], errorMes, 1]);
}
return([fStack, "", 0]);
}
function sin(a) {
return(Math.sin(a));
}
function cos(a) {
return(Math.cos(a));
}
function tan(a) {
return(Math.tan(a));
}
function ln(a) {
return(Math.log(a));
}
function sqrt(a) {
return(Math.sqrt(a));
}
function abs(a) {
return(Math.abs(a));
}
function asin(a) {
return(Math.asin(a));
}
function acos(a) {
return(Math.acos(a));
}
function atan(a) {
return(Math.atan(a));
}
function floor(a) {
return(Math.floor(a));
}
function ceil(a) {
return(Math.ceil(a));
}
function round(a) {
return(Math.round(a));
}
function max(a, b) {
return(Math.max(a, b));
}
function min(a, b) {
return(Math.min(a, b));
}
function plus(a, b) {
return(a + b);
}
function minus(a, b) {
return(a - b);
}
function mul(a, b) {
return(a * b);
}
function div(a, b) {
return(a / b);
}
function pow(a, b) {
var _local1 = b;
var _local2 = a;
if ((_local2 < 0) && (_local1 == Math.floor(_local1))) {
if (_local1 % 2) {
return(-Math.pow(-_local2, _local1));
}
return(Math.pow(-_local2, _local1));
}
if ((_local2 == 0) && (_local1 > 0)) {
return(0);
}
return(Math.pow(_local2, _local1));
}
function doEval(compiledExpression) {
var entrytype = "";
var operands = [];
var arg1;
var arg2;
var i = 0;
while (i < compiledExpression.length) {
entrytype = compiledExpression[i++];
if (entrytype == "n") {
operands.push(compiledExpression[i]);
} else if (entrytype == "v") {
operands.push(eval (compiledExpression[i]));
} else if (entrytype == "f1") {
operands.push(compiledExpression[i](operands.pop()));
} else if (entrytype == "f2") {
arg1 = operands.pop();
arg2 = operands.pop();
operands.push(compiledExpression[i](arg1, arg2));
} else {
return(false);
}
i++;
}
return(operands[0]);
}
function parseRange(str) {
var _local1 = str;
var front;
var numfront;
var back;
var _local2;
var _local3;
_local1 = _local1.toLowerCase();
_local2 = _local1.indexOf("*");
if (_local2 == -1) {
if (_local1 == "pi") {
return(Math.PI);
}
if (_local1 == "-pi") {
return(-3.14159265358979);
}
_local3 = Number(_local1);
if (notLegalValue(_local3)) {
outCallError("Check your t- range. Mulitples of pi must be entered as 0.5*pi and not pi/2 or pi*0.5.");
return(0);
}
} else {
front = _local1.substring(0, _local2);
back = _local1.substring(_local2 + 1, _local1.length);
numfront = Number(front);
if (notLegalValue(numfront)) {
outCallError("Check your t- range. Mulitples of pi must be entered as 0.5*pi and not pi/2 or pi*0.5.");
return(0);
}
if (back != "pi") {
outCallError("Check your t- range. Mulitples of pi must be entered as 0.5*pi and not pi/2 or pi*0.5.");
return(0);
}
_local3 = numfront * Math.PI;
}
return(_local3);
}
function signum(a, b) {
if ((b - a) > 0) {
return(1);
}
if ((b - a) < 0) {
return(-1);
}
return(0);
}
function prepReset() {
var j;
var k;
outIsError = 0;
outErrorMes = "";
errorbox._visible = false;
pixArray = [];
funArray = [];
compiledExpr1 = [];
compiledExpr2 = [];
compiledExpr3 = [];
newy = [0, 1, 0];
prepAxes();
dispxbox._visible = true;
dispybox._visible = true;
dispzbox._visible = true;
boxzmax._visible = true;
boxzmin._visible = true;
boxxmax._visible = true;
boxxmin._visible = true;
boxymax._visible = true;
boxymin._visible = true;
sxmin = "-1";
sxmax = "1";
symin = "-1";
symax = "1";
szmin = "-1";
szmax = "1";
}
function drawReset() {
j = 0;
while (j <= mesh) {
board["patch_" + j].clear();
j++;
}
}
function axesReset() {
k = 1;
while (k <= 12) {
board["side" + k].clear();
k++;
}
}
function procInput() {
prepGraph();
if (outIsError == 1) {
return(undefined);
}
drawGraph(1, 0, 0, -21.496046148071);
drawGraph(newy[0], newy[1], newy[2], 23.5619449019234);
}
function iniClips() {
var _local2;
var _local1;
_local1 = 1;
while (_local1 <= 12) {
board.createEmptyMovieClip("side" + _local1, _local1);
_local1++;
}
_local2 = 0;
while (_local2 < mesh) {
board.createEmptyMovieClip("patch_" + _local2, _local2 + 14);
_local2++;
}
}
function funcToGraph(a) {
var _local3;
var _local2;
var _local1;
t = a;
_local3 = doEval(compiledExpr1);
_local2 = doEval(compiledExpr2);
_local1 = doEval(compiledExpr3);
return([_local3, _local2, _local1]);
}
function notLegalValue(a) {
var _local1 = a;
if (((typeof(_local1) != "number") || (isNaN(_local1))) || (!isFinite(_local1))) {
return(true);
}
return(false);
}
function isLegal(a) {
if (!notLegalValue(a)) {
return(true);
}
return(false);
}
function outCallError(mes) {
outErrorMes = mes;
outIsError = 1;
drawReset();
axesReset();
errorbox._visible = true;
dispxbox._visible = false;
dispybox._visible = false;
dispzbox._visible = false;
boxzmax._visible = false;
boxzmin._visible = false;
boxxmax._visible = false;
boxxmin._visible = false;
boxymax._visible = false;
boxymin._visible = false;
sxmin = "";
sxmax = "";
symin = "";
symax = "";
szmin = "";
szmax = "";
}
function prepGraph() {
var i;
var _local1;
var curx;
var _local3;
var _local2;
var curt;
var lastymin;
var lastymax;
var lastxmin;
var lastxmax;
var lastzmin;
var lastzmax;
var ourarray1 = [];
var ourarray2 = [];
var ourarray3 = [];
var inipo = [];
prepReset();
tmin = parseRange(stmin);
if (outIsError == 1) {
} else {
tmax = parseRange(stmax);
if (outIsError == 1) {
} else if (((tmax <= tmin) || (notLegalValue(tmax))) || (notLegalValue(tmin))) {
outCallError("Check your t- range.");
} else if (((inpString1.length == 0) || (inpString2.length == 0)) || (inpString3.length == 0)) {
} else {
outarray1 = doCompile(inpString1, ["t"]);
if (outarray1[2] == 1) {
outCallError("Error in formula for y. " + outarray1[1]);
} else {
compiledExpr1 = outarray1[0];
outarray2 = doCompile(inpString2, ["t"]);
if (outarray2[2] == 1) {
outCallError("Error in formula for z. " + outarray2[1]);
} else {
compiledExpr2 = outarray2[0];
outarray3 = doCompile(inpString3, ["t"]);
if (outarray3[2] == 1) {
outCallError("Error in formula for x. " + outarray3[1]);
} else {
compiledExpr3 = outarray3[0];
inipo = funcToGraph(tmin);
lastymin = inipo[1];
lastymax = lastymin;
lastxmin = inipo[0];
lastxmax = lastxmin;
lastzmin = inipo[2];
lastzmax = lastzmin;
_local1 = 0;
while (_local1 <= mesh) {
funArray[_local1] = [];
curt = tmin + ((_local1 * (tmax - tmin)) / mesh);
funArray[_local1] = funcToGraph(curt);
curx = funArray[_local1][0];
_local3 = funArray[_local1][1];
_local2 = funArray[_local1][2];
if (notLegalValue(lastymin)) {
lastymin = _local3;
} else if ((_local3 < lastymin) && isLegal(_local3)) {
lastymin = _local3;
} else {
lastymin = lastymin + 0;
}
if (notLegalValue(lastymax)) {
lastymax = _local3;
} else if ((_local3 > lastymax) && isLegal(_local3)) {
lastymax = _local3;
} else {
lastymax = lastymax + 0;
}
if (notLegalValue(lastxmin)) {
lastxmin = curx;
} else if ((curx < lastxmin) && isLegal(curx)) {
lastxmin = curx;
} else {
lastxmin = lastxmin + 0;
}
if (notLegalValue(lastxmax)) {
lastxmax = curx;
} else if ((curx > lastxmax) && isLegal(curx)) {
lastxmax = curx;
} else {
lastxmax = lastxmax + 0;
}
if (notLegalValue(lastzmin)) {
lastzmin = _local2;
} else if ((_local2 < lastzmin) && isLegal(_local2)) {
lastzmin = _local2;
} else {
lastzmin = lastzmin + 0;
}
if (notLegalValue(lastzmax)) {
lastzmax = _local2;
} else if ((_local2 > lastzmax) && isLegal(_local2)) {
lastzmax = _local2;
} else {
lastzmax = lastzmax + 0;
}
_local1++;
}
ymin = lastymin;
ymax = lastymax;
zmin = lastzmin;
zmax = lastzmax;
xmin = lastxmin;
xmax = lastxmax;
if (((((notLegalValue(xmin) || (notLegalValue(xmax))) || (notLegalValue(ymin))) || (notLegalValue(ymax))) || (notLegalValue(zmin))) || (notLegalValue(zmax))) {
outCallError("Your expressions have too many singularities is the range.");
} else {
if (ymax == ymin) {
ymax = ymax + 0.5;
ymin = ymin + -0.5;
}
symax = String(Math.round(ymax * 1000) / 1000);
symin = String(Math.round(ymin * 1000) / 1000);
if (zmax == zmin) {
zmax = zmax + 0.5;
zmin = zmin + -0.5;
}
szmax = String(Math.round(zmax * 1000) / 1000);
szmin = String(Math.round(zmin * 1000) / 1000);
if (xmax == xmin) {
xmax = xmax + 0.5;
xmin = xmin + -0.5;
}
sxmax = String(Math.round(xmax * 1000) / 1000);
sxmin = String(Math.round(xmin * 1000) / 1000);
if (constr == "On") {
maxLen = Math.max(zmax - zmin, Math.max(ymax - ymin, xmax - xmin));
sxmax = String(Math.round((((xmax + xmin) / 2) + (maxLen / 2)) * 1000) / 1000);
sxmin = String(Math.round((((xmax + xmin) / 2) - (maxLen / 2)) * 1000) / 1000);
symax = String(Math.round((((ymax + ymin) / 2) + (maxLen / 2)) * 1000) / 1000);
symin = String(Math.round((((ymax + ymin) / 2) - (maxLen / 2)) * 1000) / 1000);
szmax = String(Math.round((((zmax + zmin) / 2) + (maxLen / 2)) * 1000) / 1000);
szmin = String(Math.round((((zmax + zmin) / 2) - (maxLen / 2)) * 1000) / 1000);
}
_local1 = 0;
while (_local1 <= mesh) {
pixArray[_local1] = [];
pixArray[_local1][0] = xtoPix(funArray[_local1][0]);
pixArray[_local1][1] = ytoPix(funArray[_local1][1]);
pixArray[_local1][2] = ztoPix(funArray[_local1][2]);
if ((isLegal(funArray[_local1][0]) && isLegal(funArray[_local1][1])) && isLegal(funArray[_local1][2])) {
funArray[_local1] = [0];
} else {
funArray[_local1] = [1];
}
_local1++;
}
}
}
}
}
}
}
}
function drawGraph(x, y, z, ang) {
var _local1;
var _local2 = [];
var _local3 = rotMatrix(x, y, z, ang);
drawReset();
if (outIsError == 1) {
} else {
drawAxes(x, y, z, ang);
newy = matrixByVector(_local3, newy);
if (((inpString1.length == 0) || (inpString2.length == 0)) || (inpString3.length == 0)) {
} else {
_local1 = 0;
while (_local1 <= mesh) {
_local2[_local1] = [];
pixArray[_local1] = matrixByVector(_local3, pixArray[_local1]);
_local2[_local1] = projectPoint(pixArray[_local1]);
_local1++;
}
_local1 = 0;
while (_local1 < mesh) {
if ((funArray[_local1][0] + funArray[_local1 + 1][0]) == 0) {
if (colorchoice == 1) {
colo = 16711680 /* 0xFF0000 */;
} else if (colorchoice == 2) {
colo = 65280;
} else if (colorchoice == 3) {
colo = 6750207 /* 0x66FFFF */;
} else {
colo = 16776960 /* 0xFFFF00 */;
}
board["patch_" + _local1].lineStyle(1, colo, 100);
board["patch_" + _local1].moveTo(_local2[_local1][0], _local2[_local1][1]);
board["patch_" + _local1].lineTo(_local2[_local1 + 1][0], _local2[_local1 + 1][1]);
}
_local1++;
}
}
}
}
function prepAxes() {
p1 = [-size, -size, -size];
p2 = [-size, size, -size];
p3 = [-size, size, size];
p4 = [size, size, size];
p5 = [size, size, -size];
p6 = [size, -size, -size];
p7 = [-size, -size, size];
p8 = [size, -size, size];
}
function drawAxes(a, b, c, alpha) {
function mag(m1, m2) {
if (m1 >= m2) {
return(-1);
}
if (m1 < m2) {
return(1);
}
}
var dp1;
var _local3;
var dp3;
var dp4;
var _local1;
var avx;
var avy;
var avz;
var camer;
var newdept;
var comMatrix = rotMatrix(a, b, c, alpha);
_local1 = 1;
while (_local1 <= 6) {
this["mid" + _local1] = 0;
_local1++;
}
var mids = [];
var _local2 = [];
axesReset();
p1 = matrixByVector(comMatrix, p1);
dp1 = projectPoint(p1);
p2 = matrixByVector(comMatrix, p2);
_local3 = projectPoint(p2);
p3 = matrixByVector(comMatrix, p3);
dp3 = projectPoint(p3);
p4 = matrixByVector(comMatrix, p4);
dp4 = projectPoint(p4);
p5 = matrixByVector(comMatrix, p5);
dp5 = projectPoint(p5);
p6 = matrixByVector(comMatrix, p6);
dp6 = projectPoint(p6);
p7 = matrixByVector(comMatrix, p7);
dp7 = projectPoint(p7);
p8 = matrixByVector(comMatrix, p8);
dp8 = projectPoint(p8);
dispybox._x = ((_local3[0] + dp5[0]) / 2) + 181;
dispybox._y = ((_local3[1] + dp5[1]) / 2) + 177;
boxymin._x = (_local3[0] + (signum(_local3[0], dp5[0]) * 10)) + 181;
boxymin._y = (_local3[1] + (signum(_local3[1], dp5[1]) * 15)) + 177;
boxymax._x = (dp5[0] - (signum(_local3[0], dp5[0]) * 10)) + 181;
boxymax._y = (dp5[1] - (signum(_local3[1], dp5[1]) * 10)) + 177;
dispxbox._x = ((_local3[0] + dp3[0]) / 2) + 181;
dispxbox._y = ((_local3[1] + dp3[1]) / 2) + 177;
boxxmin._x = (_local3[0] + (signum(_local3[0], dp3[0]) * 10)) + 181;
boxxmin._y = (_local3[1] + (signum(_local3[1], dp3[1]) * 10)) + 177;
boxxmax._x = (dp3[0] - (signum(_local3[0], dp3[0]) * 10)) + 181;
boxxmax._y = (dp3[1] - (signum(_local3[1], dp3[1]) * 10)) + 177;
dispzbox._x = ((_local3[0] + dp1[0]) / 2) + 181;
dispzbox._y = ((_local3[1] + dp1[1]) / 2) + 177;
boxzmin._x = (_local3[0] + (signum(_local3[0], dp1[0]) * 10)) + 181;
boxzmin._y = (_local3[1] + (signum(_local3[1], dp1[1]) * 20)) + 177;
boxzmax._x = (dp1[0] - (signum(_local3[0], dp1[0]) * 10)) + 181;
boxzmax._y = (dp1[1] - (signum(_local3[1], dp1[1]) * 10)) + 177;
avx = (((p7[0] + p8[0]) + p3[0]) + p4[0]) / 4;
avy = (((p7[1] + p8[1]) + p3[1]) + p4[1]) / 4;
avz = (((p7[2] + p8[2]) + p3[2]) + p4[2]) / 4;
camer = Math.sqrt((Math.pow(avx, 2) + Math.pow(avy, 2)) + Math.pow(fLength - avz, 2));
newdept = 1000000 - Math.floor(camer * 100);
this.mid1 = newdept;
avx = (((p8[0] + p6[0]) + p4[0]) + p5[0]) / 4;
avy = (((p8[1] + p6[1]) + p4[1]) + p5[1]) / 4;
avz = (((p8[2] + p6[2]) + p4[2]) + p5[2]) / 4;
camer = Math.sqrt((Math.pow(avx, 2) + Math.pow(avy, 2)) + Math.pow(fLength - avz, 2));
newdept = 1000000 - Math.floor(camer * 100);
this.mid2 = newdept;
avx = (((p1[0] + p6[0]) + p2[0]) + p5[0]) / 4;
avy = (((p1[1] + p6[1]) + p2[1]) + p5[1]) / 4;
avz = (((p1[2] + p6[2]) + p2[2]) + p5[2]) / 4;
camer = Math.sqrt((Math.pow(avx, 2) + Math.pow(avy, 2)) + Math.pow(fLength - avz, 2));
newdept = 1000000 - Math.floor(camer * 100);
this.mid3 = newdept;
avx = (((p1[0] + p2[0]) + p3[0]) + p7[0]) / 4;
avy = (((p1[1] + p2[1]) + p3[1]) + p7[1]) / 4;
avz = (((p1[2] + p2[2]) + p3[2]) + p7[2]) / 4;
camer = Math.sqrt((Math.pow(avx, 2) + Math.pow(avy, 2)) + Math.pow(fLength - avz, 2));
newdept = 1000000 - Math.floor(camer * 100);
this.mid4 = newdept;
avx = (((p8[0] + p6[0]) + p1[0]) + p7[0]) / 4;
avy = (((p8[1] + p6[1]) + p1[1]) + p7[1]) / 4;
avz = (((p8[2] + p6[2]) + p1[2]) + p7[2]) / 4;
camer = Math.sqrt((Math.pow(avx, 2) + Math.pow(avy, 2)) + Math.pow(fLength - avz, 2));
newdept = 1000000 - Math.floor(camer * 100);
this.mid5 = newdept;
avx = (((p2[0] + p3[0]) + p4[0]) + p5[0]) / 4;
avy = (((p2[1] + p3[1]) + p4[1]) + p5[1]) / 4;
avz = (((p2[2] + p3[2]) + p4[2]) + p5[2]) / 4;
camer = Math.sqrt((Math.pow(avx, 2) + Math.pow(avy, 2)) + Math.pow(fLength - avz, 2));
newdept = 1000000 - Math.floor(camer * 100);
this.mid6 = newdept;
mids = [this.mid1, this.mid2, this.mid3, this.mid4, this.mid5, this.mid6];
mids.sort(mag);
i = 1;
while (i <= 6) {
_local1 = 1;
while (_local1 <= 6) {
if (this["mid" + i] == mids[_local1 - 1]) {
_local2[_local1 - 1] = "wall" + i;
}
_local1++;
}
i++;
}
index1 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall3") || (_local2[_local1] == "wall4")) {
index1 = 1;
}
_local1++;
}
if (index1 == 1) {
board.side1.swapDepths(1001);
board.side1.lineStyle(1, 13421772, 100);
} else {
board.side1.swapDepths(1);
board.side1.lineStyle(1, 6710886, 100);
}
index2 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall6") || (_local2[_local1] == "wall4")) {
index2 = 1;
}
_local1++;
}
if (index2 == 1) {
board.side2.swapDepths(1002);
board.side2.lineStyle(1, 13421772, 100);
} else {
board.side2.swapDepths(2);
board.side2.lineStyle(1, 6710886, 100);
}
index3 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall6") || (_local2[_local1] == "wall1")) {
index3 = 1;
}
_local1++;
}
if (index3 == 1) {
board.side3.swapDepths(1003);
board.side3.lineStyle(1, 13421772, 100);
} else {
board.side3.swapDepths(3);
board.side3.lineStyle(1, 6710886, 100);
}
index4 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall6") || (_local2[_local1] == "wall2")) {
index4 = 1;
}
_local1++;
}
if (index4 == 1) {
board.side4.swapDepths(1004);
board.side4.lineStyle(1, 13421772, 100);
} else {
board.side4.swapDepths(4);
board.side4.lineStyle(1, 6710886, 100);
}
index5 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall6") || (_local2[_local1] == "wall3")) {
index5 = 1;
}
_local1++;
}
if (index5 == 1) {
board.side5.swapDepths(1005);
board.side5.lineStyle(1, 13421772, 100);
} else {
board.side5.swapDepths(5);
board.side5.lineStyle(1, 6710886, 100);
}
index6 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall2") || (_local2[_local1] == "wall3")) {
index6 = 1;
}
_local1++;
}
if (index6 == 1) {
board.side6.swapDepths(1006);
board.side6.lineStyle(1, 13421772, 100);
} else {
board.side6.swapDepths(6);
board.side6.lineStyle(1, 6710886, 100);
}
index7 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall5") || (_local2[_local1] == "wall3")) {
index7 = 1;
}
_local1++;
}
if (index7 == 1) {
board.side7.swapDepths(1007);
board.side7.lineStyle(1, 13421772, 100);
} else {
board.side7.swapDepths(7);
board.side7.lineStyle(1, 6710886, 100);
}
index8 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall5") || (_local2[_local1] == "wall4")) {
index8 = 1;
}
_local1++;
}
if (index8 == 1) {
board.side8.swapDepths(1008);
board.side8.lineStyle(1, 13421772, 100);
} else {
board.side8.swapDepths(8);
board.side8.lineStyle(1, 6710886, 100);
}
index9 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall5") || (_local2[_local1] == "wall1")) {
index9 = 1;
}
_local1++;
}
if (index9 == 1) {
board.side9.swapDepths(1009);
board.side9.lineStyle(1, 13421772, 100);
} else {
board.side9.swapDepths(9);
board.side9.lineStyle(1, 6710886, 100);
}
index10 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall5") || (_local2[_local1] == "wall2")) {
index10 = 1;
}
_local1++;
}
if (index10 == 1) {
board.side10.swapDepths(1010);
board.side10.lineStyle(1, 13421772, 100);
} else {
board.side10.swapDepths(10);
board.side10.lineStyle(1, 6710886, 100);
}
index11 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall1") || (_local2[_local1] == "wall4")) {
index11 = 1;
}
_local1++;
}
if (index11 == 1) {
board.side11.swapDepths(1011);
board.side11.lineStyle(1, 13421772, 100);
} else {
board.side11.swapDepths(11);
board.side11.lineStyle(1, 6710886, 100);
}
index12 = 0;
_local1 = 0;
while (_local1 < 3) {
if ((_local2[_local1] == "wall1") || (_local2[_local1] == "wall2")) {
index12 = 1;
}
_local1++;
}
if (index12 == 1) {
board.side12.swapDepths(1012);
board.side12.lineStyle(1, 13421772, 100);
} else {
board.side12.swapDepths(12);
board.side12.lineStyle(1, 6710886, 100);
}
if (board.side1.getDepth() < 10) {
dispzbox._visible = false;
boxzmax._visible = false;
boxzmin._visible = false;
} else {
dispzbox._visible = true;
boxzmax._visible = true;
boxzmin._visible = true;
}
if (board.side5.getDepth() < 10) {
dispybox._visible = false;
boxymin._visible = false;
boxymax._visible = false;
} else {
dispybox._visible = true;
boxymin._visible = true;
boxymax._visible = true;
}
if (board.side2.getDepth() < 10) {
dispxbox._visible = false;
boxxmax._visible = false;
boxxmin._visible = false;
} else {
dispxbox._visible = true;
boxxmax._visible = true;
boxxmin._visible = true;
}
board.side1.moveTo(dp1[0], dp1[1]);
board.side1.lineTo(_local3[0], _local3[1]);
board.side2.moveTo(_local3[0], _local3[1]);
board.side2.lineTo(dp3[0], dp3[1]);
board.side3.moveTo(dp3[0], dp3[1]);
board.side3.lineTo(dp4[0], dp4[1]);
board.side4.moveTo(dp4[0], dp4[1]);
board.side4.lineTo(dp5[0], dp5[1]);
board.side5.moveTo(dp5[0], dp5[1]);
board.side5.lineTo(_local3[0], _local3[1]);
board.side6.moveTo(dp5[0], dp5[1]);
board.side6.lineTo(dp6[0], dp6[1]);
board.side7.moveTo(dp6[0], dp6[1]);
board.side7.lineTo(dp1[0], dp1[1]);
board.side8.moveTo(dp1[0], dp1[1]);
board.side8.lineTo(dp7[0], dp7[1]);
board.side9.moveTo(dp7[0], dp7[1]);
board.side9.lineTo(dp8[0], dp8[1]);
board.side10.moveTo(dp8[0], dp8[1]);
board.side10.lineTo(dp6[0], dp6[1]);
board.side11.moveTo(dp7[0], dp7[1]);
board.side11.lineTo(dp3[0], dp3[1]);
board.side12.moveTo(dp8[0], dp8[1]);
board.side12.lineTo(dp4[0], dp4[1]);
}
function xtoPix(xfun) {
var _local2;
var _local1;
if (constr == "On") {
_local1 = (size * (xmax - xmin)) / maxLen;
} else {
_local1 = size;
}
_local2 = (2 * _local1) / (xmax - xmin);
return(_local1 - ((xmax - xfun) * _local2));
}
function ytoPix(yfun) {
var _local2;
var _local1;
if (constr == "On") {
_local1 = (size * (ymax - ymin)) / maxLen;
} else {
_local1 = size;
}
_local2 = (2 * _local1) / (ymax - ymin);
return(_local1 - ((yfun - ymin) * _local2));
}
function ztoPix(zfun) {
var _local2;
var _local1;
if (constr == "On") {
_local1 = (size * (zmax - zmin)) / maxLen;
} else {
_local1 = size;
}
_local2 = (2 * _local1) / (zmax - zmin);
return(_local1 - ((zmax - zfun) * _local2));
}
function projectPoint(point) {
var _local2 = point;
var _local1 = [];
_local1[0] = (fLength / (fLength - _local2[2])) * _local2[0];
_local1[1] = (fLength / (fLength - _local2[2])) * _local2[1];
return(_local1);
}
function rotMatrix(x, y, z, theta) {
var axLen;
var _local1 = [];
var radtheta = ((Math.PI/180) * theta);
var inx = x;
var _local3 = y;
var _local2 = z;
axLen = Math.sqrt(((inx * inx) + (_local3 * _local3)) + (_local2 * _local2));
_local1 = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
if (axLen > 0.0001) {
inx = inx / axLen;
_local3 = _local3 / axLen;
_local2 = _local2 / axLen;
cosT = Math.cos(radtheta);
sinT = Math.sin(radtheta);
diffT = 1 - cosT;
_local1[0][0] = ((diffT * inx) * inx) + cosT;
_local1[0][1] = ((diffT * inx) * _local3) - (sinT * _local2);
_local1[0][2] = ((diffT * inx) * _local2) + (sinT * _local3);
_local1[1][0] = ((diffT * inx) * _local3) + (sinT * _local2);
_local1[1][1] = ((diffT * _local3) * _local3) + cosT;
_local1[1][2] = ((diffT * _local3) * _local2) - (sinT * inx);
_local1[2][0] = ((diffT * inx) * _local2) - (sinT * _local3);
_local1[2][1] = ((diffT * _local3) * _local2) + (sinT * inx);
_local1[2][2] = ((diffT * _local2) * _local2) + cosT;
}
return(_local1);
}
function matrixByVector(A, B) {
var _local1 = B;
var _local2 = A;
C = [];
C[0] = ((_local2[0][0] * _local1[0]) + (_local2[0][1] * _local1[1])) + (_local2[0][2] * _local1[2]);
C[1] = ((_local2[1][0] * _local1[0]) + (_local2[1][1] * _local1[1])) + (_local2[1][2] * _local1[2]);
C[2] = ((_local2[2][0] * _local1[0]) + (_local2[2][1] * _local1[1])) + (_local2[2][2] * _local1[2]);
return(C);
}
function changeGrid() {
var remmesh = mesh;
var _local2;
var _local1;
var _local3;
_local1 = 1;
while (_local1 <= 12) {
board["side" + _local1].removeMovieClip();
_local1++;
}
_local2 = 0;
while (_local2 < remmesh) {
board["patch_" + _local2].removeMovieClip();
_local2++;
}
_local3 = Number(smesh);
if (notLegalValue(_local3)) {
_local3 = 200;
smesh = "200";
}
_local3 = Math.round(_local3);
smesh = String(_local3);
if (_local3 < 10) {
_local3 = 10;
smesh = "10";
}
if (_local3 > 300) {
_local3 = 300;
smesh = "300";
}
mesh = _local3;
iniClips();
procInput();
}
var e = Math.E;
var pi = Math.PI;
var f1Array = ["sin", "cos", "tan", "ln", "sqrt", "abs", "acos", "asin", "atan", "ceil", "floor", "round"];
var f2Array = ["max", "min", "plus", "minus", "mul", "div", "pow"];
var fLength = 9000;
var inpString1 = "sin(t)";
var inpString2 = "t";
var inpString3 = "cos(t)";
var xmin;
var xmax;
var ymin;
var ymax;
var zmin;
var zmax;
var tmin;
var tmax;
var stmin = "0";
var stmax = "10*pi";
var t;
var pixArray = [];
var funArray = [];
var p1 = [];
var p2 = [];
var p3 = [];
var p4 = [];
var p5 = [];
var p6 = [];
var p7 = [];
var p8 = [];
var size = 100;
var smesh = "200";
var mesh = 200;
var newy = [0, 1, 0];
var outIsError = 0;
var outErrorMes = "";
var compiledExpr1 = [];
var compiledExpr2 = [];
var compiledExpr3 = [];
var dispy = "y";
var dispx = "x";
var dispz = "z";
var zmindisp = "zmin";
var zmaxdisp = "zmax";
var ymindisp = "ymin";
var ymaxdisp = "ymax";
var xmindisp = "xmin";
var xmaxdisp = "xmax";
var colorchoice = 1;
var colo = 16711680;
var proc = "Processing...";
var maxLen;
var constr = "Off";
synexp._visible = false;
processing._visible = false;
errorbox.wordWrap = true;
inputbox1.wordWrap = true;
inputbox1.borderColor = 26112;
inputbox2.wordWrap = true;
inputbox2.borderColor = 26112;
inputbox3.wordWrap = true;
inputbox3.borderColor = 26112;
tminbox.wordWrap = true;
tmaxbox.wordWrap = true;
meshbox.wordWrap = true;
errorbox._visible = false;
iniClips();
procInput();
graphbut.onPress = function () {
processing._visible = true;
};
graphbut.onReleaseOutside = function () {
processing._visible = false;
};
graphbut.onRelease = function () {
procInput();
processing._visible = false;
};
resetbut.onPress = function () {
processing._visible = true;
};
resetbut.onReleaseOutside = function () {
processing._visible = false;
};
resetbut.onRelease = function () {
inpString1 = "";
inpString2 = "";
inpString3 = "";
tmin = 0;
tmax = 1;
stmin = "0";
stmax = "1";
sxmin = "-1";
sxmax = "1";
symin = "-1";
symax = "1";
szmin = "-1";
szmax = "1";
colorchoice = 1;
constr = "Off";
if (smesh != "200") {
smesh = "200";
changeGrid();
} else {
procInput();
}
processing._visible = false;
};
xup.onPress = function () {
processing._visible = true;
};
xup.onReleaseOutside = function () {
processing._visible = false;
};
xdown.onPress = function () {
processing._visible = true;
};
xdown.onReleaseOutside = function () {
processing._visible = false;
};
yleft.onPress = function () {
processing._visible = true;
};
yleft.onReleaseOutside = function () {
processing._visible = false;
};
yright.onPress = function () {
processing._visible = true;
};
yright.onReleaseOutside = function () {
processing._visible = false;
};
xup.onRelease = function () {
drawGraph(1, 0, 0, 10);
processing._visible = false;
};
xdown.onRelease = function () {
drawGraph(1, 0, 0, -10);
processing._visible = false;
};
yright.onRelease = function () {
drawGraph(newy[0], newy[1], newy[2], 10);
processing._visible = false;
};
yleft.onRelease = function () {
drawGraph(newy[0], newy[1], newy[2], -10);
processing._visible = false;
};
framebut.onPress = function () {
processing._visible = true;
};
framebut.onReleaseOutside = function () {
processing._visible = false;
};
color1.onPress = function () {
processing._visible = true;
};
color1.onReleaseOutside = function () {
processing._visible = false;
};
color2.onPress = function () {
processing._visible = true;
};
color2.onReleaseOutside = function () {
processing._visible = false;
};
color3.onPress = function () {
processing._visible = true;
};
color3.onReleaseOutside = function () {
processing._visible = false;
};
color4.onPress = function () {
processing._visible = true;
};
color4.onReleaseOutside = function () {
processing._visible = false;
};
color1.onRelease = function () {
colorchoice = 1;
drawGraph(0, 0, 0, 0);
processing._visible = false;
};
color2.onRelease = function () {
colorchoice = 2;
drawGraph(0, 0, 0, 0);
processing._visible = false;
};
color3.onRelease = function () {
colorchoice = 3;
drawGraph(0, 0, 0, 0);
processing._visible = false;
};
color4.onRelease = function () {
colorchoice = 4;
drawGraph(0, 0, 0, 0);
processing._visible = false;
};
syntax.onRollOver = function () {
synexp._visible = true;
};
syntax.onRollOut = function () {
synexp._visible = false;
};
example1.onPress = function () {
processing._visible = true;
};
example1.onReleaseOutside = function () {
processing._visible = false;
};
example2.onPress = function () {
processing._visible = true;
};
example2.onReleaseOutside = function () {
processing._visible = false;
};
example3.onPress = function () {
processing._visible = true;
};
example3.onReleaseOutside = function () {
processing._visible = false;
};
example4.onPress = function () {
processing._visible = true;
};
example4.onReleaseOutside = function () {
processing._visible = false;
};
example5.onPress = function () {
processing._visible = true;
};
example5.onReleaseOutside = function () {
processing._visible = false;
};
example6.onPress = function () {
processing._visible = true;
};
example6.onReleaseOutside = function () {
processing._visible = false;
};
example7.onPress = function () {
processing._visible = true;
};
example7.onReleaseOutside = function () {
processing._visible = false;
};
example8.onPress = function () {
processing._visible = true;
};
example8.onReleaseOutside = function () {
processing._visible = false;
};
example9.onPress = function () {
processing._visible = true;
};
example9.onReleaseOutside = function () {
processing._visible = false;
};
example10.onPress = function () {
processing._visible = true;
};
example10.onReleaseOutside = function () {
processing._visible = false;
};
example1.onRelease = function () {
inpString3 = "3*cos(t)+cos(10*t)*cos(t)";
inpString1 = "3*sin(t)+cos(10*t)*sin(t)";
inpString2 = "sin(10*t)";
stmin = "0";
stmax = "2*pi";
constr = "On";
procInput();
processing._visible = false;
};
example2.onRelease = function () {
inpString3 = "t*cos(t)";
inpString1 = "t";
inpString2 = "t*cos(t)";
stmin = "0";
stmax = "10*pi";
constr = "On";
procInput();
processing._visible = false;
};
example3.onRelease = function () {
inpString3 = "5*cos(t)-cos(5*t)";
inpString1 = "5*sin(t)-sin(5*t)";
inpString2 = "t";
stmin = "0";
stmax = "4*pi";
constr = "Off";
procInput();
processing._visible = false;
};
example4.onRelease = function () {
inpString3 = "2*sin(3*t)*cos(t)";
inpString1 = "2*sin(3*t)*sin(t)";
inpString2 = "0";
stmin = "0";
stmax = "pi";
constr = "On";
procInput();
processing._visible = false;
};
example5.onRelease = function () {
inpString3 = "2*sin(3*t)*cos(t)";
inpString1 = "2*sin(3*t)*sin(t)";
inpString2 = "sin(3*t)";
stmin = "0";
stmax = "2*pi";
constr = "On";
procInput();
processing._visible = false;
};
example6.onRelease = function () {
inpString3 = "t*cos(t)";
inpString1 = "t*sin(t)";
inpString2 = "t";
stmin = "0";
stmax = "10*pi";
constr = "Off";
procInput();
processing._visible = false;
};
example7.onRelease = function () {
inpString3 = "sin(2*t)";
inpString1 = "cos(t)";
inpString2 = "t";
stmin = "0";
stmax = "4*pi";
constr = "Off";
procInput();
processing._visible = false;
};
example8.onRelease = function () {
inpString3 = "cos(t)";
inpString1 = "sin(t)";
inpString2 = "t";
stmin = "0";
stmax = "10*pi";
constr = "Off";
procInput();
processing._visible = false;
};
example9.onRelease = function () {
inpString3 = "t";
inpString1 = "0";
inpString2 = "t";
stmin = "-1";
stmax = "1";
constr = "Off";
procInput();
processing._visible = false;
};
example10.onRelease = function () {
inpString3 = "t";
inpString1 = "t*cos(t)";
inpString2 = "t*sin(t)";
stmin = "0";
stmax = "10*pi";
constr = "Off";
procInput();
processing._visible = false;
};
gridbut.onRelease = function () {
changeGrid();
processing._visible = false;
};
gridbut.onPress = function () {
processing._visible = true;
};
gridbut.onReleaseOutside = function () {
processing._visible = false;
};
constrbut.onRelease = function () {
if (constr == "On") {
constr = "Off";
} else {
constr = "On";
}
};
problem1.onRelease = function () {
inpString1 = "";
inpString2 = "";
inpString3 = "";
tmin = 0;
tmax = 1;
stmin = "0";
stmax = "1";
sxmin = "-1";
sxmax = "1";
symin = "-1";
symax = "1";
szmin = "-1";
szmax = "1";
procInput();
inpString3 = "t";
inpString1 = "t";
inpString2 = "t^3";
stmin = "-1";
stmax = "1";
constr = "Off";
processing._visible = false;
};
problem2.onRelease = function () {
inpString1 = "";
inpString2 = "";
inpString3 = "";
tmin = 0;
tmax = 1;
stmin = "0";
stmax = "1";
sxmin = "-1";
sxmax = "1";
symin = "-1";
symax = "1";
szmin = "-1";
szmax = "1";
procInput();
inpString3 = "cos(t)";
inpString1 = "sin(t)";
inpString2 = "0";
stmin = "0";
stmax = "2*pi";
constr = "On";
processing._visible = false;
};
problem3.onRelease = function () {
inpString1 = "";
inpString2 = "";
inpString3 = "";
tmin = 0;
tmax = 1;
stmin = "0";
stmax = "1";
sxmin = "-1";
sxmax = "1";
symin = "-1";
symax = "1";
szmin = "-1";
szmax = "1";
procInput();
inpString3 = "cos(t)";
inpString1 = "sin(t)";
inpString2 = "t^2";
stmin = "0";
stmax = "10*pi";
constr = "Off";
processing._visible = false;
};
problem4.onRelease = function () {
inpString1 = "";
inpString2 = "";
inpString3 = "";
tmin = 0;
tmax = 1;
stmin = "0";
stmax = "1";
sxmin = "-1";
sxmax = "1";
symin = "-1";
symax = "1";
szmin = "-1";
szmax = "1";
procInput();
inpString3 = "t*cos(t)";
inpString1 = "t*sin(t)";
inpString2 = "ln(t+1)";
stmin = "0";
stmax = "10*pi";
constr = "Off";
processing._visible = false;
};
problem5.onRelease = function () {
inpString1 = "";
inpString2 = "";
inpString3 = "";
tmin = 0;
tmax = 1;
stmin = "0";
stmax = "1";
sxmin = "-1";
sxmax = "1";
symin = "-1";
symax = "1";
szmin = "-1";
szmax = "1";
procInput();
inpString3 = "-t";
inpString1 = "t";
inpString2 = "t";
stmin = "-1";
stmax = "1";
constr = "On";
processing._visible = false;
};
problem6.onRelease = function () {
inpString1 = "";
inpString2 = "";
inpString3 = "";
tmin = 0;
tmax = 1;
stmin = "0";
stmax = "1";
sxmin = "-1";
sxmax = "1";
symin = "-1";
symax = "1";
szmin = "-1";
szmax = "1";
procInput();
inpString3 = "t";
inpString1 = "sin(t)";
inpString2 = "t";
stmin = "0";
stmax = "4*pi";
constr = "Off";
processing._visible = false;
};
problem1.onPress = function () {
processing._visible = true;
};
problem1.onReleaseOutside = function () {
processing._visible = false;
};
problem2.onPress = function () {
processing._visible = true;
};
problem2.onReleaseOutside = function () {
processing._visible = false;
};
problem3.onPress = function () {
processing._visible = true;
};
problem3.onReleaseOutside = function () {
processing._visible = false;
};
problem4.onPress = function () {
processing._visible = true;
};
problem4.onReleaseOutside = function () {
processing._visible = false;
};
problem5.onPress = function () {
processing._visible = true;
};
problem5.onReleaseOutside = function () {
processing._visible = false;
};
problem6.onPress = function () {
processing._visible = true;
};
problem6.onReleaseOutside = function () {
processing._visible = false;
};