DGS Studio

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

Graph preview of vector_field(x,y,z)
A static sample of this expression. The studio draws the full interactive result.

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

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

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.

Edit and generate

Generate Graph opens the studio homepage and runs this field. Open in DGS Studio loads the same text and waits for you to generate it. The equation is sent once, as a query parameter.

Related examples