# Python – Sympy Polygon.intersection() Method

In Sympy, the function Polygon.intersection() is used to get the intersection of a given polygon and the given geometry entity. The geometry entity can be a point, line, polygon, or other geometric figures. The intersection may be empty if the polygon and the given geometry entity are not intersected anywhere. But can contain individual Points or complete Line Segments if intersection exists.

```Syntax: Polygon.intersection(o)

Parameters: Geometry Entity

Returns: The list of Segments or Points of intersection.
```

Example #1:

## Python3

 `# import Point, Polygon ` `from` `sympy ``import` `Point, Polygon ` ` `  `# creating points using Point() ` `p1, p2, p3, p4 ``=` `map``(Point, [(``0``, ``0``), (``1``, ``0``), (``5``, ``1``), (``0``, ``1``)]) ` `p5, p6, p7 ``=` `map``(Point, [(``3``, ``2``), (``1``, ``-``1``), (``0``, ``2``)]) ` ` `  `# creating polygons using Polygon() ` `poly1 ``=` `Polygon(p1, p2, p3, p4) ` `poly2 ``=` `Polygon(p5, p6, p7) ` ` `  `# using intersection() ` `isIntersection ``=` `poly1.intersection(poly2) ` ` `  `print``(isIntersection)`

Output:

`[Point2D(1/3, 1), Point2D(2/3, 0), Point2D(9/5, 1/5), Point2D(7/3, 1)]`

Example #2:

## Python3

 `# import Point, Polygon ` `from` `sympy ``import` `Point, Polygon ` ` `  `# creating points using Point() ` `p1, p2, p3, p4 ``=` `map``(Point, [(``0``, ``0``), (``1``, ``0``), (``5``, ``1``), (``0``, ``1``)]) ` ` `  `# creating polygon using Polygon() ` `poly1 ``=` `Polygon(p1, p2, p3, p4) ` ` `  `# using intersection() ` `isIntersection ``=` `poly1.intersection(Line(p1, Point(``3``, ``2``))) ` `                                     `  `print``(isIntersection)`

Output:

`[Point2D(0, 0), Point2D(3/2, 1)]`

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.