绘制圆弧点
有人可以为我提供一种在弧上画点的算法吗?我知道起点、终点和半径。我需要显示由这些信息形成的圆弧上的点(起点、终点和半径)。
查看图片了解更多详情
我有起点 (x,y)、终点(a,b)。我必须计算弧上 5 个点的相等距离。是否可以?
Can someone provide me an algorithm to draw points on arc? I know the start-point, end-point and radius. I need to show points on the arc made by this information(start-point, end-point and radius).
See the image for more details
I have Start-Point (x,y), End-Point(a,b). I have to calculate equally distance 5 points on arc. Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标准算法是中点圆算法(有时称为 Breshenham 圆算法)。
请注意,您的弧规范不完整。通常有两条半径相同的圆弧连接两个给定点,一条圆心位于连接点的线的每一侧。此外,正如 @In silico 指出的那样,半径不能小于点之间距离的一半。
The standard algorithm for this is the Midpoint circle algorithm (sometimes called Breshenham's circle algorithm).
Note that your arc specification is incomplete. There are generally two arcs of the same radius joining two given points, one for the center on each side of the line joining the points. Also, as @In silico points out, the radius can be no smaller than half the distance between the points.
指定弧线的方式和SVG中使用的类似,有一些详细的实现注释太长,无法复制到此处。对于圆弧,x 和 y 半径相等,因此 x 轴角度并不重要。正如 Ted Hopp 所指出的,您需要一个标志来指示弧线绘制的方向(在 SVG 中称为
large-arc-flag
)。一旦获得圆弧的中心和起点和终点的角度,将角度分为六份,并使用该角度的正弦/余弦来绘制五个中间点。
The means of specifying an arc is similar to that used in SVG, which has some detailed implementation notes which are too long to copy here. For circular arcs, the x and y radii are equal so the x axis angle is not important. As Ted Hopp noted, you need a flag to indicate which direction the arc is drawn in ( in SVG called
large-arc-flag
).Once you have the centre and angles of start and end of the arc, divide the angle into six and use the sin/cos of this angle to plot the five intermediate points.