Skip to content

Commit

Permalink
make_function_plotter uses Numbas.jme.makeFast
Browse files Browse the repository at this point in the history
The new implicitcurve object in JSXGraph 1.7.0 needs to evaluate its
function thousands of times for each update. It became clear that the
standard way of evaluating JME expressions is far too slow, so I wrote
`Numbas.jme.makeFast` to turn most expressions into almost-native JS
functions.

This commit changes the `make_function_plotter` code, which is used
whenever you use a subexpression as a parameter in a JSXGraph diagram,
to use `Numbas.jme.makeFast`.

It also makes `make_function_plotter` pick up the names of objects
already defined in the board, so you can use the values of things like
sliders in expressions.
If an object in the board has a `.Value` method, then you can use its
value by referring to it by its ID in the expression.

Example:

    jsxgraph(400,400, [-4,4,4,-4], [
        "a": ["slider", [[-3.5,2.5],[-1.5,2.5],[0,1,3]], ["id": "a"]],
        "f": ["implicitcurve", [expression("x^2-y^2-a")], ["id": "f"]]
    ])
  • Loading branch information
christianp committed Feb 1, 2024
1 parent 083eaa2 commit 046c38c
Showing 1 changed file with 38 additions and 16 deletions.
54 changes: 38 additions & 16 deletions jsxgraph.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 046c38c

Please sign in to comment.