Giter Site home page Giter Site logo

niciki / sierpinski_fractals Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 2.0 25 KB

Chaos plot visualization of Sierpinski triangle (Sierpinski gasket) and Sierpinski square (Sierpinski carpet) using two different libraries (turtle and mathplotlib).

Python 100.00%
visualization sierpinski-triangle sierpinski-carpet sierpinski sierpinski-gasket sierpinski-algorithm

sierpinski_fractals's Introduction

Sierpinski fractals

Sierpinski triangle or Sierpinski gasket

Chaos plot visualization is done using two different libraries (turtle and mathplotlib). In the first visualization, the points are drawn sequentially, due to this, the speed is much lower than in the second method, where all the points are drawn together and the result is presented in the form of a picture. Attractor points are 3 vertices of the triangle. The number of points can be changed (it is necessary to change the value of the variable n).

Sample image for an image using the turtle module and n = 50000

image

Sample image for an image using the mathplot module and n = 100000

image

Sierpinski square or Sierpinski carpet

The algorithm is similar to drawing a Sierpinski triangle, but 8 points of attractors are used: 4 points of the apex of the square and midpoints of the sides.

Sample image for an image using the mathplot module and n = 1000000

image

Note

When using the variant that uses the mathplotlib library for large n (~> 100000), it is recommended to additionally specify specify the last additional line width parameter in ax.scatter, which can be made small, or even equal to zero, for example: linewidths = 0

An example of drawing a triangle for n = 10e7 without decreasing linewidth to 0

image

An example of drawing a triangle for n = 10e7 with decreasing linewidth to 0

image


Example of distribution of points with increasing n for a triangle

Гифка с Gifius ru

Example of distribution of points with increasing n for a square

Гифка с Gifius ru (6)

sierpinski_fractals's People

Contributors

niciki avatar

Stargazers

 avatar

Watchers

 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.