gracien-app / ModularMTL

Hardware accelerated visualisation of Modular Multiplication on a Circle written in Swift using Metal API and SwiftUI.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ModularMTL

About

Modular multiplication on a circle, is a beautiful way to visualise interesting patterns, emerging from basic operation of multiplication. The inspiration for this visualization came from Times Tables, Mandelbrot and the Heart of Mathematics YouTube video by Mathologer.

Written in Swift using Metal API and SwiftUI.

Images

Prototype

Algorithm

The operating scheme is very simple:

  • Distribute N points on the circle equally,
  • Select a multiplier M
  • For each point n:
    • Perform modulo N operation on a product of index of point n and multiplier M
    • The result of the above operation becomes the index of the endpoint e
    • Create a connection between points n and e

Computation of connections is offloaded to Compute Shaders, written using Metal Shading Language.

Features

  • Animation mode,
  • Parameter controls using arrow keys,
  • Glow effect on supported hardware (Metal Performance Shaders),
  • Managed using Swift Package Manager with separate Core module.

Building

Binary must be bundled together with Core bundle containing default Metal library (.metallib file).
The easiest way to do that, is using swift-bundler tool.

Once set up, it can create application bundle with proper structure and Metal library included in Core bundle.

git clone https://github.com/gracien-app/ModularMTL.git
cd ModularMTL

# Build Universal binary in Release configuration. 
# Application bundle will be created in your current directory.
swift-bundler build -c release -o . -u

Universal application bundle available in releases.

About

Hardware accelerated visualisation of Modular Multiplication on a Circle written in Swift using Metal API and SwiftUI.


Languages

Language:Swift 86.6%Language:Metal 13.4%