Generating random point in a cylinder

后端 未结 4 1362
旧时难觅i
旧时难觅i 2020-12-21 13:47

What is best way or an algorithm for generating a random 3d point [x,y,z] inside the volume of the circular cylinder if radius r and height h of the cylinder are given?

4条回答
  •  滥情空心
    2020-12-21 14:08

    Generate a random point inside the rectangular solid circumscribing the cylinder; if it's inside the cylinder (probability pi/4), keep it, otherwise discard it and try again.

提交回复
热议问题