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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for superellipse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c4f0fd171d33dd775d983fd15d0bdb3dc19595e8c53bb4fc298a95fec3a1174a
MD5 f83959d664421862c00c2888da2993ad
BLAKE2b-256 c7986a4880a217e227872ae2faf88748df70b0e9185be19df0148757652f7cde

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: superellipse-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd6f92359396a5b8b923b461d3ce82d02e60c70bfd739b73b6fff0395324afb9
MD5 ca130cd6237f525f41c4493b0035d7fd
BLAKE2b-256 1934b6754e760709dec29285702cd8e5ff2b390a9b7b5dc11046098c5c36ea6b

See more details on using hashes here.

Provenance

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