MCPcopy
hub / github.com/neozhaoliang/pywonderland

github.com/neozhaoliang/pywonderland @0.1.0 sqlite

repository ↗ · DeepWiki ↗ · release 0.1.0 ↗
533 symbols 1,548 edges 64 files 278 documented · 52%
README

A Tour in the Wonderland of Math with Python

A collection of python scripts for drawing beautiful figures and animating interesting algorithms in mathematics.

Build Status

UPDATE: This repo is currently under a huge reconstruction, more fancy and advanced features will be added, some dirty code will be removed. Also I will make more shadertoy live demos to help people understand the math. So you can look forward a more fantastic version :smile:.​

Known issues:

  1. The code for drawing E8 root system is not mathematically correct (though the result image looks right), I didn't take the bilinear form into account. Same reason for drawing polytope on its Coxeter plane in polytopes project.

About this repo

The purpose of this project is to show the beauty of math with python. It consists of several independent subprojects with each one illustrates a special object/algorithm in math. The current list is:

These topics are chosen largely due to my personal taste:

  1. They must produce appealing results.
  2. There must be some non-trivial math behind them.
  3. The code should be as simple as possible.

I'll use only popular python libs and build all math stuff by hand (tools like sage, sympy, mathemetica will not be used here). Also I will only maintain the code for python >= 3.6.

Note: Python3.5 is deprecated now because it's a bit tricky to install the latest numba on Ubuntu16.04 for python3.5 (if you are using anaconda for package management then you need not worry about this because anaconda will fix it for you). Note numba is only used in a few fractal scripts in the misc directory and all other projects should also work for python>=2.7.

How to use

All projects here are implemented in a ready-to-use manner for new comers. You can simply run the examples without tweaking any parameters once you have the dependencies installed correctly. Each subdirectory in src/ is a single program (except that glslhelpers is a helper module for running glsl programs and misc is a collection of independent scripts), any file named main.py, run_*.py, example_*.py is an executable script that gives some output.

List of algorithms

Here is a list of some algorithms implemented in this project:

Dependencies

The recommended way to install all dependencies is simply running the bash script install_dependencies.sh.

sudo bash install_dependencies.sh

Or you can install the python libs by pip:

pip install -r requirements.txt

Open source softwares required:

  • python3-tk (for file dialog)
  • ImageMagick (for making gif animations)
  • FFmpeg (for saving animations to video files)
  • POV-Ray (for generating high quality raytracing results)
  • graphviz (for drawing automata of Coxeter groups)
  • Inkscape (optional, for convering large svg files to png)

They can all be installed via command-line:

sudo apt-get install python3-tk imagemagick ffmpeg povray graphviz inkscape

Note pygraphviz also requires libgraphviz-dev:

sudo apt-get install libgraphviz-dev

In the scripts these softwares are called in command line as povray, ffmpeg, convert (from ImageMagick), etc. For Windows users you should add the directories contain these .exe files to the system Path environment variables to let the system know what executables these commands refer to. For example on Windows the default location of POV-Ray's exe file is C:\Program Files\POV-Ray\v3.7\bin\pvengine64.exe, so you should add C:\Program Files\POV-Ray\v3.7\bin to system Path and rename pvengine64.exe to povray.exe, then you can run the scripts without any changes and everything works fine.

TODO

I have a long list of projects to do in mind and they may take a few years to accomplish:

  • Knots, inspired by knotilus but I hope I could do better than that.

  • Minimal surfaces. Implement two ways to construct minimal surfaces: either by solving Plateau's problem or use a pair of analytic functions. Render the result in POV-Ray.

  • Uniform tilings: Replace the hyperbolic module currently used in uniform-tilings project by a custom one (since I want to include LaTeX expressions in the images), with upper half space model added. Also find an efficient way to render the upper half space boundary images in python. Inspired by Roice's artwork.

  • Shader animations of polyhedral, euclidean, hyperbolic tilings with gears.

  • Escher circle limits in svg format.

  • Knots and dynamic systems.

Thanks

I have learned a lot from the following people:

License

see the LICENSE file.

Core symbols most depended-on inside this repo

uniformf
called by 64
src/glslhelpers/shader.py
anim
called by 52
src/polytopes/example_polytope_animation.py
write
called by 31
src/gifmaze/gifmaze/gifmaze.py
uniformi
called by 27
src/glslhelpers/shader.py
draw
called by 27
src/uniform-tilings/coxeter/automata.py
mark_cell
called by 25
src/gifmaze/gifmaze/gifmaze.py
save
called by 21
src/gifmaze/gifmaze/gifmaze.py
move
called by 19
src/polytopes/polytopes/models.py

Shape

Method 320
Function 171
Class 42

Languages

Python98%
TypeScript2%

Modules by API surface

src/uniform-tilings/tiling.py42 symbols
src/gifmaze/gifmaze/gifmaze.py38 symbols
src/polytopes/polytopes/models.py34 symbols
src/grayscott/main.py24 symbols
src/uniform-tilings/honeycomb.py23 symbols
src/uniform-tilings/coxeter/coxeter.py23 symbols
src/uniform-tilings/coxeter/polynomial.py18 symbols
src/uniform-tilings/coxeter/automata.py18 symbols
src/polytopes/polytopes/todd_coxeter.py18 symbols
src/uniform-tilings/helpers.py16 symbols
src/polytopes/example_wythoff_shader_animation.py13 symbols
src/gifmaze/js/wilson.js13 symbols

Dependencies from manifests, versioned

hyperbolic1.2.0 · 1×

For agents

$ claude mcp add pywonderland \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact