ladnik / pascal

Graphical representation of the Sierpiński triangle based on Pascal's triangle and modulo operations on the binomial coefficients

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pascal

Graphical representation of the Sierpiński triangle based on Pascal's triangle and modulo operations on the binomial coefficients. Implemented in Processing, a visualization and animation language and framework based on Java.

If you have any questions regarding this project or ideas on improving it, feel free to contact me.

Mathematical background

The Sierpiński triangle is a fractal attractive fixed set with the overall shape of an equilateral triangle, subdivided recursively into smaller equilateral triangles. Originally constructed as a curve, this is one of the basic examples of self-similar sets—that is, it is a mathematically generated pattern that is reproducible at any magnification or reduction. It is named after the Polish mathematician Wacław Sierpiński, but appeared as a decorative pattern many centuries before the work of Sierpiński. [Wikipedia]

Implementation

The Sierpiński triangle can be generated through many different methods, this application uses the coloring of remainders when dividing binomial coefficients placed in a triangle shape (Pascal's triangle).

Pascal's triangle is generated by starting with "1" for row 0, for each subsequent row a "1" is added to each side. Starting at row 2, the values between those outmost "1" are calculated by adding the two numbers directly above in the previous row. It then looks something like:

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
...

Each value of the triagle is placed inside a box which then is colored according to the remainder of the modulo operation with the specified divisor. The controls are displayed within the application.

Further details are explained in the code's comments.

Execution

Executing .pde file in VSCode

  • Install the Extension 'Processing for Visual Studio Code' by Tobiah Zarlez
  • In the .pde file, press cmd-shift-p and run Processing: Create Task File
  • After creating the task file in your workspace, run Processing: Run Processing Project via the same window
  • A new window running the application should open

Executing the exported executables

  • For Windows, get the latest release here, unpack it and run pascal.exe.
  • For Linux, get the latest release here, unpack it and run pascal (or open it in a terminal and run chmod +x pascal and ./pascal). If you haven't installed Java yet, install the correct JRE and JDK for your system through your package manager.

Examples

  1. Borders and numbers displayed, color scheme 2, mod 6

program screenshot 1

  1. Borders and numbers not displayed, color scheme 1, mod 3

program screenshot 2

Sources and further notes

The keyboard and mouse icons are taken from Xelu's icon pack. [Source]

About

Graphical representation of the Sierpiński triangle based on Pascal's triangle and modulo operations on the binomial coefficients


Languages

Language:Java 53.0%Language:Processing 47.0%