Generating random point in a cylinder

后端 未结 4 1357
旧时难觅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条回答
  •  萌比男神i
    2020-12-21 14:18

    The z axis is easy: -0.5 * h <= z <= 0.5 * h

    The x and y are equal to a circle will be: x^2 + y^2 <= r^2

    Buth math is long ago for me :-)

提交回复
热议问题