Generate Random Points WIthin A SemiCircle

This topic is 2923 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello!

Suppose, the radius and center are known already, I want to know how to generate random points within the bottom half of the circle ie. between 180 to 360 degrees only.

Thanks for any help
Unforgiven

Share on other sites
Pick a random angle between 180 and 360 (lets say d).

then x=centrex+r*cos(d), y=centrey+r*sin(d)

where centrex, centrey are the coordinates of the centre of your circle

Share on other sites
Quote:
 Original post by 69mijPick a random angle between 180 and 360 (lets say d).Pick a random radius between 0 and your radius (lets say r)then x=centrex+r*cos(d), y=centrey+r*sin(d)where centrex, centrey are the coordinates of the centre of your circle

You'll get random points but they won't be evenly distributed, which might be a problem for OP.

While I'm sure someone has a great math formula for this, the easiest thing I can think of is to just draw a square around your circle, randomly generate x/y pairs in the square, and then reject anything outside the circle. Might waste a slight bit of computation, but its quick and easy.

1. 1
Rutin
47
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• Forum Statistics

• Total Topics
632994
• Total Posts
3009769
• Who's Online (See full list)

There are no registered users currently online

×