Thread: Formula For Circle..

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    8

    Formula For Circle..

    Hi all,
    anyone haf formula for circle... not the pi*r*r one....
    Is the formula to get every points on the circumferece of the circle...
    Hope someone can help me....
    Thanks in advance,
    xiao guang

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    x^2 + y^2 = r^2
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Well it all depends on what you are going to use the points for. Are you planning on drawing them to the screen? If so you can use some circle drawing algorithms here:

    http://www.cs.unc.edu/~mcmillan/comp...e7/circle.html

    If you just want floating-point numbers you could use a very naive and slow brute force method with cosine and sine..

    Code:
    const float PRECISION = 0.001f;
    const float RADIUS = 150.f;
    
    float x, y;
    
    for( float i = 0.f; i < 2*PI; i += PRECISION )
    {
      x = cosf( i ) * RADIUS;
      y = sinf( i ) * RADIUS;
    
      // Do something with this point...
    }

    EDIT:

    I should've read your question more carefully, I assumed you wanted to know how to calculate points on a circle. I didn't even see where you had type "formula". Oh well maybe someone will find this of use.
    Last edited by MrWizard; 11-17-2003 at 07:09 AM.
    "...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

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    8
    may i noe wat precision u refer to..??

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by xiao guang
    may i noe wat precision u refer to..??
    const float PRECISION = 0.001f;

    As per the posted code.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Zeller's Formula
    By unejam2005 in forum C++ Programming
    Replies: 6
    Last Post: 11-14-2005, 09:48 PM
  2. how to change char to formula
    By kosong in forum C Programming
    Replies: 2
    Last Post: 06-09-2003, 04:31 AM
  3. Math formula (js -->C++)
    By Demon1s in forum C++ Programming
    Replies: 20
    Last Post: 05-02-2003, 05:22 AM
  4. Need help with this formula -b/2a..Please read.
    By foofoo in forum C Programming
    Replies: 4
    Last Post: 06-04-2002, 11:59 PM
  5. Formula string conversion
    By Gr3g in forum C++ Programming
    Replies: 2
    Last Post: 04-12-2002, 08:28 PM