Make distance() more succinct

This commit is contained in:
ColonelParrot 2023-05-11 09:44:59 -04:00
parent 8a0ec08de1
commit dbfff42790
2 changed files with 2 additions and 2 deletions

View File

@ -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 {

View File

@ -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 {