Thread: drawing a Circle

  1. #1
    Registered User
    Join Date
    Jun 2003

    drawing a Circle

    Oi !!

    Is it possible to draw circles in C language ?,...
    (not using graphics library)..

    I have pretty much an idea of asking a user the Coordinates (x,y)of the "Center of the Circle,".. and then asking the "Radius"...

    I find it difficult to figure out the step by step procedures and algorithms in solving this out !

    Any Comments or Suggestions ?

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    It involves trig.

    You can't draw a circle without a graphics library. You could display ascii characters, but that would be pretty dumb for a circle.
          /* display code */

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Revised a bit.
          /* display code */

    This allows you to place the circle at any x,y.

    If you don't like using radians throughout the code then use euler angles and convert those to radians in your calls to cos() and sin() - angle *PI/180

    #define DEGREES_TO_RADIANS(x) ((double)x*PI/180.0)

    Circles can be drawn faster by mirroring the pixels since all circles are symmetric. Theoretically you only need to draw one 90 degree arc and the rest can be calcuated easily on the fly. This
    means that the code only needs to go from 0 to 90 degrees which is faster than 0 to 360 or 0 to 2*pi (6.????).

  4. #4
    Registered User
    Join Date
    Apr 2002
    You can use Bresenham's circle drawing algorithm if you'd like.

    Also you don't need to do the 90 degree arc, you can do a 45 degree arc and mirror that for the 8 octants.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Drawing a circle with ASCII character
    By bnkslo in forum C Programming
    Replies: 15
    Last Post: 04-03-2008, 12:56 PM
  2. drawing circle to console
    By golom in forum C Programming
    Replies: 2
    Last Post: 12-20-2006, 10:57 AM
  3. Drawing circle into a bitmap file
    By brokensail in forum C++ Programming
    Replies: 2
    Last Post: 10-30-2006, 01:26 AM
  4. Drawing a circle using glut...
    By bennyho03 in forum C Programming
    Replies: 6
    Last Post: 10-18-2004, 10:06 AM
  5. Drawing a circle in a video captured frame
    By skyhigh in forum C Programming
    Replies: 2
    Last Post: 12-05-2001, 01:00 AM