Given a point on a circle, find it on a given square Math is not my forte so I apologize. I have a seemingly simple problem and I'm unable to figure out the formula for this.
I'd describe the problem as given the center point of a circle and a point on the edge of the circle, find the same point on a square with the same length as the diameter of the circle.

The filled in points in this image are the ones I'm trying to find.
As an addition, I'd love some online resources on where I can learn how to do this kind of math and intuitively find the answer for myself in the future. Cheers.

Suppose the circle and square is centered at $(0,0)$ the circle has radius $r$ and the square has sides $2r$.  The midpoint of the sides of the square are $(0,r), (r,0), (0, -r), (-r,0)$ and the corners are $(-r,r),(r,r), (r,-r)$ and $(-r,-r)$.
Okay a point on the circle is $(x_1,y_1)$
So the equation of the line from $(0,0)$ to $(x_1, y_1)$ will have slope $m=\frac {x_1}{y_1}$.  And the equation of the line is $y = \frac {x_1}{y_1}x$.
Now there are four cases to consider based on what side of the square the line will intersect.
Case 1:  The line goes through the right side of the square.
That means $x_1 > 0$ and $|y_1| \le x_1$ and so $ -1 \le m \le 1$.
So if $m = 1$ then the line will go through the right side of the square.
So let that point be $(r, y_2)$.
But theb we have the formula $y = mx$ so $y_2 = mr =\frac {y_1}{x_1}r$. and the point on the square is $(r, \frac {y_1}{x_1}r)$
Case 2:
The line passes through the top of the square.
Then $y_1 > 0$ and $|x_1| \ge y_1$ and so $|m| =|\frac {y_1}{x_1}| \ge 1$
So if $m > 1$ or $m < -1$ then the line goes through the top the square.
And the point is $(x_2, r)$.
I should point out that if the point of the circle was $(x_1, y_1) = (0, r)$ then we'd have a case where $m = \frac {y_1}{x_1} =\frac r0 =\infty$.  This is the case that the line is completely vertical.
In this case it's obvious the point on the square is the exact same point of the circle so the point is $(0,r)$.  Otherwise....
The equation of our line is $y = mx =\frac{y_1}{x_1}$ so $r = m x_2$ and $r = \frac {y_1}{x_1} x_2$ so $\frac {x_1}{y_1}r = x_2$.
And the point is $(\frac {x_1}{y_1}r, r)$>
....
The case where the line goes through the left and right side are similar.
If $-1 \le m \le 1$ but $x_1 < 0$ then the line goes through the left side of the square and
the point is $(x_2, y_2) = (-r, -r\frac {y_1}{x_1})$.
And if $m \le -1$ or $m \ge 1$ (or $x_1 = 0$ and $m = \infty$) but $y_1 < 0$ then the line goes through the bottom of the square and
the point is $(x_2, y_2) = (-r\frac {x_1}{y_1} ,-r)$
