Ejemplo n.º 1
0
  /**
   * Tries to fix a structural problem leading to an evaluation error, e.g. x(x+1) is interpreted as
   * xcoord(x+1). This can be fixed by changing the structure to x*(x+1) for example.
   */
  private void fixStructure() {
    // get function variables for x, y, z
    FunctionVariable xVar = null, yVar = null, zVar = null;
    for (FunctionVariable fVar : fVars) {
      if ("x".equals(fVar.toString())) xVar = fVar;
      else if ("y".equals(fVar.toString())) yVar = fVar;
      else if ("z".equals(fVar.toString())) zVar = fVar;
    }

    // try to replace x(x+1) by x*(x+1)
    expression.replaceXYZnodes(xVar, yVar, zVar);
  }