Re: How would one check if a square is within a circle?
Posted: Thu Feb 18, 2021 5:57 pm
I haven't looked it up, but ok I'll trust your solution, pgimeno.
I know, the (squared_distance(corner, center) > radius^2) is much fasterpgimeno wrote: ↑Thu Feb 18, 2021 5:20 pm If distance(corner, center)^2 > radius^2 then Return true -- at least one corner is out of circle
By cancelling the square root in distance() with the squaring above, you save four square roots. The radius^2 can be calculated once before the loop. I believe that's the protip that eliddell suggested.