https://github.com/ongzzzzzz/marching-squares
https://github.com/ongzzzzzz/marching-squares
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ongzzzzzz/marching-squares
- Owner: ongzzzzzz
- Created: 2021-12-08T16:50:05.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-09T03:13:17.000Z (over 3 years ago)
- Last Synced: 2025-01-05T07:46:33.168Z (5 months ago)
- Language: JavaScript
- Size: 452 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# marching-squares
this repo is an implementation of the marching-squares algorithm to render metaballs on the screen.idea from a youtube video by Reducible: https://www.youtube.com/watch?v=6oMZb3yP_H8
desmos graph if u just wanna see the math stuff: https://www.desmos.com/calculator/q08htskxrs
# notes:
- metaballs look cool
- many functions can be written implicitly (eg. x^2 + y^2 = 4 encodes a circle)
- explicit fns: y=f(x)
- implicit fns: f(x, y)=C, where C is constant
- metaballs is just an implicit fn - kinda like superposition of Magnetic Fields in physics
- sum( R / sqrt( (x-x1)2 + (y-y1)2 ) ) = C, for all x, y in grid
- marching squares is just an algorithm to draw implicit fns
- check every grid square, are their corners `< C` or `> C` ?
- draw a connecting line according to which corners `< C` or `> C`
# todo
- make the balls move more naturally
- add interactivity? (add / remove balls)
- slider for resolution (high res = laggier)
- color in balls