gpt4 book ai didi

计算形状的半径

转载 作者:行者123 更新时间:2023-11-30 14:27:24 25 4
gpt4 key购买 nike

我正在训练使用放射线识别道路标志形状。我有形状的中心点,我必须找到 7 个径向线来识别该图形。要找到 7 个径向线,我必须找到 0°、30°、60° 和 90° 处的点,如下图所示(图像 a):

https://lh4.googleusercontent.com/-sFsGXGD9VGI/TqxRjwIoSPI/AAAAAAAAAD0/yUOhN7RNUhU/s445/radiais.png

问题是,我不知道如何找到与我的中心成 30° 的点。

看,在我的第一次植入中,我计算了 5 个径向线(0°、45° 和 90°),如图像 b:为了找到 0° 处的点,我做了:

//fix the y coordinate and increment x coord
for(x = center.x to width)
pixel(x, center.y)

为了找到 90° 的点,我做了:

//fix the x coordinate and increment y coord
for(y = center.y to height)
pixel(center.x, y)

为了找到 45° 的点,我做了:

//increment x and y coord in the same number
for(x = center.x, y = center.y to width, height)
pixel(x, y)

所以,我想知道如何访问 30° 和 60° 的点。

ps.:抱歉,还不能发布图片!没有声誉。

最佳答案

您可以使用极坐标系。这是一个伪代码:

theta = 30 * pi / 180                      // 30, 60, whatever
for r = 0 to length_of_line
x = center.x + r * cos(theta)
y = center.y + r * sin(theta)
pixel(x, y)

这样你就可以绘制倾斜度为 12, 16, 94.7362, ... 度的径向线

关于计算形状的半径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7941149/

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