Code Monkey home page Code Monkey logo

pywonderland's Introduction

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

What's fun here

  • Todd-Coxeter algorithm and uniform polytopes

    Use Todd-Coxeter algorithm to compute the data of a polytope, and render it in POV-Ray.

    [Book] | [Doc]

  • Möbius transformations

    • When a Möbius transformation is an isometry of the hyperbolic disk, it must be of elliptic/parabolic/hyperbolic type, and it's elliptic/parabolic/hyperbolic if and only if it's a composition of reflections about two intersecting/parallel/hyper-parallel mirrors.

    • A Möbius transformation can be uniquely extended to an isometry of the hyperbolic upper-half space.

  • Coxeter automata and 2D Uniform tilings

    [Casselman's Paper] | [Doc]

  • GIF animations of maze and cellular automata

    Generate maze animations containing thousands of frames in a few seconds. No external libs used and no drawing api call!

    [Doc]

  • Domino shuffling algorithm

    This algorithm samples a perfectly random tiling of a aztec diamond.

    [Mathologer Video] | [Paper]

  • Propp and Wilson's coupling from the past algorithm

    [Book]

  • Catacaustics of plane curves

    Use sympy to compute catacaustics of parametric and implicit curves.

    [Doc]

    Cardioid as a catacaustic of circle Nephroid as a catacaustic of cardioid
  • Coxeter element and Coxeter plane

    We explain how to project the E8 root system to its Coxeter plane.

    [Casselman's Paper] | [Doc]

    E8 5-Cube
  • Assassin vs Bodyguards

    Consider a room of regular polygon shape in the xy-plane, and let A (an "assassin") and T (a "target") be two arbitrary-but-fixed points within the room. Suppose that the room behaves like a billiard table, so that any ray (a.k.a "shot") from the assassin will bounce off the walls of the room, with the angle of incidence equaling the angle of reflection.

    Puzzle: Is it possible to block any possible shot from A to T by placing a finite number of points in the room?

    [PBS Video] | [math3ma blog]

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 should work fine.

Thanks

I have learned a lot from the following people:

License

see the LICENSE file.

pywonderland's People

Contributors

gsilvan avatar isaaclyautey avatar lucas-c avatar mohi7solanki avatar neozhaoliang avatar philippeitis avatar wlbksy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pywonderland's Issues

Question about gifmaze module and pypi

Hello.

I would lile to contribute to the gifmaze module,
but I am a bit lost between the various versions of this code.

So :

  • is this the "official" gifmaze.py source code repository ? :)
  • do you plan on publishing new version of gifmaze on pypi.org ?
  • are you willing to accept pull requests ?

Regards

Error when runing e8.py

---> 14 import cairocffi as cairo
15 import numpy as np
16 from palettable.colorbrewer.qualitative import Set1_8

C:\Localdata\Software\PythonAnaconda\lib\site-packages\cairocffi_init_.py in ()
14 import ctypes.util
15
---> 16 from . import constants
17 from .compat import FileNotFoundError
18 from ._ffi import ffi

ImportError: cannot import name constants

Projects to be added in this repo

The following projects will be completely rewritten:

  1. The 120-cell. The main changes will be:

    • Can render all 4D polytopes, not merely the 120-cell.
    • Use Todd - Coxeter algorithm to generate all vertices, edges, faces, not using a pre-computed data.
    • Use POV-Ray to render nice images.
    • Port jenn3d to python with Pyglet and GLSL.
  2. The hyperbolic tilings. The main features will be:

    • Use more advanced algorithm to generate the tiling i.e. the minimal root algorithm.
    • Tile the disc with an user defined texture, i.e. Escher's circle limit art.

The following projects will be added to this repo:

  1. Fluid simulation with Navier - Stokes equation.
  2. 3D minimal surfaces with POV-Ray.
  3. Image warppings with conformal transformations.

(PYL-R1723) Unnecessary `else` / `elif` used after `break`

Description

The use of else or elif becomes redundant and can be dropped if the last statement under the leading if / elif block is a break statement. In the case of an elif after break, it can be written as a separate if block. For else blocks after break, the …

Occurrences

There is 1 occurrence of this issue in the repository.

See all occurrences on DeepSource → deepsource.io/gh/neozhaoliang/pywonderland/issue/PYL-R1723/occurrences/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.