Thread: Draw a circle?

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    9

    Draw a circle?

    I am completely stuck on how to draw a circle in c++ any advice?

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Need to be using a graphics library: DirectX, OpenGL, SDL, etc... There are some OpenGL tutorials on this site.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    trig man, trig
    you know that unit circle thing they taught you? you need it.

    Sines and Cosines are a wonderful thing
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  4. #4
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    Thumbs down Standard ANSI/ISO C++ has NO GRAPHICS!

    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.

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    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.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #6
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    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
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Half of the circle
    By hdragon in forum Game Programming
    Replies: 14
    Last Post: 03-10-2006, 10:15 PM
  2. Draw The Circle
    By rifatgunduz in forum C++ Programming
    Replies: 11
    Last Post: 01-26-2005, 06:49 AM
  3. Draw circle
    By Roaring_Tiger in forum C Programming
    Replies: 7
    Last Post: 09-30-2004, 07:16 PM
  4. Best way to draw circle!!??
    By OneStiffRod in forum Game Programming
    Replies: 12
    Last Post: 04-28-2003, 07:57 AM
  5. point lies in circle?
    By cozman in forum Game Programming
    Replies: 3
    Last Post: 12-20-2001, 04:39 PM