Giter VIP home page Giter VIP logo

polargraph-optimizer's Introduction

polargraph-optimizer

Optimize drawing plan for a polargraph

Example Usage

Optimize the included drawing plan map.txt:

$ time ./process.py map.txt > map_optimized.txt 
Total Glyphs: 8074
Initial penup distance:   4107485
Initial total distance:   4742961
Deduped penup distance:   3494625
Deduped total distance:   4040278
Sorted penup distance:    5319295
Sorted total distance:    5864948
Greedy penup (i=0)         124384
Greedy total (i=0)         670037

real  1m0.164s
user  1m0.088s
sys 0m0.024s

Now map_optimized.txt includes a reordered drawing plan with duplicate glyphs removed and with an improved ordering.

About the algorithm

The optimization algorithm is basically this:

  • Remove path sections which are exact duplicates of earlier sections
  • Reorder paths:
    • Pick the first path as the first path in the input file
    • Find the path that starts nearest the previous one's endpoint, or the one which, if reversed, would start nearest the previous one's endpoint
    • Repeat until we have processed all paths

For the drawing plan map.txt included, this results in a 7.1x improvement in total pen travel distance (see code for definition of distance). Actual results will vary due to a variety of factors. Please report real-life results so we can include them here!

Contributors

Evan Heidtmann

Olivier Bouwman

polargraph-optimizer's People

Contributors

euphy avatar ezheidtmann avatar olivierbouwman 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.