Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a circle of radius r and access to a random number generator. What is a method to generate random (x,y) values distributed along the circle's perimeter?

share|cite|improve this question
Generate a random angle $\theta$ between $0$ and $2\pi$. Take $(x,y)=(r\cos\theta, r\sin\theta)$. – mjqxxxx Dec 7 '12 at 15:18
up vote 7 down vote accepted

The simplest method would be to generate a random angle $\theta \in [0,2\pi]$. Then convert from polar to Cartesian with $(x,y) = (r \cos \theta , r \sin \theta)$.

Note that if your random number generator returns a number $k \in [0,1]$ then $\theta = 2\pi k$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.