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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tangential_knife_cnc_geometry-1.0.0.tar.gz.
File metadata
- Download URL: tangential_knife_cnc_geometry-1.0.0.tar.gz
- Upload date:
- Size: 71.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43576ff5e39008b55f66d351b1123d3464f0e7af32e4ffce66d23f22539261ff
|
|
| MD5 |
c9c9e59eedd38c8b4222890acdb0b5df
|
|
| BLAKE2b-256 |
afda6d175b7d0efd487f4c60b247a0b52c2d272f3a7f389cfea9859e2777ce2f
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tangential_knife_cnc_geometry-1.0.0.tar.gz -
Subject digest:
43576ff5e39008b55f66d351b1123d3464f0e7af32e4ffce66d23f22539261ff - Sigstore transparency entry: 2811658555
- Sigstore integration time:
-
Permalink:
Cabalist/tangential-knife-cnc-geometry@da1ae2e5aded67454a71a92f89098535a3997e69 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Cabalist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@da1ae2e5aded67454a71a92f89098535a3997e69 -
Trigger Event:
push
-
Statement type:
File details
Details for the file tangential_knife_cnc_geometry-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tangential_knife_cnc_geometry-1.0.0-py3-none-any.whl
- Upload date:
- Size: 43.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df2f241d4e982c8c206174ed7874a18e5d51836968540a898c07d4a165475e45
|
|
| MD5 |
206e875d6015da8b1140bdb51a61fbc0
|
|
| BLAKE2b-256 |
2d98324e0c2097d0f4a23f6007d4cb59f33bff3908dba74fa6077df6994154b8
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tangential_knife_cnc_geometry-1.0.0-py3-none-any.whl -
Subject digest:
df2f241d4e982c8c206174ed7874a18e5d51836968540a898c07d4a165475e45 - Sigstore transparency entry: 2811658558
- Sigstore integration time:
-
Permalink:
Cabalist/tangential-knife-cnc-geometry@da1ae2e5aded67454a71a92f89098535a3997e69 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/Cabalist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish_pypi.yml@da1ae2e5aded67454a71a92f89098535a3997e69 -
Trigger Event:
push
-
Statement type: