From d9bce1295e421e252fcdba092e7c235755cd4f19 Mon Sep 17 00:00:00 2001 From: Sagi Kedmi Date: Mon, 14 Aug 2017 10:22:49 +0300 Subject: [PATCH] make sure points are uniformly distributed --- package.json | 2 +- src/index.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3338687..9fa37f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "random-location", - "version": "1.0.5", + "version": "1.0.6", "description": "Random coordinates within a circle given a center point and radius", "main": "src/index.js", "scripts": { diff --git a/src/index.js b/src/index.js index 3faf5b8..1c25d4d 100644 --- a/src/index.js +++ b/src/index.js @@ -57,7 +57,11 @@ Where -90 <= A <= 90 and -180 <= B <= 180. radius R is in meters. */ const randomCirclePoint = (centerPoint, radius) => { - return randomCircumferencePoint(centerPoint, Math.random() * radius) + // http://mathworld.wolfram.com/DiskPointPicking.html + return randomCircumferencePoint( + centerPoint, + Math.sqrt(Math.random()) * radius + ) } /*