We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef92ed5 commit db1895bCopy full SHA for db1895b
1 file changed
src/core/sceneObjs/BaseGrinGlass.js
@@ -467,8 +467,14 @@ class BaseGrinGlass extends BaseGlass {
467
* @returns {string}
468
*/
469
shiftOrigin(equation) {
470
- // Replace standalone x (including `ex`/`xe` implicit multiplication), but avoid names like `exp`/`max`.
471
- return equation.replaceAll(/(^|[^a-zA-Z0-9_]|e)x(?=$|[^a-zA-Z0-9_]|e)/g, "$1(x-" + this.origin.x + ")").replaceAll("y", "(y-" + this.origin.y + ")");
+ // Protect `\exp` and `\max` so their `x` is not replaced; restore them after.
+ return equation
472
+ .replaceAll("\\exp", "\\EXP")
473
+ .replaceAll("\\max", "\\MAX")
474
+ .replaceAll("x", "(x-" + this.origin.x + ")")
475
+ .replaceAll("\\EXP", "\\exp")
476
+ .replaceAll("\\MAX", "\\max")
477
+ .replaceAll("y", "(y-" + this.origin.y + ")");
478
}
479
480
/**
0 commit comments