This project implements an algorithm to count the number of regions formed by intersecting circles on a 2D plane and determines whether each region is inside or outside each circle. The results are visualized using matplotlib, with plots saved in the .nosync directory.
-
Clone the Repository: git clone https://github.com/DDDOH/2D-Circle-Region-Identifier.git cd 2D-Circle-Region-Identifier
-
Create a Virtual Environment:
python -m venv venvActivate it:
- Windows:
venv\Scripts\activate - macOS/Linux:
source venv/bin/activate
-
Install Dependencies:
pip install -r requirements.txt -
Run the Script:
python main.py
- The script generates random circles (default: 20) and computes intersecting regions, saving plots to
.nosync/region_X.png. - Modify parameters in
main.py: n_circle: Number of circles (e.g., set to 3 for testing).PLOT_ARC = True: Visualize arcs for debugging.PLOT_POINT = True: Show intersection points.PLOT_REGION = True: Plot detected regions (default).- Example: Set
n_circle = 3and runpython main.pyto visualize regions for three circles.
The algorithm:
- Generates random circles with centers
(c_x, c_y)and radiir. - Computes intersection points between all circle pairs using
intersect_two_circle. - Identifies arcs (circle segments between intersections) and assigns them to regions.
- Traverses arcs to delineate regions, determining their inside/outside relationship with each circle.
- Visualizes results with
matplotlib, showing circles and filled regions.
- Fork the repository and clone it locally.
- Create a branch for your changes:
git checkout -b your-branch-name. - Make changes, test with
python main.py, and commit:git commit -m "Your change description". - Push to your fork:
git push origin your-branch-name. - Open a pull request to the main repository.
Suggestions for contributions:
- Add unit tests for
utils.pyfunctions. - Improve error handling for edge cases (e.g., non-intersecting circles).
- Enhance visualizations with labels or legends.
No license specified. Contact the repository owner for usage permissions.