Skip to content

aarizat/circpacker

Repository files navigation

circpacker : Circle Packer

made-with-python docs License orcid

CircPacker is an application software in Python 3 to create circle packing in closed polygons.

plot example1

Features

Requirements

circpacker now targets Python 3.12+ and uses uv for environment and dependency management.

Installation and development

Clone the repository and sync dependencies:

uv sync

Run tests:

uv run pytest -q

Run format and lint checks:

uv run ruff format --check .
uv run ruff check .

Run static type checks:

uv run mypy

Run Python examples/scripts:

uv run python -c "import circpacker; print(circpacker.__version__)"

Examples

To produce the plot shown above execute the following script

from numpy import array
from circpacker.basegeom import Polygon
from circpacker.packer import CircPacking as cp
coordinates = array([[1, 1], [2, 5], [4.5, 6], [8, 3], [7, 1],
                     [4, 0]])
polygon = Polygon(coordinates)
boundCoords = polygon.boundCoords
CircPack = cp(boundCoords, depth=10)
CircPack.plot(plotTriMesh=True)

Now, let's see an example for a autosimilar bimsoil model.

from numpy import array
import matplotlib.pyplot as plt
from circpacker.basegeom import Polygon
from circpacker.packer import CircPacking as cp
from circpacker.slopegeometry import AnthropicSlope

h = 15 # slope height
slopeGeometry = AnthropicSlope(h, [1, 1.5], 2/3*h, 2/3*h, 1/3*h)
boundCoords = slopeGeometry.boundCoords
polygon = Polygon(boundCoords)
CircPack = cp(boundCoords, minAngle=20, maxArea=0.35*polygon.area, length=0.05*h)
CircPack.plot(plotTriMesh=True)

For a simple slope with h=15 m, inclination H:V of 1:1.5, crown and foot lengths of 2/3h, and depth 1/3h. Minimum angle and maximum area for each Delaunay triangle of 20° and 35% of slope area, respectively.

plot example2

More information

Here is a list of papers based on circpacker.

About

Application software in Python 3 to create circle packing in closed polygons.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors