Streamlines
2D Streamlines
Draw streamlines(-y, x) as curves tangent to the vector field. Direction arrows show the counterclockwise flow. Density and length are adjustable.
Generate Graph draws streamlines(-y, x) as curves that follow F(x, y) = (-y, x). At (1, 0) the field is (0, 1). At (0, 1) it is (-1, 0). The direction is perpendicular to the position vector, so each regular orbit is a circle around the origin and the flow is counterclockwise. The magnitude is sqrt(x^2+y^2). The origin is a zero vector, so no direction is invented there.
Each seed is integrated forward and backward with adaptive Runge-Kutta (Dormand-Prince). A step that leaves the window, meets a singularity, or reaches a zero vector stops that ray. Samples are not joined across an undefined region. Direction arrows follow the field. Streamline density changes the seed grid. Trajectory length caps the arc. A click adds a seed. Vector field arrows are optional. Zoom, pan, and the existing board export stay available. The same card also draws streamlines(x, y), streamlines(1, 0), and streamlines(x, -y).
Equation
streamlines(-y,x)
Graph preview
How a streamline is integrated
A streamline is a curve whose tangent is the vector field at every regular point. In the plane it solves dx/dt = P and dy/dt = Q. In space it also solves dz/dt = R. DGS reuses the adaptive Runge-Kutta (Dormand-Prince) step from the differential-equation solver. The independent variable is time, and the state is the point itself. Each seed is integrated forward and backward. The step grows when the local error is small and shrinks when it is not. A proposed step is also limited so the point cannot jump across the window.
The ray stops at the boundary of the view, at a maximum arc length, at a maximum number of steps, at a zero vector, or when a sample is undefined, infinite, or too large. The last valid point is kept. The invalid point is not connected. A closed orbit, such as the circles of F = (-y, x), stops when the point returns to its seed so the same loop is not traced forever. These curves are numerical. They are not a closed-form solution, and a very long requested length is still capped. The field (-y, x, z) rotates about the z-axis while z grows exponentially forward in time.
Reading the input
streamlines(-y,x)— 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.
Rotation
Circular streamlines around the origin. At (1, 0) the field is (0, 1). At (0, 1) it is (-1, 0). The origin is an equilibrium.
streamlines(-y,x)
Source
Trajectories leave the origin along rays. The origin is a zero vector and is not given a direction.
streamlines(x,y)
Constant
Horizontal streamlines. Every direction arrow points to the right.
streamlines(1,0)
Saddle
Flow leaves along the x-axis and approaches along the y-axis.
streamlines(x,-y)
Try a change
- Move Streamline density and Trajectory length after Generate Graph. The seeds and the arcs change, and each curve stays tangent to the field.
- Click the 2D board to add a seed, or use Add seed for a 3D point. The new trajectory follows the same field.
- Turn on Vector field arrows to show the field beside the curves. Color by magnitude recolors each curve by its speed.
Generate Graph integrates streamlines(P, Q) on the 2D board, or streamlines(P, Q, R) in the existing 3D viewer, with adaptive Runge-Kutta forward and backward. Direction arrows follow the field. Density, length, and optional field arrows redraw locally. A click or Add seed starts another curve. Zoom, pan, orbit, and export stay with those engines. A trajectory is not joined across an undefined sample.