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));
Hint: the equation for a circle is given by $$(x - a)^2 + (y-b)^2 = r^2$$
$$\text{OR}\quad y=b\pm \sqrt{r^2-(x-a)^2}$$
where $(a, b)$ is the center of the circle, and $r$ it's radius.
$(1)$ What is your center? So $a = b = \;?\;\;$ And radius $\;r=\;?\;\;$
$\quad\;$ Just substitute the values you have into the equation for a circle to define your circle.
$(2)$ Then use each of your given $x$-values to determine/solve for the corresponding $y$-values using
$\quad\;$the formula you arrive at in $(1)$. (You should find two $y$-values for each $x$.)