[英]Generating 3D points along a cylinder surface with a non-uniform distribution
I am trying to randomly generate points along the curved surface of a cylinder that has ay up-axis.我正在尝试沿具有上轴的圆柱体的曲面随机生成点。 Following a SO question of creating points along a 2D circle, I have
在沿着 2D 圆创建点的 SO 问题之后,我有
def point(h, k, r):
theta = random.random() * 2 * pi
global x
global y
x = h + cos(theta) * r
y = k + sin(theta) * r
given the cylinder's (h,k) origin point (0, -21.56462) and r (radius = 7.625).给定圆柱体的 (h,k) 原点 (0, -21.56462) 和 r (半径 = 7.625)。 I then made these points 3D by generating az point within my range (-2.35, 12.31).
然后我通过在我的范围(-2.35、12.31)内生成 az 点来制作这些点 3D。 However, this got me half the way there because the final result was a cylinder but rotated 90 degrees clockwise.
然而,这让我走到了一半,因为最终结果是一个圆柱体,但顺时针旋转了 90 度。
Image of generated cylinder生成的圆柱体图像
What formula can I use that will generate the points in the correct direction?我可以使用什么公式来生成正确方向的点? I am not that familiar with trigonometry, unfortunately.
不幸的是,我对三角学并不熟悉。 Thanks in advance!
提前致谢!
THE SOLUTION:解决方案:
def point(h, k, r):
theta = random.random() * 2 * pi
global x
global z
x = h + cos(theta) * r
z = k + sin(theta) * r
The new (h,k) origin is now (x,z) where x and z are the coordinates for the center of the cylinder and y is randomly generated within its appropriate height range.新的 (h,k) 原点现在是 (x,z),其中 x 和 z 是圆柱体中心的坐标,y 在其适当的高度范围内随机生成。 The vector is still (x,y,z).
向量仍然是 (x,y,z)。
THE SOLUTION:解决方案:
(thanks to David Huculak) (感谢大卫胡库拉克)
def point(h, k, r):
theta = random.random() * 2 * pi
global x
global z
x = h + cos(theta) * r
z = k + sin(theta) * r
The new (h,k) origin is now (x,z) where x and z are the coordinates for the center of the cylinder and y is randomly generated within its appropriate height range.新的 (h,k) 原点现在是 (x,z),其中 x 和 z 是圆柱体中心的坐标,y 在其适当的高度范围内随机生成。 The vector is still (x,y,z).
向量仍然是 (x,y,z)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.