From bbf0a53c4f0c6b3d255236faeaea7039ce17bdfa Mon Sep 17 00:00:00 2001 From: itzpr3d4t0r <103119829+itzpr3d4t0r@users.noreply.github.com> Date: Sat, 13 Jul 2024 12:16:40 +0200 Subject: [PATCH] better docs, added a test --- docs/circle.rst | 14 +++++++------- docs/geometry.rst | 2 ++ test/test_circle.py | 6 +++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/circle.rst b/docs/circle.rst index 984d95c7..777dc47d 100644 --- a/docs/circle.rst +++ b/docs/circle.rst @@ -408,16 +408,16 @@ Circle Methods .. method:: intersect - | :sl:`returns the intersection points of the circle with another shape` - | :sg:`intersect(Circle) -> intersection_points` + | :sl:`finds intersections between the circle and another shape` + | :sg:`intersect(Circle) -> list[Point]` Calculates and returns a list of intersection points between the circle and another shape. - The other shape can either be a `Circle` object. - If the two objects do not intersect, an empty list is returned. + The other shape must be a `Circle` object. + If the circle does not intersect or has infinite intersections, an empty list is returned. .. note:: - The shape argument must be an actual shape object (Circle). - You can't pass a tuple or list of coordinates representing the shape, - because the shape type can't be determined from the coordinates alone. + The shape argument must be an instance of the `Circle` class. + Passing a tuple or list of coordinates representing the shape is not supported, + as the type of shape cannot be determined from coordinates alone. .. ## Circle.intersect ## \ No newline at end of file diff --git a/docs/geometry.rst b/docs/geometry.rst index 4f061284..75679eb0 100644 --- a/docs/geometry.rst +++ b/docs/geometry.rst @@ -70,6 +70,8 @@ performing transformations and checking for collisions with other objects. as_rect: Returns the smallest rectangle that contains the circle. + intersect: Finds intersections between the circle and another shape. + Additionally to these, the circle shape can also be used as a collider for the ``geometry.raycast`` function. Line diff --git a/test/test_circle.py b/test/test_circle.py index 417c9cc6..59a99886 100644 --- a/test/test_circle.py +++ b/test/test_circle.py @@ -1506,6 +1506,9 @@ def test_intersect_return_type(self): objects = [ Circle(10, 10, 4), + Circle(10, 10, 400), + Circle(10, 10, 1), + Circle(15, 10, 10), ] for object in objects: @@ -1517,10 +1520,11 @@ def test_intersect(self): c = Circle(10, 10, 4) c2 = Circle(10, 10, 2) c3 = Circle(100, 100, 1) + c3_1 = Circle(10, 10, 400) c4 = Circle(16, 10, 7) c5 = Circle(18, 10, 4) - for circle in [c, c2, c3]: + for circle in [c, c2, c3, c3_1]: self.assertEqual(c.intersect(circle), []) # intersecting circle