I have a finite cylinder in three-dimensions with a long-axis defined by the endpoints $p_1$ and $p_2$, and radius $R$. What is an easy method of picking a random point in this cylinder with uniform probability across its volume?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
Find a small box containing your cylinder and generate random points uniformly in the box, rejecting points that are outside the cylinder. (This is not the fastest method, but probably the simplest.)
Another method that is a little faster would be: Generate points uniformly and randomly on a disc with the same radius as your cylinder (for example as above), and then choose the distance along the axis uniformly.