Vector Fields
3D Vector Field
Draw vector_field(x, y, z) in the 3D viewer. Arrows point away from the origin. Orbit, zoom, and pan stay on the existing viewer.
Generate Graph draws vector_field(x, y, z) in the existing 3D viewer. At (1, 0, 0) the arrow points in the positive x direction. At (-1, 0, 0) it points in the negative x direction, away from the origin. At (0, 0, 0) the vector is the zero vector. The magnitude is sqrt(x^2+y^2+z^2).
The same card also draws the rotation vector_field(-y, x, 0) about the z-axis and the constant field vector_field(0, 0, 1). Drag orbits the scene, the wheel zooms, and Shift-drag or right-drag pans. The density slider uses a small grid so the view stays readable. Arrow scale and Normalize arrows change the picture without a new request. An undefined sample is left out.
Equation
vector_field(x,y,z)
Graph preview
How a vector field is sampled
A vector field assigns a vector to each point. In the plane, F(x, y) = (P, Q). In space, F(x, y, z) = (P, Q, R). The arrow at a sample point starts at that point and points in the direction of the vector. Its length follows the magnitude, scaled so neighboring arrows do not cover one another. Color uses the same magnitude, from teal for a small vector to amber for the largest vector in the current window.
A zero vector has no direction, so it is drawn as a marker rather than an arrow with an invented direction. A sample that is undefined, infinite, or too large to plot is omitted. Changing the density changes how many points are sampled. Normalizing keeps the direction and uses one length, which makes a direction pattern easier to see when magnitudes differ. These pictures sample the field. They do not replace gradient, divergence, or curl, which stay on their own commands.
Reading the input
vector_field(x,y,z)— This is a command. The name selects the routine, and the items inside the parentheses are its arguments.
Other versions of this example
These stay on this page so each version keeps the same explanation. Choose Try example to run a version in its Studio workflow, or copy it into the editable field below.
Radial
At (1, 0, 0) the arrow points along positive x. At the origin the vector is zero.
vector_field(x,y,z)
Rotation about z
The horizontal part circles the z-axis, and the vertical component is 0.
vector_field(-y,x,0)
Constant up
Every arrow is (0, 0, 1), so the field points straight up with equal length.
vector_field(0,0,1)
Try a change
- Move the Arrow density slider after Generate Graph. The number of arrows changes, and each remaining arrow still follows the field.
- Turn on Normalize arrows. Directions stay the same and the lengths become equal. A zero vector stays a marker with no direction.
- Try vector_field(1/x, y) and set an odd density. Samples on the line x = 0 are skipped, and the other arrows remain.
Generate Graph draws vector_field(P, Q) on the 2D board, or vector_field(P, Q, R) in the existing 3D viewer. Arrow length and color follow the magnitude unless Normalize arrows is on. Zoom, pan, and orbit stay with those engines. An undefined sample is skipped. A zero vector is a marker with no direction. Export stays available.