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 {