Skip to main content

Generalized superellipse (Lamé curve) geometry: discretization, curvature, arc-length, and export

Project description

superellipse

Generalized superellipse (Lamé curve) geometry for Python.

PyPI version Python versions License CI Documentation codecov

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


Download files

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

Source Distribution

superellipse-0.8.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

superellipse-0.8.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

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

Hashes for superellipse-0.8.0.tar.gz
Algorithm Hash digest
SHA256 0e372e1ec65044dfb59f37d29750588fecdc407b9184c3fb0be78099f6b1a843
MD5 daa0362c596224ec3987b88f0d86ec94
BLAKE2b-256 2b31c5dee428f9e19028fe6855d0994875b29a3429023a876036e2dbfbb2f695

See more details on using hashes here.

Provenance

The following attestation bundles were made for superellipse-0.8.0.tar.gz:

Publisher: release.yml on egoughnour/superellipse

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

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

Hashes for superellipse-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9dd0d3d6353dd64b54ca4928548056130bed0f59e2524a8a862a2df465c0a362
MD5 c3875a963f26884929ac35dc2a6091cb
BLAKE2b-256 e61fb17dedba06532819981195aaf4938546f3a2ae867ca7ac8098cbf6fadf1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for superellipse-0.8.0-py3-none-any.whl:

Publisher: release.yml on egoughnour/superellipse

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page