Say you have a center of $(5, 5)$ and a radius of $2$. If you went for each x-value in $\{3, 4, 5, 6, 7\}$, how would you find the y value?
EDIT: I have this code in C#
for (int i = centerx - radius; i <= centerx + radius; i++) { double y0 = centery + Math.Sqrt((double)(radius ^ 2 - (i - centerx) ^ 2)); double y1 = centery - Math.Sqrt((double)(radius ^ 2 - (i - centerx) ^ 2)); int y2 = Convert.ToInt32(Math.Round(y0)); int y3 = Convert.ToInt32(Math.Round(y1));
This gives some weird results, it makes a weird line, not anything like a circle at all. Any help is appreciated.
EDIT2: Same thing as before
int[] array_x = new int[radius*2+1]; int x = 0; for (int i = -radius; i <= radius; i++) { array_x[x] = i; x++; } for (int i = 0; i <= array_x.Length; i++) { double y0 = centery + Math.Sqrt((double)(radius ^ 2 - (array_x[i] - centerx) ^ 2)); double y1 = centery - Math.Sqrt((double)(radius ^ 2 - (array_x[i] - centerx) ^ 2)); int y2 = Convert.ToInt32(Math.Round(y0)); int y3 = Convert.ToInt32(Math.Round(y1));