- Joined
- Sep 20, 2022
- Messages
- 282
- Reaction score
- 40
If the function random() returns a random fraction between 0 and 1 (inclusive), and the objective is to select many random points on a disk (of radius 1), what is wrong with this code?
Code:
angle = 2*PI*random()
radius = random()
The points cluster near the centre. For uniform random points, there is a simple fix.