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:
224
224
Generate a point in a circle, or can think of it as a vector pointing
225
225
a random direction with a random magnitude <= radius.
226
226
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
231
228
232
229
Args:
233
230
center (Point2): The center of the circle
@@ -236,7 +233,7 @@ def rand_in_circle(center: Point2, radius: float) -> Point2:
236
233
# random angle
237
234
angle = 2 * math .pi * random .random ()
238
235
# random radius
239
- r = radius * random .random ()
236
+ r = radius * math . sqrt ( random .random () )
240
237
# calculating coordinates
241
238
return (r * math .cos (angle ) + center [0 ], r * math .sin (angle ) + center [1 ])
242
239
You can’t perform that action at this time.
0 commit comments