How would one check if a square is within a circle?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How would one check if a square is within a circle?
I haven't looked it up, but ok I'll trust your solution, pgimeno.
Re: How would one check if a square is within a circle?
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.
Who is online
Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Google [Bot] and 5 guests