Random number fun

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,355
Messages
2,571,467
Members
48,794
Latest member
Lonell Lee
Top