I’m plotting points in 3d space to create a circle (looks like a wireframe disc). I have a small piece of code to do this. I’d like to now be able to figure out if a user click in my viewport intersects with the edge of my circle. I guess I need to test if the clicked point intersects the function of my circle.

Is there any formula for seeing if a point is on the edge of a circle? This is the only way I could see this working efficiently.

How could I take into account a rotation of the circle introduced by the user? I am currently plotting the circle with no rotation around the origin. If the user rotates the circle 20 degrees or some #, is it possible to take that into account as well?

I’m plotting points in 3d space to create a circle (looks like a wireframe disc). I have a small piece of code to do this. I’d like to now be able to figure out if a user click in my viewport intersects with the edge of my circle. I guess I need to test if the clicked point intersects the function of my circle.

Is there any formula for seeing if a point is on the edge of a circle? This is the only way I could see this working efficiently.

How could I take into account a rotation of the circle introduced by the user? I am currently plotting the circle with no rotation around the origin. If the user rotates the circle 20 degrees or some #, is it possible to take that into account as well?

Thanks[/b]
Normally, you’d be doing this with glRenderMode(GL_SELECT) etc.

Alternatively, you could compute the on-screen location of the circle center (cx,cy) and one point (rx,ry) on the circumference using gluProject(), determine their square distance and compare this to the square distance of the screen location of the user mouse click (ux,uy) and the circle center,

From the original post, it’s not quite clear if you want this, but just in case:
If you wish to determine the angle between the line through user input (ux,uy) and circle center (cx,cy) and the line through reference point (rx,ry) and center, you can do so with
ang=atan2(uy-cy,ux-cx)-atan2(ry-cy,rx-cx)

I’m not sure if this is applicable to your problem. But another way of doing it could be to draw a polygon over your circle in its draw function, however use blending with an alpha colour value of zero or use some other technique to make sure the polygon isn’t actually drawn. And then you can use OpenGL ‘picking’ to determine whether the user has clicked the circle.

I haven’t been able to explain my idea well, but I hope it helps.