Skip to content

<notatio-vector-plot>

Split a field attribute into its two components. Handles an optional \{...\}, {...} or (...) wrapper and only splits on a comma at brace / paren depth zero, so \{\frac{y}{2}, -x\} survives intact. / export function splitField(raw: string): [string, string] | undefined { let s = raw.trim(); const unwrap: [string, string][] = [ ["\\{", "\\}"], ["\\left(", "\\right)"], ["{", "}"], ["(", ")"], ["[", "]"], ]; for (const [open, close] of unwrap) { if (s.startsWith(open) && s.endsWith(close)) { s = s.slice(open.length, s.length - close.length).trim(); break; } } let depth = 0; for (let i = 0; i < s.length; i++) { const c = s[i]; if (c === "{" || c === "(" || c === "[") depth++; else if (c === "}" || c === ")" || c === "]") depth--; else if (c === "," && depth === 0) { const u = s.slice(0, i).trim(); const v = s.slice(i + 1).trim(); if (u && v) return [u, v]; return undefined; } } return undefined; }

const log = debug("vectorplot");

/** <notatio-vector-plot u="-y" v="x" xrange="-2,2" yrange="-2,2"> -- a planar vector field (Wolfram's VectorPlot): u/v are the two components in notatio, or field="-y, x" gives both at once. Arrows sit on an n×n grid of cell centres, their length and colour scaling with |F|.

type="stream" switches to StreamPlot: streamlines traced from the same grid by fixed-step RK4 on the normalised field -- deterministic, so the same field always draws the same picture (no random seeding).

Stories in the playground·packages/notatio-lit/src/notatio-vector-plot.ts· in Vue: <VectorPlot>

Attributes

AttributeTypeDefaultNotes
ustring""The x component of the field, in notatio.
vstring""The y component of the field, in notatio.
fieldstring""Both components at once, comma-separated — "-y, x".
xvarstring"x"The variable on the x axis; defaults to the expression's first unknown.
yvarstring"y"The variable on the y axis; defaults to the next unknown after xvar.
xrangestring"-2,2"The x sampling range, as lo,hi.
yrangestring"-2,2"The y sampling range, as lo,hi.
nnumber0Arrows (or streamline seeds) per side.
type"vector" | "stream""vector"vector for arrows, stream for RK4 streamlines.
stepsnumber60Streamline integration steps taken in each direction from a seed.
axesstring"true""false" hides the axes.
x-label
property xLabel
string""Axis label for x.
y-label
property yLabel
string""Axis label for y.
labelstring""Caption drawn above the figure.