SolvedCircles!! help

Posts 15 of 5 · Page 1 of 1
Circles!! help
im trying to get a perfect circle going here
im using this code below.
its not exactly a perfect circle though
more like a Octacontagon its circular but with rough edges
any suggestions?

Code:
void circle(int rx, int ry, int r)
{
int x,y;
double d;//detail
const double pi = 3.14159265; //more or less
for(d=0; d<=2*pi; d+=0.01) //you can play with the value to be added to d
{
x=rx+sin(d)*r;
y=ry+sin(d+(pi/2))*r;
putpixel(x,y);
}
}

Quote Originally Posted by -Bl00d- View Post
im trying to get a perfect circle going here
im using this code below.
its not exactly a perfect circle though
more like a Octacontagon its circular but with rough edges
any suggestions?

Code:
void circle(int rx, int ry, int r)
{
int x,y;
double d;//detail
const double pi = 3.14159265; //more or less
for(d=0; d<=2*pi; d+=0.01) //you can play with the value to be added to d
{
x=rx+sin(d)*r;
y=ry+sin(d+(pi/2))*r;
putpixel(x,y);
}
}

If this is for a directX game construct 360 vertices one from each degree of rotation and then allow directX to render the necessary lines.
Example code (i just wrote this up here, so there may be errors0
Code:
void render(int xLoc, int yLoc, int rad){
//create pLine here, dont feel like looking up params list for D3DXCreateLine()
D3DXVECTOR2 vec[360];
for(int i = 0; i < 360; ++i){
vec[i].x=xLoc+(rad*cos((i)*(PI/180)));
vec[i].y=yLoc+(rad*sin((i)*(PI/180)));
}
pLine->Begin(); 
pLine->Draw(vec,360,D3DCOLOR_XRGB(10,200,10)); 
pLine->End(); 
}
ahhh! Saltine your awesome dude!
Quote Originally Posted by -Bl00d- View Post
ahhh! Saltine your awesome dude!
Oh, if you do create pLine every function call don't forget to do pLine->Release(); at the end of the function or it will leak memory like a bitch
I was about to mention Saltine to this thread since I know he loves circles. Guess he already got to it

/Solved
/Closed
Posts 15 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?