Skip to content

Commit

Permalink
better docs, added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
itzpr3d4t0r committed Jul 13, 2024
1 parent 957c887 commit bbf0a53
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
14 changes: 7 additions & 7 deletions docs/circle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
2 changes: 2 additions & 0 deletions docs/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion test/test_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit bbf0a53

Please sign in to comment.