Skip to main content

This package uses the quickhull algorithm to find the convex hull of a point set, but with the added option of restricting the set of halfplanes we intersect over to only those with normals lying in a given convex cone.

Reason this release was yanked:

Missing dependincies

Project description

2D Conehull

This package uses the quickhull algorithm to find the convex hull of a point set, but with the added option of restricting the set of halfplanes we intersect over to only those with normals lying in a given convex cone.

Features

  • Cone-Constrained Hull: The cone feature computes the intersection of halfplanes whose outward normals lie between two specified direction vectors. This creates a larger (unbounded) region that contains the original convex hull.
  • Visualizations: View a step-by-step visualization of the algorithm.
  • Samplers: For convenience we include simple ways of creating point sets, by inputting either an implicit (in)equality or a parametrization.

Basic Usage

import numpy as np

# Make conehull accessible
import sys
import os
sys.path.append(os.path.dirname(os.getcwd()))

from conehull import conehull
from conehull.view import plot_hull

points = np.array([
    [ 3.0, -4.0],
    [-1.0,  0.0],
    [ 3.0,  5.0],
    [ 4.5,  1.0],
    [-6.0, -2.0],
    [ 0.0,  4.0],
    [ 5.0,  2.0],
    [-2.0, -5.0],
    [ 1.0,  2.0],
    [ 2.0,  6.0],
    [-5.5,  1.5],
    [ 6.0, -1.0],
    [-3.0,  7.0],
    [ 3.0,  0.0],
    [ 2.0, -2.5],
    [ 4.0,  0.0],
    [-7.0,  3.0],
    [-4.0, -0.5],
])
cone = np.array([[1, 0], [0, 1]])

cone_hull = conehull(points, cone=cone)

# plot_hull is just a convenience wrapper around pyplot
plot_hull(cone_hull, points, cone=cone, show_convex_hull=True, 
                title="Cone hull with standard convex hull comparison")

Visualization Modes

# Import visualization functions
from conehull.view import (
    conehull_animated,
    conehull_step_by_step, 
    conehull_jupyter,
    plot_hull
)

# 1. Animated visualization - auto-playing GIF/video
# Creates a smooth animation showing algorithm steps
conehull_animated(points, cone=cone, save_path="animation.gif", interval=800)

# 2. Step-by-step interactive viewer - returns navigation functions
# Best for understanding algorithm mechanics step by step
hull, frames, show_frame = conehull_step_by_step(points, cone=cone)

# Use the returned show_frame function to navigate:
show_frame(0)    # Show first step
show_frame(5)    # Jump to step 5
show_frame(-1)   # Show final result

# 3. Jupyter widget - interactive controls in notebooks
# Returns a widget object with navigation buttons and sliders
if 'ipywidgets' in globals():  # Only works in Jupyter
    viewer = conehull_jupyter(points, cone=cone)
    viewer.show()  # Display the interactive widget

# 4. Static hull plot - simple visualization with comparison option
plot_hull(hull=cone_hull, points=points, cone=cone, 
          show_convex_hull=True, save_path="comparison.png")

Configurable Bounding Box

Since the hull is unbounded for any nontrivial cone, we use a bounding box. The cone_bounds parameter controls how the unbounded cone hull is clipped:

# Default: margin = 2.0 times data range
cone_hull = conehull(points, cone=cone)

# Custom margin multiplier
cone_hull = conehull(points, cone=cone, cone_bounds=5.0)

# Explicit bounds: [x_min, x_max, y_min, y_max]
cone_hull = conehull(points, cone=cone, cone_bounds=[-10, 10, -10, 10])

# Alternative format: [[x_min, y_min], [x_max, y_max]]
cone_hull = conehull(points, cone=cone, cone_bounds=[[-10, -10], [10, 10]])

Files

  • _geometry.py - Basic geometric operations like point-to-line distances and determining which side of a line points are on. Also handles sorting hull points in counterclockwise order.
  • _conehull.py - Implements the QuickHull algorithm for both standard and cone-constrained convex hulls. Contains the main conehull() function and recursive hull construction logic.
  • _cone_intersection.py - Transforms standard convex hulls into cone hulls by filtering halfplanes based on cone constraints. Computes intersections within configurable bounding boxes.
  • view.py - Visualization tools including step-by-step animations, interactive Jupyter widgets, and static plotting. Supports both automated playback and manual navigation of algorithm steps.
  • sampler.py - Generates test point datasets from mathematical functions. Supports parametric curves, implicit equations, and region sampling for creating diverse test cases.

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

conehull-1.0.0.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

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

conehull-1.0.0-py3-none-any.whl (32.2 kB view details)

Uploaded Python 3

File details

Details for the file conehull-1.0.0.tar.gz.

File metadata

  • Download URL: conehull-1.0.0.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for conehull-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a17e3b7412e058fc0acbde7127ce06b2ffb762bcddcbca72b05f7cf9900246e9
MD5 4d4fba387298b45ee92507b168128988
BLAKE2b-256 e65f52167ce47e481740f4b91f74113dd04a21f2c15d71844064ba2191f9a50e

See more details on using hashes here.

File details

Details for the file conehull-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: conehull-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 32.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for conehull-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b0bf0fb6636a37795a8c8ff3afb00138a6a02b029d9c472f6f0bc67c0f895f31
MD5 b459d04fccd87574a1b6145033f85795
BLAKE2b-256 bcf197d1da091b47c9c59a1cdc3175f28d9b6b4a4ba40f2cc730294fd3501735

See more details on using hashes here.

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