Skip to main content

A small 2D geometry kernel for turning vector artwork into toolpaths for an oscillating tangential knife; the import name is geom2d. It provides the primitives a toolpath generator needs and nothing else:

  • P points and vectors, Line segments, circular Arc segments and CubicBezier curves, all immutable dataclasses with a validated geometry;

  • biarc approximation of Béziers into tangent-continuous arcs and lines (CubicBezier.biarc_approximation), with a documented output contract;

  • arc splitting to a maximum sweep, tangent directions and turn angles at joints, and path helpers (segment module) that work on any object satisfying the Segment protocol;

  • one tolerance, EPSILON, with clear rules for when a comparison is a distance, an angle, or a relative quantity.

SVG parsing, affine transforms and elliptical arcs are deliberately out of scope: an external parser applies transforms and converts arcs before this library sees the geometry, and hands it P-like points.

Requires Python 3.14. Pure standard library, no dependencies.

Install and use

uv add tangential-knife-cnc-geometry
from geom2d import P, Line, Arc, CubicBezier, path_is_closed, segments_are_g1

curve = CubicBezier.from_quadratic(P(0, 0), P(5, 10), P(10, 0))
segments = curve.biarc_approximation(0.01, max_arc_angle=3.1416 / 2)  # raises if 0.01 cannot be met
assert all(segments_are_g1(a, b) for a, b in zip(segments, segments[1:]))

Conventions

  • Angles are radians, counter-clockwise from +x. A positive cross product, winding or turn means counter-clockwise (left). Arc.angle is the signed sweep; positive is counter-clockwise. offset(+d) moves a segment to the left of its direction of travel.

  • EPSILON is an absolute distance at every magnitude; angle_eq compares directions a whole turn apart as equal. Coordinates should stay below about 1e7, and tangent directions resolve to EPSILON only for features larger than about 1e-8 times the coordinate magnitude.

  • EPSILON is a numerical floor, not a physical one: set it far below the process resolution, pass tolerances at the process resolution, and drop features below that floor yourself. Near EPSILON the library promises self-consistency (no crashes, nothing silently dropped, connected output), never physical meaning.

  • A job’s tolerance is passed explicitly, never set globally: path_is_closed(path, tolerance=), segments_are_g1(..., point_tolerance=, angle_tolerance=), P.almost_equal(other, tolerance), biarc_approximation(tolerance) and Arc.from_sweep(..., tolerance=) for arcs built from rounded coordinates.

  • == and hash on geometry are grid identity at EPSILON resolution (so objects work in sets and dicts); P.almost_equal tests geometric coincidence. set_epsilon is called once at startup, before any geometry is created.

  • Invalid geometric input raises GeometryError (a ValueError); a biarc approximation that cannot meet its tolerance raises ApproximationError unless strict=False; degenerate input has documented return values instead of arithmetic errors; nothing depends on assert.

Development

uv sync --group dev
uv run prek install              # once: run the checks on every commit
uv run prek run --all-files      # ruff check, ruff format, ty, pyrefly (prek.toml; CI runs the same)
uv run pytest
uv run python -O -m pytest
uv run --group docs sphinx-build -W docs docs/_build/html
  • Python 3.14 is pinned by requires-python, the checkers’ settings and CI; there is deliberately no .python-version file, because one shadows the uv shim on machines that use pyenv.

  • License: LGPL v3. The library descends from Claude Zervas’s utl-geom2d and keeps its license; the 1.0 rebuild is documented in CHANGELOG.rst.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tangential_knife_cnc_geometry-1.0.0.tar.gz (71.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tangential_knife_cnc_geometry-1.0.0-py3-none-any.whl (43.7 kB view details)

Uploaded Python 3

File details

Details for the file tangential_knife_cnc_geometry-1.0.0.tar.gz.

File metadata

File hashes

Hashes for tangential_knife_cnc_geometry-1.0.0.tar.gz
Algorithm Hash digest
SHA256 43576ff5e39008b55f66d351b1123d3464f0e7af32e4ffce66d23f22539261ff
MD5 c9c9e59eedd38c8b4222890acdb0b5df
BLAKE2b-256 afda6d175b7d0efd487f4c60b247a0b52c2d272f3a7f389cfea9859e2777ce2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tangential_knife_cnc_geometry-1.0.0.tar.gz:

Publisher: publish_pypi.yml on Cabalist/tangential-knife-cnc-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tangential_knife_cnc_geometry-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tangential_knife_cnc_geometry-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 df2f241d4e982c8c206174ed7874a18e5d51836968540a898c07d4a165475e45
MD5 206e875d6015da8b1140bdb51a61fbc0
BLAKE2b-256 2d98324e0c2097d0f4a23f6007d4cb59f33bff3908dba74fa6077df6994154b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for tangential_knife_cnc_geometry-1.0.0-py3-none-any.whl:

Publisher: publish_pypi.yml on Cabalist/tangential-knife-cnc-geometry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page