Generalized superellipse (Lamé curve) geometry: discretization, curvature, arc-length, and export
Project description
superellipse
Generalized superellipse (Lamé curve) geometry for Python.
Overview
A superellipse (or Lamé curve) is defined by:
$$|x/a|^p + |y/b|^q = 1$$
This package provides tools for working with these curves:
- Geometry: Points, tangents, normals, curvature
- Discretization: Uniform, arc-length, or adaptive panel-based sampling
- Signed distance: Fast SDF evaluation for level-set methods
- Export: SVG paths, JSON, NumPy arrays
- Special cases: Squircle (p=q=4), rounded rectangles, stadium curves
Installation
pip install superellipse
# With plotting support
pip install superellipse[plot]
# With SVG export
pip install superellipse[export]
# Everything
pip install superellipse[all]
Quick Start
from superellipse import Superellipse
# Create a squircle (p=4, like iOS icons)
curve = Superellipse(a=1.0, b=1.0, p=4)
# Sample 100 points
points = curve.sample(n=100)
# Get curvature at each point
kappa = curve.curvature(points)
# Export to SVG path
path_data = curve.to_svg_path(n=100)
CLI
# Plot a superellipse
superellipse plot --a 1 --b 0.8 --p 4 --output squircle.png
# Export to SVG
superellipse export --a 1 --b 1 --p 6 --format svg --output curve.svg
# Compute arc length
superellipse info --a 1 --b 1 --p 4
Use Cases
- UI/UX Design: Squircles for app icons (iOS-style rounded rectangles)
- CAD/CAM: Smooth corner profiles for machining
- Graphics: Procedural shape generation
- Scientific Computing: Boundary geometry for PDEs
- Typography: Letterform design with smooth corners
API Reference
Superellipse(a, b, p, q=None)
Create a superellipse with semi-axes a, b and exponents p, q.
If q is None, uses q=p (symmetric exponent).
Methods
| Method | Description |
|---|---|
sample(n, method='uniform') |
Sample n points on the curve |
curvature(points) |
Signed curvature at given points |
normal(points) |
Outward unit normals |
tangent(points) |
Unit tangent vectors |
arc_length(t0=0, t1=2π) |
Arc length between parameter values |
signed_distance(points) |
Signed distance from points to curve |
to_svg_path(n=100) |
Export as SVG path data string |
to_json() |
Export curve parameters as JSON |
Sampling Methods
'uniform': Uniform in parameter t ∈ [0, 2π]'arclength': Uniform in arc length'adaptive': Refine near high-curvature regions'panels': Panel-based with Gauss-Legendre nodes (for BIE)
License
MIT License. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
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 superellipse-0.8.0.tar.gz.
File metadata
- Download URL: superellipse-0.8.0.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e372e1ec65044dfb59f37d29750588fecdc407b9184c3fb0be78099f6b1a843
|
|
| MD5 |
daa0362c596224ec3987b88f0d86ec94
|
|
| BLAKE2b-256 |
2b31c5dee428f9e19028fe6855d0994875b29a3429023a876036e2dbfbb2f695
|
Provenance
The following attestation bundles were made for superellipse-0.8.0.tar.gz:
Publisher:
release.yml on egoughnour/superellipse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superellipse-0.8.0.tar.gz -
Subject digest:
0e372e1ec65044dfb59f37d29750588fecdc407b9184c3fb0be78099f6b1a843 - Sigstore transparency entry: 858008872
- Sigstore integration time:
-
Permalink:
egoughnour/superellipse@d6ec8ceffde5b17c4a31694ffa51dc5d25925e60 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/egoughnour
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d6ec8ceffde5b17c4a31694ffa51dc5d25925e60 -
Trigger Event:
push
-
Statement type:
File details
Details for the file superellipse-0.8.0-py3-none-any.whl.
File metadata
- Download URL: superellipse-0.8.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dd0d3d6353dd64b54ca4928548056130bed0f59e2524a8a862a2df465c0a362
|
|
| MD5 |
c3875a963f26884929ac35dc2a6091cb
|
|
| BLAKE2b-256 |
e61fb17dedba06532819981195aaf4938546f3a2ae867ca7ac8098cbf6fadf1b
|
Provenance
The following attestation bundles were made for superellipse-0.8.0-py3-none-any.whl:
Publisher:
release.yml on egoughnour/superellipse
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
superellipse-0.8.0-py3-none-any.whl -
Subject digest:
9dd0d3d6353dd64b54ca4928548056130bed0f59e2524a8a862a2df465c0a362 - Sigstore transparency entry: 858008949
- Sigstore integration time:
-
Permalink:
egoughnour/superellipse@d6ec8ceffde5b17c4a31694ffa51dc5d25925e60 -
Branch / Tag:
refs/tags/v0.8.0 - Owner: https://github.com/egoughnour
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@d6ec8ceffde5b17c4a31694ffa51dc5d25925e60 -
Trigger Event:
push
-
Statement type: