如何制作在矩阵内绘制圆弧的函数? [英] How do I make a function to draw arcs inside a matrix?

查看:97
本文介绍了如何制作在矩阵内绘制圆弧的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要制作一个在矩阵内绘制圆弧的函数/方法.我会使用1s作为塑造弧的点,使用0s作为空白点.因此,该函数将产生类似于此矩阵的东西(只有我会在现实中使用1400x700矩阵):

I need to make a function/method that draws arcs inside a matrix. I would use 1s as points that shape the arc and 0s as empty spots. So the function would produce something like this matrix (only I would use 1400x700 matrix in reality):

000000000000000
000100000001000
000010000010000
000000111000000
000000000000000

我需要将以下参数传递给函数:

I need to pass the following parameters to the function:

x: x坐标

y: y坐标

w:宽度

h:高度

start:起始角度,以度为单位

start: the start angle, in degrees

extent:范围,以度为单位

现在,我不知道该怎么做.有人可以帮助我吗?

Now, I don't know the math on how to do it. Anyone could help me?

推荐答案

提示:

圆弧是方程域的边界

(X - Xc)² + (Y - Yc)² ≤ R².

起点可以是

(Xc + R, Yc).

现在从已知点开始,可以执行轮廓跟踪,即重复查找下一个验证不等式的8个邻居.

Now from a known point, you can perform contour following, i.e. repeatedly find the next 8-neighbor that verifies the inequation.

这为您提供了一个全球性的想法.处理起点和终点有些棘手.通过将工作分成8个八分圆,可以实现优化.但这是一个更长的故事.

This gives you a global idea. Handling the start and end point is a little tricky. And optimizations are possible by splitting the work in 8 octants. But this is a longer story.

这篇关于如何制作在矩阵内绘制圆弧的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆