Another typical mechanism for determining whether two objects are intersecting is by computing bounding circles of the objects. Then determining whether the objects overlap is simply testing if the bounding circles overlap. In this post-lab, you will demonstrate your knowledge of conditionals and test cases by writing a function to perform this computation.
Details
Create a function called are_circles_overlapping(circle_1_x,
circle_1_y, circle_1_radius, circle_2_x, circle_2_y,
circle_2_radius)
in a file called circle_overlap.py.
The function should return True
if the circle centered
at (circle_1_x, circle_1_y) with a radius
of circle_1_radius is overlapping with the circle centered
at (circle_2_x, circle_2_y) with a radius
of circle_2_radius. The function should
return False
otherwise. Consider two circle touching
to be not overlapping.
You can compute whether two circles are overlapping by determining if the center points of the circles are within the sum of the circle radii.
Test your function by calling the function multiple times with different parameters. Make sure you follow the course's code conventions.
Sample Test Cases
Function Parameters | Expected Output |
---|---|
0, 0, 2, 1, 1, 2 | True |
0, 0, 2, 4, 4, 2 | False |
2, 2, 2, 3, 3, 2 | True |
Submission
Submit your program as a .py file on the course Inquire page before class on Friday October 3rd.