Hello!
I made an algorithm for drawing and filling a circle with pixels. But hence, it doesn't work at all... the pixels get spread all over the screen. Here is how it looks:
//Algorith for plotting a circle filled with pixels
int nRadie = 50;
double pi = 3.1415926535;
for(double v=(pi/180); v <= (2*pi); v+=(pi/180))
{
for(int z=1; z<=(nRadie); z++)
{
int y = (int)((z)/(sin(v)))+100;
int x = (int)((cos(v))*z)+100;
Plot32BitPixel(x, y, color, pixelBuffer, nPitch);
}
}
Ok, I'm no genious in neighter programming nor maths, so thes could probably be done much better but, shouldn't I at least get somewhat a circular object painted with this??
as you can see, the v is incremented with 1 degree for 360 degrees but is written in radians.
Can anyone figure out why this is so TOTALLY wrong?
I have tried to make this algorith according to these mathematical laws:
sin v = a/c
cos v = b/c
y-coordinate
^
| /|
| c/ |a
| / |
|/v__|___ > x-coordinate
b
a, b, c = lenght of the sides on the triangle
v = degrees between y = 0 and the current y value
(triangle in a Coordinate system)
THX!
[edited by - FxMazter on December 23, 2002 6:51:34 PM]
[edited by - FxMazter on December 23, 2002 6:55:27 PM]
[edited by - FxMazter on December 23, 2002 6:57:26 PM]
[edited by - FxMazter on December 23, 2002 6:58:17 PM]
[edited by - FxMazter on December 23, 2002 7:00:32 PM]
[edited by - FxMazter on December 23, 2002 7:02:13 PM]