Intersection of polygon and circle

Computes the area and shape of the intersection of a polygon with a circle
5 Downloads
Updated 22 Mar 2023

View License

For a circle of radius R, and a polygon with nV vertices defined in the 2 X nV matrix P, the following code will compute the area of the intersection in A, as well as its shape in pointList and isArc:
[A, pointList, isArc] = polygonCircleIntersection(R, P)
pointList is the list of points in the new shape, and isArc is an array of logicals where isArc(i) is true if if the segment between pointList(i-1) and pointList(i) is an arc, and is false if it is a line segment.
The following function contains examples, which you can go through one by one by running
testPolygonCircleIntersection
and pressing ENTER to go to the next example. This function will also draw the shapes of the intersections.
If you find any issues, please let me know.
Known issues:
  • If the intersection produces a disjoint shape, this code will fail. If the shape P is not convex, this is a possibility, in which case you should triangulate it, using, for example, the function triangulation, and provide the resulting triangles separately

Cite As

Simão Pedro da Graça Oliveira Marto (2024). Intersection of polygon and circle (https://www.mathworks.com/matlabcentral/fileexchange/126645-intersection-of-polygon-and-circle), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2023a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.1

added image, updated description

1.0.0