Sign in to follow this  
Sappharos

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 this post


Link to post
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 this post


Link to post
Share on other sites
alvaro    21246
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this