We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4d2e563 commit 00abf9eCopy full SHA for 00abf9e
src_c/circle.c
@@ -384,13 +384,16 @@ pg_circle_contains(pgCircleObject *self, PyObject *arg)
384
/*a circle is always contained within itself*/
385
Py_RETURN_TRUE;
386
}
387
- double dx, dy, dr;
+ /* a bigger circle can't be contained within a smaller circle */
388
+ if (temp->r > scirc->r) {
389
+ Py_RETURN_FALSE;
390
+ }
391
- dx = temp->x - scirc->x;
- dy = temp->y - scirc->y;
- dr = temp->r - scirc->r;
392
+ double dx = temp->x - scirc->x;
393
+ double dy = temp->y - scirc->y;
394
+ double distance = sqrt(dx * dx + dy * dy);
395
- result = (dx * dx + dy * dy) <= (dr * dr);
396
+ result = distance + temp->r <= scirc->r;
397
398
else if (pgRect_Check(arg)) {
399
SDL_Rect *temp = &pgRect_AsRect(arg);
0 commit comments