Source: helper/getDistance.js

  1. /**
  2. * Returns the distance between 2 coordinates of a plan.
  3. *
  4. * @param {Array<number>} coordA
  5. * @param {Array<number>} coordB
  6. * @returns number
  7. */
  8. const getDistance = (coordA, coordB) => {
  9. const [xA, yA] = coordA;
  10. const [xB, yB] = coordB;
  11. return Math.sqrt((xB - xA) ** 2 + (yB - yA) ** 2);
  12. };
  13. export default getDistance;