25
Covered in the comp.graphics.faq
在comp.graphics.faq
Excerpt:
Subject 4.04: How do I fit a Bezier curve to a circle?
主题4.04:我如何将一个Bezier曲线贴到一个圆上?
Interestingly enough, Bezier curves can approximate a circle but not perfectly fit a circle. A common approximation is to use four beziers to model a circle, each with control points a distance d=r*4*(sqrt(2)-1)/3 from the end points (where r is the circle radius), and in a direction tangent to the circle at the end points. This will ensure the mid-points of the Beziers are on the circle, and that the first derivative is continuous.
The radial error in this approximation will be about 0.0273% of the circle's radius.
有趣的是,Bezier曲线可以近似一个圆,但不完全适合一个圆。一个常见的近似方法是用四个贝齐尔模型来模拟一个圆,每一个都有一个距离d=r*4*(sqrt(2)-1)/3从端点处(r为圆半径),并在一个方向与圆的端点相切。这将确保Beziers的中点在圆上,并且一阶导数是连续的。这个近似的径向误差大约是圆半径的0.0273%。
Michael Goldapp, "Approximation of circular arcs by cubic polynomials" Computer Aided Geometric Design (#8 1991 pp.227-238)
Michael Goldapp,“三次多项式圆弧的近似”计算机辅助几何设计(# 81991pp.227 -238)
Tor Dokken and Morten Daehlen, "Good Approximations of circles by curvature-continuous Bezier curves" Computer Aided Geometric Design (#7 1990 pp. 33-41). http://www.sciencedirect.com/science/article/pii/016783969090019N (non free article)
Tor Dokken和Morten Daehlen,“由曲率连续的Bezier曲线的良好近似”计算机辅助几何设计(#7 1990 pp. 33-41)。http://www.sciencedirect.com/science/article/pii/016783969090019N(非免费的文章)
Also see the non-paywalled article at http://spencermortensen.com/articles/bezier-circle/
还可以在http://spencermortensen.com/articles/bezier-circle/上看到非付费的文章。
Browsers and Canvas Element.
Note that some browsers use Bezier curves to their canvas draw arc, Chrome uses (at the present time) a 4 sector approach and Safari uses an 8 sector approach, the difference is noticeable only at high resolution, because of that 0.0273%, and also only truly visible when arcs are drawn in parallel and out of phase, you'll notice the arcs oscillate from a true circle. The effect is also more noticeable when the curve is animating around it's radial center, 600px radius is usually the size where it will make a difference.
注意,一些浏览器使用贝塞尔曲线的帆布画弧,Chrome使用(目前)4部门方法和Safari使用8部门的方法,只在高分辨率的区别是明显的,因为,0.0273%,也只有真正可见弧时并行的阶段,你会注意到弧振动从一个真正的圆。当曲线在它的径向中心周围运动时,效果也会更明显,600像素的半径通常是它会产生影响的大小。
Certain drawing API's don't have true arc rendering so they also use Bezier curves, for example the Flash platform has no arc drawing api, so any frameworks that offer arcs are generally using the same Bezier curve approach.
某些绘图API没有真正的圆弧渲染,因此它们也使用Bezier曲线,例如Flash平台没有arc绘图API,因此提供arcs的任何框架通常都使用相同的Bezier曲线方法。
Note that SVG engines within browsers may use a different drawing method.
注意,浏览器中的SVG引擎可能使用不同的绘图方法。
Other platforms
Whatever platform you are trying to use, it's worth checking to see how arc drawing is done, so you can predict visual errors like this, and adapt.
无论你想要使用什么平台,都值得检查一下如何绘制圆弧图,这样你就可以预测出这样的视觉错误,并进行调整。