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.5.0.tar.gz (18.9 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.5.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file superellipse-0.5.0.tar.gz.

File metadata

  • Download URL: superellipse-0.5.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for superellipse-0.5.0.tar.gz
Algorithm Hash digest
SHA256 cb3892909b4d55ef2fa55388ead99cc0b21cb4e552dd78efe413de28e446f04c
MD5 09b52985d23d2bb08dc1f04a7a5954bb
BLAKE2b-256 f42b191268c1c832626f12318e14bc7338d0202ad5fffe8d2e48c2129eb46c1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for superellipse-0.5.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.5.0-py3-none-any.whl.

File metadata

  • Download URL: superellipse-0.5.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.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f020612600e9b57ea719a0bbab69a5fe15fd992861d4b643aeb5915e2bde5bc
MD5 6c018a24b9fa61a4cf690f81f5ff27da
BLAKE2b-256 d61635af7fc7e52af4c6a32882f320d6b6c6581e53695cc40283e8371c1109e5

See more details on using hashes here.

Provenance

The following attestation bundles were made for superellipse-0.5.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