• Stars
    star
    4,181
  • Rank 10,360 (Top 0.3 %)
  • Language
    Python
  • License
    MIT License
  • Created about 8 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A tour in the wonderland of math with python.

A Tour in the Wonderland of Math with Python

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

About this repo

The purpose of this project is to show the beauty of math with python by rendering high quality images, videos and animations. It consists of several independent projects with each one illustrates a special object/algorithm in math. The current list contains:

  • Aperiodic tilings like Penrose tiling, Ammann-Beenker tiling, etc.
  • Triology on perfectly random sampling algorithms.
    1. Domino shuffling algorithm on Aztec diamonds.
    2. Wilson's uniform spanning tree algorithm on 2d grids.
    3. Coupling from the past algorithm on lozenge tilings.
  • Hopf fibration.
  • 3D and 4D Uniform polytopes.
  • 2D uniform tilings and 3D uniform honeycombs in Euclidean, spherical and hyperbolic spaces.
  • Make gif animations of various algorithms.
  • Lots of shader animations.
  • Miscellaneous scripts like E8 root system, Mandelbrot set, Newton's fractal, Lorenz attractor, etc.

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).

Gallery

The code for some of the images are not in the master branch, they can be found in the released version.

  • Uniform 3D and 4D polytopes

  • Mรถbius transformations

  • 3D Euclidean uniform honeycombs and their duals

  • Gray-Scott simulation

  • 3D hyperbolic uniform honeycombs

  • Limit set of rank 4 Coxeter groups

  • Aperiodic tilings

  • 3D Fractals

  • Coxeter automata and 2D Uniform tilings

  • GIF animations of various algorithms

  • Others

Many more to be comtinued ...

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.

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.

Thanks

I have learned a lot from the following people:

License

see the LICENSE file.