distance(): Measuring Separation Between Points
distance() calculates the separation between compatible points or vectors. In ordinary Euclidean coordinates, it generalizes the Pythagorean theorem: the distance between (x₁, y₁) and (x₂, y₂) is the square root of the summed squared coordinate differences.
Useful geometry
Distance is useful for nearest-neighbour checks, collision ranges, movement, and error measurement. For a two-component difference, hypot() is a convenient related operation. Build coordinate differences with subtract(), and use abs() when you need per-axis displacement rather than straight-line distance.
Input caveats
Points need matching dimensions and compatible units. A two-dimensional point cannot be directly compared with a three-dimensional point without an explicit convention. For matrices, distinguish geometric distance from element-wise differences. Normalize units first with to() when measurements use different scales.