Georgie0409,
Описал более явно векторность (по MallSerg), что откуда берется, и сделал соответствия (map) расстояние-координаты.
class Vector3D {
constructor(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}
get length() {
return Math.hypot(this.x, this.y, this.z);
}
subtract(vector) {
return new Vector3D(this.x - vector.x, this.y - vector.y, this.z - vector.z);
}
}
let OA = new Vector3D(2000, 1000, 500);
let OB = new Vector3D(2500, 1200, 600);
let OC = new Vector3D(2300, 1200, 490);
let OD = new Vector3D(2150, 1400, 400);
let positionVectors = [OB, OC, OD];
/*
let BA = OA.subtract(OB);
let CA = OA.subtract(OC);
let DA = OA.subtract(OD);
let distanceVectors = [BA, CA, DA];
console.log(Math.min(BA.length, CA.length, DA.length));
*/
let mapByLength = new Map(positionVectors.map((OX) => [OA.subtract(OX).length, OX] ));
let minLength = Math.min(...mapByLength.keys());
let minPosition = mapByLength.get(minLength);
console.log(minLength, minPosition);