GithubHelp home page GithubHelp logo

penrose.py's Introduction

penrose.py

This repository contains several Python 3 modules for building and manipulating Penrose tilings. For now, only the kite-and-dart (P2) and rhombus (P3) tilings are supported (as well as the associated Robinson A and B tilings), but it should be fairly easy to add support for the P1 tiling as well.

NOTE: I (Zachary Catlin) do not intend to work on this further, package this for PyPI, etc. If you’re interested in developing this further, please feel free to fork this repository.

This is extracted from a private project of mine; as there’s nothing particularly secret about the code I wrote, I’m posting it in case someone else would find it useful.

The main show is in the following modules, listed by increasing level of abstraction:

  • pen_num – the class Number is an implementation of the number field ℚ[√(10+2√5)], which allows for exact representation of tile coordinates (for the tile sets in question) and rotation matrices for multiples of 18° (also relevant for the tile sets in question).

  • pen_geom – geometric primitives—e.g., points, line segments, affine transforms—and operations and predicates involving these primitives. Uses pen_num.Number to represent coordinates and other numeric values.

  • penrose – contains a class to represent a tile with a matching rule; subclasses implement the tiles of the P2, P3, A, & B tilings.

  • tile_manager – a container for managing a set of positioned tiles, including making sure that intersection and edge-matching constraints are obeyed, as well as supporting whole-tiling manipulations like deflation.

  • tile_output – helper functions for outputting a tiling as SVG paths.

Also, there are several accessory modules and scripts:

  • pen_num_tests, pen_geom_tests, and test_runner.py – test suite for the lower-level modules.

  • decomp_check.py – a script I used to graphically verify several of the tile decompositions.

  • deflate_sun.py – a script that starts with a P2 sun vertex figure and proceeds to repeatedly deflate it, writing out SVG images of each step. The output of this script is what I wrote these modules for in the first place.

As it stands (March 2021), this code works well, but works slowly—running deflate_sun.py takes several hours on my vintage-2015 laptop. From profiling runs, the major culprit appears to be the enormous number of memory allocations/deallocations needed: a pen_num.Number is a composite object of composite objects. Streamlining the layout of Number or rewriting it in a compiled language are probably your best bets for making this run faster.

penrose.py's People

Contributors

zec avatar

Watchers

 avatar  avatar

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.