Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


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.

  • You cannot reply to this topic
3 replies to this topic

#1 Sappharos   Members   -  Reputation: 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

Sponsor:

#2 Brother Bob   Moderators   -  Reputation: 8616

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   Crossbones+   -  Reputation: 13933

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.


#4 Bacterius   Crossbones+   -  Reputation: 9289

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.

The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis





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.



PARTNERS