Thread: Circle in C

  1. #1
    Unregistered
    Guest

    Question Circle in C

    I know this is a newbie question, but how do I design a circle in Unix C?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    What do you mean?

    -How to calculate the dimensions for a given circle??

    -How to draw one with dos graphics(I dunno)

    -???
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    197

    Question

    If you would give us a better expression of what you want,
    we could answer to your question!

    klausi
    When I close my eyes nobody can see me...

  4. #4
    Unregistered
    Guest
    I want to know how do I design a circle in Unix C, just using the math.h library and this formula:

    x^2 + y^2 = R^2

    where r is the radius.

  5. #5
    Registered User pub_enemy01's Avatar
    Join Date
    Nov 2001
    Posts
    2
    Hello.

    Hmm...That sounds more like a mathematical question than a computer programming question. Find a good geometry or trig book, they should tell you there. Good Luck!

    Remember, a programmers creativity is more important than any code that they learn, because without creativity, it is impossible to apply that code.

  6. #6
    Sayeh
    Guest

    Circle Algorithm

    The hard way is to use sin and cosign to calculate a circle. The easy way is to use the Bresenhem algorithm. He also invented one for lines as well. Excellent programming probject to learn how to create graphic primitives.

    The Bresenhem circle algorithm essentially does the math required to calculate 1/4 of the circle. It then mirrors the other three quadrant's from the first. Effecient.

    enjoy.

  7. #7
    Registered User Zeeshan's Avatar
    Join Date
    Oct 2001
    Location
    London, United Kingdom
    Posts
    226
    Hey guys...
    I don't know the answer. But, I think what he wants to know is how to put the pixels onto the screen.
    He already has the formula for drawing with center at the origin.

    >> x ^ 2 + y ^ 2 = r ^ 2

    So, if any1 of you does know it...You should tell him how to put pixels onto the screen...

    My Pseudo-code
    _____________

    for (float x=0;x!=r;x+=1)
    {
    y = sqrt(r^2 - x^2);
    putpixel(x,y,color);
    }

    for (float x=0;x!=r;x-=1)
    {
    y = sqrt(r^2 - x^2);
    putpixel(x,y,color);
    }

    -----
    or for a better algorithm check out the TUTORIAL pages on this site for Denthor's Grafix Tutorials - i think it's the lesson3
    Last edited by Zeeshan; 11-06-2001 at 09:14 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. circle problem
    By gunghomiller in forum C++ Programming
    Replies: 10
    Last Post: 07-14-2007, 06:40 PM
  2. Drawing circle into a bitmap file
    By brokensail in forum C++ Programming
    Replies: 2
    Last Post: 10-30-2006, 01:26 AM
  3. Half of the circle
    By hdragon in forum Game Programming
    Replies: 14
    Last Post: 03-10-2006, 10:15 PM
  4. circle filling
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-08-2002, 05:37 AM
  5. point lies in circle?
    By cozman in forum Game Programming
    Replies: 3
    Last Post: 12-20-2001, 04:39 PM