# zooming in on parts of a circle

This topic is 3851 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

This is all strictly 2d. I am trying to add a functionality where the user can select a part of a circle by highlighting the circle and then zoom in on the selected part. So far I have been able to reproduce it by: -calculate the zoom factor -repositioning the origin of the circle based on the zoom -multiply the radius by the new zoom -redraw the circle basically I am just redrawing a bigger circle off the screen to emulate the appearance of zooming. In addition to drawing the circle, I am also drawing hash marks on the circle to indicate degrees. So when the entire circle is displayed, there are 360 hashmarks indicating each degree. As you zoom in, more hashmarks are displayed to indicate the fractional degrees (ex. 90.1, 90.2..) So the obvious problem now is that as I zoom in more, the system has to redraw the entire circle with all the hashmarks. If the user selects only 0.5 degrees of the circle, the system has to redraw the entire circle and add in over 360000 hashmarks. Needless to say, its stupidly slow. Are there any resources or mathematical technique I can use to calculate the bezier curve after I zoom in on a circle? So the system will only need to redraw the curve instead of the entire circle and add only the hashmarks needed? I am trying to do all this with vector graphics btw. [Edited by - daemonk on July 6, 2008 11:10:18 PM]

##### Share on other sites
If the screen rectangle does not contain the circle center, then find which segments of the screen rectangle the circle intersects with. If there are no intersections, then the rectangle is either completely inside the circle, or completely outside it, and you don't need to draw it at all.

If there is one intersection, we've hit purely mathematical boundaries; count it as zero intersections. If there are three intersections, then you've hit a purely mathematical intersection on one line segment. Count it as four intersections, with the doubled intersection twice.

If there are two intersections, we have an easy case. Find the extent of the intersections in terms of angle from the circle origin. So, if the circle enters the bottom of the rectangle and leaves at the top a little further to the right, find the angles from 0° to these points. Then, render the circle and ticks only within this extent.

If there are four intersections, we have something like the circle entering at the right, leaving at the top, then re-entering at the top and leaving at the left. Do the two-intersection case twice, once for each of the two extents.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 11
• 9
• 9
• 44
• ### Forum Statistics

• Total Topics
634131
• Total Posts
3015720
×