# Calculate Vertices for Circle

## Recommended Posts

Sappharos    140
A question for someone with a more mathematical mind.

When drawing a circle on the screen using vector graphics, is there a way to calculate how many vertices should used given a specific radius, to make it appear smooth (pixel-level accuracy)? This will be less given a smaller radius, but it appears it's not directly proportional to the radius or circumference.

Thanks,

Matthew Rule

##### Share on other sites
Brother Bob    10344
A circle that has a radius or r units has a circumference of 2*pi*r units. Thus, a circle that has a radius of 100 pixels has a circumference of approximately 628 pixels. If you then want roughly pixel-accuracy, you can use 628 line segments. You can probably use half or so, but that's up to you to experiment and see what's good enough.

##### Share on other sites
alvaro    21247
I did some back-of-the-envelope computation and came up with pi*sqrt(radius/2) . Try it, or something proportional to it and see how well it works perceptually. Edited by Álvaro

##### Share on other sites
Bacterius    13165
The whole point of vector graphics is to encode resolution-independent graphics, the concept of pixel is meaningless in this context. Normally you just encode "draw circle at position C, radius R", and then just use whatever graphics API you have to draw said circle at the resolution you want (possibly with anti-aliasing).

Or maybe I'm misunderstanding the question... Edited by Bacterius