Skip to content

pointDistance

Calculates the pixel distance between two points.

The straight-line (Euclidean) distance between two [x, y] points, in whatever units the coordinates use. A 160 by 120 offset gives the classic 200.

import {pointDistance} from "@d3plus/math";

pointDistance([40, 160], [200, 40]);

Parameters

import {pointDistance} from "@d3plus/math";
p1requiredPoint

The first point, which should always be an [x, y] formatted Array.

p2requiredPoint

The second point, which should always be an [x, y] formatted Array.