From dbfff42790bf0380bb1e640b86cd2701e41147e8 Mon Sep 17 00:00:00 2001 From: ColonelParrot <65585002+ColonelParrot@users.noreply.github.com> Date: Thu, 11 May 2023 09:44:59 -0400 Subject: [PATCH] Make distance() more succinct --- src/jscanify-node.js | 2 +- src/jscanify.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jscanify-node.js b/src/jscanify-node.js index 30ae041..2d3f6c5 100644 --- a/src/jscanify-node.js +++ b/src/jscanify-node.js @@ -22,7 +22,7 @@ let cv; * @returns distance between two points */ function distance(p1, p2) { - return Math.sqrt((p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2); + return Math.hypot(p1.x - p2.x, p1.y - p2.y); } class jscanify { diff --git a/src/jscanify.js b/src/jscanify.js index 2dfd14e..f0e3b58 100644 --- a/src/jscanify.js +++ b/src/jscanify.js @@ -16,7 +16,7 @@ * @returns distance between two points */ function distance(p1, p2) { - return Math.sqrt((p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2); + return Math.hypot(p1.x - p2.x, p1.y - p2.y); } class jscanify {