在拱门上找到x和y

2024-06-16 14:00:30 发布

您现在位置:Python中文网/ 问答频道 /正文

enter image description here

大家好。我的数学不是很好,所以我需要帮助用Python编写函数。有一个拱门,我需要知道拱门上每个像素的xy。我所有的数据,我都写在图片上了。如果需要进一步澄清,请告诉我


Tags: 数据函数图片数学像素拱门
1条回答
网友
1楼 · 发布于 2024-06-16 14:00:30

有了弧长和半径,我们可以用弧度来计算弧角

fi = L/R= 366.5/350  (60 degrees, BTW)

半角

hf = fi/2 = 366.5/700   (30 degrees)

圆心坐标

cx = R * sin(hf) = 350*1/2 = 175
cy = R * cos(hf) = 350*0.866 = 303.1

现在我们可以进行循环,以获得具有给定分辨率的像素坐标,起始角度为-Pi/2-Pi/6(一般情况下为-Pi/2-hf

for i in range(2220):
   an = -math.pi*2/3  +  i * 366.5/350 / 2220
   x = cx + R * math.cos(an)
   y = cy + R * math.sin(an)

要更正代码,请执行以下操作:

cx = radius * math.sin(hf)
cy = -radius * math.cos(hf)

xl.append(cx + radius * math.cos(an))
yl.append(cy - radius * math.sin(an))

相关问题 更多 >