The first point, represented as [x, y]
.
The second point, represented as [x, y]
.
The Euclidean distance between the two points.
// Define two points
const point1: T_Point = [0, 0];
const point2: T_Point = [3, 4];
// Calculate the distance
const distance = pointPointDistance(point1, point2);
console.log(distance); // 5
// Points at the same location
const distance2 = pointPointDistance([1, 1], [1, 1]);
console.log(distance2); // 0
Calculates the Euclidean distance between two points in 2D space.
This function computes the straight-line distance (also known as the Euclidean distance) between two points represented as
[x, y]
coordinates.