开发者

how to draw circular arc with give two points and radius and clockwise direction

开发者 https://www.devze.com 2023-02-09 20:55 出处:网络
The problem is draw arc with two pints on 开发者_如何学Pythonbitmap with radius and clockwise direction.From your one-sentence question, I\'m gonna assume you\'re ok with drawing Bezier curves. If not

The problem is draw arc with two pints on 开发者_如何学Pythonbitmap with radius and clockwise direction.


From your one-sentence question, I'm gonna assume you're ok with drawing Bezier curves. If not, there is plenty of information about them out there.

Anyway, you cannot create a perfect circular arc with Bezier curves (or splines). What you can do is approximating a circle to a level where the eye won't be able to see the difference. This is usually done with 8 quadratic Bezier curve segments, each covering 1/8th of the circle. This is i.e. how Adobe Flash creates circles.

If you're after a plain parametrization using sin and cos, it's way easier:

for (float t = 0; t < 2 * Math.PI; t+=0.05) {
    float x = radius * sin(t);
    float y = radius * cos(t);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消