Math node

Distance

Measures the distance between two points, 2D or 3D (2D ignores Z). Start/End take any point value — a SIMD point, [x, y, z] numbers, or a whole cloud (measured from its centroid). Split XYZ swaps the structure inputs for plain X/Y/Z float ports. Metric: Euclidean (straight line), Manhattan (grid), Chebyshev (largest axis). Also outputs Delta (End−Start), Direction (normalized, zero-safe) and Midpoint as points.

Inputs

PortTypeDefault
StartThe first point — any point value works: a SIMD point from the Points pipeline, [x, y, z] numbers, or a WHOLE cloud, which measures from its centroid (a one-point cloud is just the point). Hidden when Split XYZ is on.structure—
EndThe second point — same shapes as Start. Distance, Delta, Direction and Midpoint all run Start → End.structure—
Mode2D or 3D. 2D simply ignores Z wherever it came from — a 3D point in 2D mode measures on the XY plane; the Z float ports hide too.int0
MetricHow the axes combine: Euclidean = straight line (the default ruler), Manhattan = |dx|+|dy|+|dz| (grid travel), Chebyshev = the largest single axis (king's moves). Direction stays geometric (Euclidean) in every metric.int0
Split XYZSwaps the two structure inputs for plain float ports — Start X/Y(/Z), End X/Y(/Z) — for cabling single numbers straight from Math, Mouse or LFO nodes. 2D mode shows only X and Y.boolfalse
Start XSplit face: the first point's X in Grafit units.float0
Start YSplit face: the first point's Y in Grafit units.float0
Start ZSplit face: the first point's Z — only in 3D mode.float0
End XSplit face: the second point's X in Grafit units.float0
End YSplit face: the second point's Y in Grafit units.float0
End ZSplit face: the second point's Z — only in 3D mode.float0

Outputs

PortType
Distancefloat
Deltastructure
Directionstructure
Midpointstructure

How It Works

Distance is the universal ruler, and it has two faces. The structure face (Mode: Points) takes any point value on Start and End — a point, three numbers, a dictionary with x/y/z, or a whole point cloud, which is measured from its centroid (two clouds measure centre to centre). Split XYZ swaps those in for plain Start X/Y/Z and End X/Y/Z float ports, for the times when the numbers arrive separately.

Beyond the scalar distance it emits the whole vector family that patches used to rebuild by hand: Delta (End − Start), Direction (normalized, and exactly zero at zero distance — never NaN) and Midpoint, all as points that open in Break Point.

Metric picks how the distance is counted: Euclidean (the straight line), Manhattan (the sum of the axis steps — a grid walk), Chebyshev (the largest single axis — a chessboard king's move). Direction stays geometric in all three, so only the number changes.

2D mode simply ignores Z, which is what you want for screen-space work.

Use Cases

  • Proximity as a control — Two tracked hands into Start and End: the distance drives a synth's filter, a particle field's strength, or a crossfade.
  • Aim one thing at another — Direction into Direction to Rotation gives the degrees any Rotation port wants, and Length gives the reach in the same breath.
  • Draw the connection — Midpoint places a label; Delta sizes and orients the line between the two points.
  • Cloud separation — Two point clouds into the structure ports measures centroid to centroid, which is the honest "how far apart are these two groups".
  • Trigger on approach — Distance into Compare (< threshold) into Do Once fires exactly when two things meet.

Tips

  • Direction is zero-safe: coincident points give an exactly zero vector, not NaN, so nothing downstream explodes.
  • Use Manhattan when you are working on a grid (a DMX patch, a tile layout) — it reflects the real number of steps.
  • For per-point distances across a whole cloud, reach for the points family rather than measuring centroids here.
  • Delta opens in Break Point, so the individual axis differences are one node away.
  • Distance is the node the owner rebuilt as the canonical example of how a Grafit project should read — see the Distance example project.

Open Distance in the interactive catalog →

Distance is one of 381 nodes in Grafit Pro.

Free download. Every feature for 7 days, no card. Then €99.99 once — or keep playing your projects as a Player.

More Math nodes