Skip to content

Scientific geometry

Vector fields and streamlines ​

scenes/vector-fields-and-streamlines
const geometry =
  show === "arrows"
    ? { kind: "vectors", vector: SWIRL }
    : {
        kind: "streamlines",
        vector: SWIRL,
        seeds: { kind: "grid", counts: [4, 4, 3] },
        step: 0.05,
        steps: 400,
      };
plot.setGraph({ ...DOMAIN, plots: [{ name: "field", geometry }] });
plot.frameScene();

Calls

2 in the code above, in the order it makes them

plot.setGraph(graph: Graph): void

Draw a document of mathematical plots: expressions, curves, imported tables, and the labelled axis frame around them.

Replaces whatever graph was set before, and leaves uploaded geometry alone, so a generated surface can sit beside a point cloud under the same camera.

This is the expensive call: every plot in the document is regenerated and re-uploaded. Drawing one afterwards is not. A page with a slider over an expression's parameter should expect the cost of a keystroke, not the cost of a frame, which is why the examples keep their documents small.

plot.frameScene(): void

Point the camera at the middle of everything uploaded, far enough back to see it.

Call after uploading. A scene measured in grid cells or in millimetres is nowhere near where a camera starts, and without this the first thing a caller sees is an empty canvas.