gpt4 book ai didi

python - 通过围绕枢轴旋转 3d 点创建一个圆

转载 作者:行者123 更新时间:2023-12-05 06:54:34 26 4
gpt4 key购买 nike

我想旋转一个 3d 点并使用每个旋转步骤创建一个圆。我手上只有一个起点(pos1,1x3 数组),表示圆应该从哪里开始。这个点应该在一个轴上顺时针旋转,不改变 r 并围绕原点创建 10 个不同的 3d 点,它们均匀分布在圆上,见下图:

Image

为此,我实现了 2D 旋转矩阵并以给定角度在 xy 方向上旋转我的点 pos1,但看起来它不会在最后创建一个圆圈。

def rotate_point(origin, point, angle):
angle = math.radians(angle % 360)

rotatedX= origin[0] + (point[0] - origin[0]) * math.cos(angle) - (point[1] - origin[1]) * math.sin(angle)
rotatedY= origin[1] + (point[0] - origin[0]) * math.sin(angle) + (point[1] - origin[1]) * math.cos(angle)
return rotatedX, rotatedY

def main():
origin= np.array([0, 0, 0])
point_to_rotate = np.array([1.12, 199.32, 1062.88])
theta = 10

rotatedPoint= rotate_point(origin, point_to_rotate , theta)
print('rotatedPoint:', rotatedPoint)

编辑:如果我在 for 循环中以逆时针方向运行它,它实际上会执行它应该执行的操作。

def main():
origin= np.array([-1.14, 172.59, 1078.31])
point_to_rotate = np.array([1.12, 199.32, 1062.88])
theta = 0
for i in range(10):
theta = theta+36
rotatedPoint= rotate(origin, point_to_rotate , theta)
print('i:', i, 'degree: ', theta, 'rotate:', rotatedPoint)

编辑 2:如果我不增加度数而是减少度数,那么它会按顺时针方向创建点:

theta = 360 

然后进入:

theta = theta-36

最佳答案

查看我的问题解决方案的编辑。这是一个基于旋转点创建的圆。

enter image description here

enter image description here

关于python - 通过围绕枢轴旋转 3d 点创建一个圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65512568/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com