Visible part of a circle

Started by
2 comments, last by alvaro 11 years, 8 months ago
Well I have the following issue: I have a circle this circle that need to be rendered but, I require to render only the visible part of it. The circle is actually the surface of a 2D planet and the render function is a divide_et_impera algorithm so I have the capability to zoom in and zoom out and have LOD within this circle. The function gets two parameters, the angle of start and the angle of stop, as a arch or slice of the circle. I've tried several methods like line-circle intersection or testing if the segment is visible or not and then do the division. If somebody can give me some tips on how to determine the visible area of the circle please do as such.
Here is a photo with the thing that I desire, the red part of the circle is the visible, the black rectangle is the viewport.

[attachment=10413:circle_viewport.PNG]
Advertisement
So you're trying to work out what the start and end angles are for the arc that represents the visible part of the circle? I'm not sure that will give you the answer you want, as the section directly below the centre of the circle (but still on screen) won't be drawn.

If you know the position of the circle's centre and where the bottom of the viewport is, couldn't you just test the Y coordinate during the draw?
[size="2"]Currently working on an open world survival RPG - For info check out my Development blog:[size="2"] ByteWrangler
Also, graphics hardware won't draw stuff outside the screen area--it's clipped right before the perspective divide. You don't incur the cost of drawing pixels. The only cost is the cost of processing vertices which, for a circle, probably isn't an issue. Is there some other reason why hardware's automatic clipping is unsuitable/irrelevant?

[size="1"]And a Unix user said rm -rf *.* and all was null and void...|There's no place like 127.0.0.1|The Application "Programmer" has unexpectedly quit. An error of type A.M. has occurred.
[size="2"]

I agree that you probably don't need to do any clipping of your own. But if you do, you should realize that the intersection of a circle and a rectangle can consist of up to 4 arcs. It's probably best to think of the circle as 4 arcs to begin with (one per quadrant) and clip them independently.

This topic is closed to new replies.

Advertisement