Hi, as the the title states I want to draw a circle using a 2D array. I'm trying to use the Pythagorean Theorem to find all the points on the circle, but when I run the program, nothing shows up. Here is my code:
1 2 3 4 5 6 7 8 9 10 11 12
for(int r = startPR; r < startPR + radius && r < NUM_ROWS; r++)
{
for (int c = startPC; c < startPC + radius && c < NUM_COLS; c++ )
{
if ((r*r) + (c*c) == rSquared)
{
image[r][c].redVal = 255;
image[r][c].greenVal = 0;
image[r][c].blueVal = 0;
}
}
}
startPR is the center point in rows(x), startPC is the center point in colums(y), rSqaured is the radius squared. The image is blank when I run the program so I assume the if statement is never computing to true. Any ideas? Thanks in advance.