Skip to content

Scientific geometry

Vector fields ​

scenes/vector-fields
const { field, scale } = swirl(n);
const arrows = plot.uploadVectorField(field, scale);
plot.showVectorField(arrows);
plot.frameScene();
return { readout: `${(n * n * n).toLocaleString("en-GB")} arrows` };

Calls

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

plot.uploadVectorField(field: VectorField, scale: number): VectorFieldHandle

Upload a vector field and return a handle naming it.

scale multiplies every arrow's length. There is no way to derive it: the field and the scene are different quantities, and only the caller knows how they should compare on screen.

plot.showVectorField(handle: VectorFieldHandle): void

Draw the vector field handle names.

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.