File size: 6,205 Bytes
252429d
 
112e757
252429d
 
f00b2e2
252429d
 
 
 
d7d27f0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
---
title: Ideal Polyhedron Volume Toolkit
emoji: πŸ”Ί
colorFrom: blue
colorTo: purple
sdk: docker
pinned: false
license: mit
---

# Ideal Polyhedra Volume Toolkit

A Python toolkit for computing and optimizing volumes of ideal hyperbolic polyhedra using Delaunay triangulation, hull projection, and fast/exact Lobachevsky functions.

## Installation

Install the package in development mode:

```bash
pip install -e .
```

Dependencies: `numpy`, `scipy`, `mpmath`, `torch`

## Project Structure

```
ideal_poly_volume_toolkit/
β”œβ”€β”€ ideal_poly_volume_toolkit/   # Core package
β”‚   β”œβ”€β”€ geometry.py              # Core geometry and volume computation functions
β”‚   β”œβ”€β”€ visualization.py         # 3D visualization utilities
β”‚   β”œβ”€β”€ rivin_holonomy.py        # Penner-Rivin holonomy computation
β”‚   β”œβ”€β”€ pointset_to_fuchsian.py  # Full Fuchsian group pipeline
β”‚   └── __init__.py
β”‚
β”œβ”€β”€ bin/                         # Command-line tools and GUI
β”‚   β”œβ”€β”€ gui.py                   # 🎨 Interactive Gradio web interface
β”‚   β”œβ”€β”€ optimize_polyhedron.py  # General optimization wrapper
β”‚   β”œβ”€β”€ analyze_distribution.py # Distribution analysis wrapper
β”‚   └── README.md
β”‚
β”œβ”€β”€ examples/                    # Organized example scripts
β”‚   β”œβ”€β”€ distributions/          # Distribution analysis examples
β”‚   β”‚   β”œβ”€β”€ tetrahedron/       # Tetrahedron volume distributions
β”‚   β”‚   β”œβ”€β”€ five_vertex/       # 5-vertex polyhedra distributions
β”‚   β”‚   β”œβ”€β”€ six_vertex/        # 6-vertex polyhedra distributions
β”‚   β”‚   └── euclidean/         # Euclidean tetrahedra analysis
β”‚   β”œβ”€β”€ optimization/           # Optimization examples by vertex count
β”‚   β”‚   β”œβ”€β”€ 7vertex/           # 7-vertex optimization (octahedron variants)
β”‚   β”‚   β”œβ”€β”€ 12vertex/          # 12-vertex optimization
β”‚   β”‚   β”œβ”€β”€ 20vertex/          # 20-vertex optimization (icosahedron)
β”‚   β”‚   └── platonic/          # Platonic solid analysis
β”‚   β”œβ”€β”€ visualization/          # Visualization scripts
β”‚   └── analysis/               # Statistical and theoretical analysis
β”‚
β”œβ”€β”€ scripts/                     # Active research/development scripts
β”œβ”€β”€ results/                     # Output files
β”‚   β”œβ”€β”€ data/                   # JSON configuration files
β”‚   β”œβ”€β”€ plots/                  # PNG visualization outputs
β”‚   └── logs/                   # Optimization logs
└── docs/                        # Documentation
    β”œβ”€β”€ RESULTS_SUMMARY.md
    └── PLATONIC_MAXIMALITY_RESULTS.md
```

## Core Functionality

### `ideal_poly_volume_toolkit.geometry` - Volume Computation

- **Stereographic projection**: `lift_to_sphere_with_inf()`, `inverse_stereographic_from_sphere_pts()`
- **Triangulation**: `delaunay_triangulation_indices()`, `hull_tris_projected_back()`
- **Lobachevsky function**: `lob_fast()` (PyTorch autodiff), `lob_exact()` (mpmath high-precision)
- **Volume computation**:
  - `triangle_volume_from_points()` - Single triangle volume
  - `ideal_poly_volume_via_delaunay()` - Full polyhedron via Delaunay
  - `ideal_poly_volume_via_hull_project_back()` - Full polyhedron via convex hull

### `ideal_poly_volume_toolkit.rivin_holonomy` - Penner-Rivin Algorithm

- **Holonomy computation**: `generators_from_triangulation()` - Compute Fuchsian group generators
- **Arithmeticity testing**: Check if polyhedra have arithmetic holonomy (traces in number fields)
- **Triangulation structures**: `Triangulation` class for managing ideal triangulations

### `ideal_poly_volume_toolkit.pointset_to_fuchsian` - Full Pipeline

- **Group computation**: `group_from_pointset()` - Convert point sets to Fuchsian groups
- **Trace field analysis**: `invariant_trace_field_signature()` - Analyze arithmetic properties
- **Visualization**: `render_snapshot()` - High-quality rendering with iridescence and transparency
- **Mesh export**: `hull_to_mesh()`, `export_mesh_obj()` - Export to OBJ format

## Quick Start

### 🎨 Interactive GUI (Easiest)

The fastest way to get started is with the Gradio web interface:

```bash
python bin/gui.py
```

Then open your browser to `http://127.0.0.1:7860`

**Features:**
- Interactive optimization with real-time progress
- Distribution analysis with automatic plotting
- 3D visualization in sphere and PoincarΓ© ball models
- No need to remember command-line arguments!

### Command-Line Tools

For scripting and batch processing, use the wrapper scripts in `bin/`:

```bash
# Optimize a 7-vertex polyhedron (10 trials)
python bin/optimize_polyhedron.py --vertices 7 --trials 10

# Analyze volume distribution for tetrahedra
python bin/analyze_distribution.py --vertices 4 --samples 10000

# Get help on any tool
python bin/optimize_polyhedron.py --help
```

See `bin/README.md` for detailed usage and examples.

### Computing a volume (Python API)

```python
import numpy as np
from ideal_poly_volume_toolkit.geometry import ideal_poly_volume_via_delaunay

# Define vertices in the complex plane (stereographic projection)
vertices = np.array([0.0+0.0j, 1.0+0.0j, 0.5+0.866j])
volume = ideal_poly_volume_via_delaunay(vertices)
print(f"Volume: {volume}")
```

### Running examples

Examples are organized by topic. For instance:

```bash
# 7-vertex optimization
cd examples/optimization/7vertex
python optimize_7vertex.py

# Tetrahedron distribution analysis
cd examples/distributions/tetrahedron
python tetrahedron_volume_distribution.py

# Visualization
cd examples/visualization
python visualize_golden_config.py
```

## Key Examples

- **7-vertex optimization**: Testing the hypothesis that the maximum volume is an octahedron with one stellated face
- **20-vertex optimization**: Finding maximal volume configurations for icosahedron-like polyhedra
- **Distribution analysis**: Statistical analysis of volume distributions for various polyhedra
- **Platonic solids**: Analysis of regular polyhedra and their perturbations

## Research Results

See `docs/RESULTS_SUMMARY.md` and `docs/PLATONIC_MAXIMALITY_RESULTS.md` for detailed findings.

## License

See LICENSE file.