I am completely stuck on how to draw a circle in c++ any advice?
Printable View
I am completely stuck on how to draw a circle in c++ any advice?
Need to be using a graphics library: DirectX, OpenGL, SDL, etc... There are some OpenGL tutorials on this site.
trig man, trig
you know that unit circle thing they taught you? you need it.
Sines and Cosines are a wonderful thing
There are NO graphics in standard C++. Your compiler may have a graphics library (graphics.h or something). If not, like Zack L. said, you need an additonal 3rd-party library.
You should not have to use trigonometry to calculate a circle. And, that won't help if you can't "draw" on the screen. For example, I believe Windows has a DrawCircle() function... although I'm not sure if that's the correct name of the function.
ah, but you use trig indirectly when you use the library. I assumed that he is able in some form to draw graphics because of the nature of the post. If the method he's using does not include a circle routine he could easily write one.
Common method:
cosine table pre-calculated. You create a series of points around the circle and simply draw lines from point to point. since the cosine table is pre-generated you get to draw them with blazing speed.
Zach and Doug, your graphics library is doing the same thing I assure you.;)
Of course you need trig, but chances are that the graphics library will contain either a draw_circle type function or a draw_ellipse with variable eccentricity, which you merely set to 0, and you're good.
By the way, here are some links:
www.opengl.org
www.libsdl.org
newx=x+cos(angle)*radius;
newy=y+sin(angle)*radius;
This is the general idea but you will need much more. Check out google - many many sites talk about several diff methods of doing this.