File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed
Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change @@ -224,10 +224,7 @@ def rand_in_circle(center: Point2, radius: float) -> Point2:
224224 Generate a point in a circle, or can think of it as a vector pointing
225225 a random direction with a random magnitude <= radius.
226226
227- Reference: https://stackoverflow.com/a/30564123
228-
229- .. note:: This algorithm returns a higher concentration of points
230- around the center of the circle
227+ Reference: https://stackoverflow.com/a/50746409
231228
232229 Args:
233230 center (Point2): The center of the circle
@@ -236,7 +233,7 @@ def rand_in_circle(center: Point2, radius: float) -> Point2:
236233 # random angle
237234 angle = 2 * math .pi * random .random ()
238235 # random radius
239- r = radius * random .random ()
236+ r = radius * math . sqrt ( random .random () )
240237 # calculating coordinates
241238 return (r * math .cos (angle ) + center [0 ], r * math .sin (angle ) + center [1 ])
242239
You can’t perform that action at this time.
0 commit comments