• Advertisement
Sign in to follow this  

Generate Random Points WIthin A SemiCircle

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
Pick 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

Share this post


Link to post
Share on other sites
Quote:
Original post by 69mij
Pick 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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement