# Formula For Circle..

This is a discussion on Formula For Circle.. within the C Programming forums, part of the General Programming Boards category; Hi all, anyone haf formula for circle... not the pi*r*r one.... Is the formula to get every points on the ...

1. ## 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....
xiao guang

2. x^2 + y^2 = r^2

3. 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.

4. may i noe wat precision u refer to..??

5. Originally posted by xiao guang
may i noe wat precision u refer to..??
const float PRECISION = 0.001f;

As per the posted code.

Quzah.

Popular pages Recent additions