• Create Account

## Calculate Vertices for Circle

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1Sappharos  Members

140
Like
0Likes
Like

Posted 17 November 2012 - 01:41 PM

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

### #2Brother Bob  Moderators

10108
Like
0Likes
Like

Posted 17 November 2012 - 01:58 PM

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.

### #3Álvaro  Members

20266
Like
0Likes
Like

Posted 17 November 2012 - 02:06 PM

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, 17 November 2012 - 02:06 PM.

### #4Bacterius  Members

13102
Like
0Likes
Like

Posted 18 November 2012 - 03:00 AM

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, 18 November 2012 - 03:00 AM.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.