用2点和圆心画圆弧
我有两个圆点和圆心。我想在这些点之间画一条弧线。方法 drawArc
过于简单,不符合我的目的。 有人帮忙吗?
I have two points of circle and center of this circle. I want to draw an arc between these points. Method drawArc
is to simple and doesn't fit my purpose.
Anybody help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Canvas.drawArc,但必须计算它所需的参数:
假设圆的中心是 (x0, y0),弧包含两个点 (x1, y1) 和 (x2, y2)。那么半径为:r=sqrt((x1-x0)(x1-x0) + (y1-y0)(y1-y0))。所以:
祝你好运!
You can use Canvas.drawArc, but you must compute the arguments it needs:
Lets say that the center of the circle is (x0, y0) and that the arc contains your two points (x1, y1) and (x2, y2). Then the radius is: r=sqrt((x1-x0)(x1-x0) + (y1-y0)(y1-y0)). So:
Good luck!
Graphics.drawArc
需要以下参数:给定圆弧起点和终点,可以计算将在其中绘制圆弧的边界框。这为您提供了足够的信息来提供参数:x、y、宽度和高度。
您还没有指定所需的角度,所以我猜您可以任意选择一个。
Graphics.drawArc
expects the following parameters:Given your arc start and end points it is possible to compute a bounding box where the arc will be drawn. This gives you enough information to provide parameters: x, y, width and height.
You haven't specified the desired angle so I guess you could choose one arbitrarily.