Simple math question which I need for my programming but I haven't been able to work out. I have this diagram to show how the core concept looks: If the diameter of the circle is 20cm, how do I calculate how long the square is diagonally? Thanks.

Since diameter is 20, then i *hope* the sides are 20cm since they look tangental. Then, using pythagoras theorem to get diagonal length of square, i.e: √((20^2)+(20^2) = √800 = 20√2

The square is 20 by 20 (you can deduce that from the diameter) so you just use Pythagoras. The diagonal part is the squareroot of 20^2+20^2 = 28.28