• Create Account

## Visible part of a 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

### #1kosmync64  Members

103
Like
0Likes
Like

Posted 01 August 2012 - 05:30 PM

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.

### #2Postie  Members

1459
Like
0Likes
Like

Posted 01 August 2012 - 06:31 PM

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?
Currently working on an open world survival RPG - For info check out my Development blog:

### #3Geometrian  Members

1809
Like
0Likes
Like

Posted 01 August 2012 - 07:04 PM

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?

Edited by Geometrian, 01 August 2012 - 07:05 PM.

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.

### #4Álvaro  Members

20253
Like
0Likes
Like

Posted 02 August 2012 - 07:49 AM

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.

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.