private string performMath1(mathOperation operation, string expression) { string result = ""; try { result = performMath2(getMathParenthetical(operation, expression), operation, expression); } catch (SysEvalException e) { } return(result); }
private string performMath2(parenthetical mathParenthetical, mathOperation operation, string expression) { string mathString = ""; switch (operation) { case mathOperation.sqrt: mathString = Mathf.Sqrt(sysEval(mathParenthetical.expression)).ToString(); break; case mathOperation.sin: mathString = Mathf.Sin(sysEval(mathParenthetical.expression)).ToString(); break; case mathOperation.cos: mathString = Mathf.Cos(sysEval(mathParenthetical.expression)).ToString(); break; case mathOperation.tan: mathString = Mathf.Tan(sysEval(mathParenthetical.expression)).ToString(); break; case mathOperation.arcsin: mathString = Mathf.Asin(sysEval(mathParenthetical.expression)).ToString(); break; case mathOperation.arccos: mathString = Mathf.Acos(sysEval(mathParenthetical.expression)).ToString(); break; case mathOperation.arctan: mathString = Mathf.Atan(sysEval(mathParenthetical.expression)).ToString(); break; case mathOperation.abs: mathString = Mathf.Abs(sysEval(mathParenthetical.expression)).ToString(); break; } expression = expression.Substring(0, mathParenthetical.startIndex - 1) + mathString + expression.Substring(mathParenthetical.endIndex + 1); return(expression); }
private parenthetical getMathParenthetical(mathOperation operation, string expression) { parenthetical newParenthetical = findParenthetical(Enum.GetName(typeof(mathOperation), operation), expression); return(newParenthetical); }