emailhy
emailhy

Reputation: 780

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

The problem is draw arc with two pints on bitmap with radius and clockwise direction.

Upvotes: 0

Views: 1355

Answers (1)

Pedery
Pedery

Reputation: 3636

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);
}

Upvotes: 1

Related Questions