I have a circle and have to check if a rectangle is inside it. I want to find the furthest corner of the rectangle and then check if it's inside the circle. I have a problem with the first part. I saw that people do:
dx = max(centerX - rectLeft, rectRight - centerX);
dy = max(centerY - rectTop, rectBottom - centerY);
But isn,t that wrong? For example i have center (5,6) topLeft (-2,-3) width=9 height=8
dx = max( 5 - -2, -2 + 9 - 5) = max(7, 2) which is 7 = OK
but
dy = max( 6 - -3, -3 - 8 - 6) = max( 9, -17 ) = 9
which is not OK because 17 stands further than the center. Am I wrong or I should use fabs to make point 17 instead of -17?