java中drawArc参数的含义_高精度的Java圖形drawArc

在Java中使用AWT/Swing的drawArc方法绘制大半径弧线时,由于startAngle和arcAngle参数为整数度导致精度问题。解决方案包括使用Arc2D对象允许浮点角度参数,并设置Graphics2D的抗锯齿属性,或者利用Graphics2D的rotate方法精确绘制弧线。
摘要由CSDN通过智能技术生成

I'm trying to draw a high precision arc in Java using AWT/Swing. The Graphics class offers the "drawArc" method to do this and in most cases this is fine. However, when the arc has a large radius (I.e. The "width" and "height" parameters are large) then the arc will not be drawn precisely. This is because the "startAngle" and "arcAngle" parameters are given as integer degrees. I'm forced to convert an angle (given in radians) to degrees and then rounding it. The loss of precision leads to the arc falling short of its actual end point (if you round down) or go further than it should (if you round up).

我想用AWT/Swing在Java中畫一個高精度的弧線。圖形類提供了“drawArc”方法來實現這一點,在大多數情況下這是可以的。但是,當圓弧的半徑較大(即“寬度”和“高度”參數較大)時,圓弧就不會被精確地繪制出來。這是因為“startAngle”和“arcAngle”參數是作為整數度給出的。我被迫把一個角度(以弧度表示)轉換成度數,然后把它四舍五入。精度的損失會導致圓弧無法達到它的實際端點(如果你將圓弧向下)或者比它應該走的更遠(如果你將圓弧向上)。

I'm looking for an alternative

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值