The math can be optimized by at least an order of magnitude.
Trigonometry functions are expensive, especially the reverse ones. If v=0.5, see [1] for how to find out sine/cosine of a maxSpread * v. For angleBetweenCenters + maxSpread * v, see [2] for how to find sine + cosine of a sum of angles. If you’ll do all that math in the symbolic form (you can use Maple or Mathematica or something similar), you’ll get the equivalent formulae for p1-p4 that won’t use any trigonometry, only simple math and probably a square root. [1] https://en.wikipedia.org/wiki/List_of_trigonometric_identiti...
[2] https://en.wikipedia.org/wiki/List_of_trigonometric_identiti...
Implemented a 2D angle class for cases like that, where you would otherwise use these slow trigonometry functions. It’s C++ but should be easy to convert to JavaScript or any other OO language.
After years of living in the US, I still have trouble that the word is "cockpit" not "cocktip". That became hilariously obvious when at work we had to use a library that uses the term "cockpit" for one of its main components.
I just started learning GLSL shaders. As practice, I wrote a psuedo-metaball joystick. I didn't know about metaballs, but now that I do I can do some more research and improve my next iteration.
About 2 minutes in there's an excellent realtime metaballs implementation that ran smoothly on a 486-66mhz. Metaballs were an extremely popular effect in the early 90's.
Comments (93) 36 threads
Earlier commentsTrigonometry functions are expensive, especially the reverse ones.
If v=0.5, see [1] for how to find out sine/cosine of a maxSpread * v. For angleBetweenCenters + maxSpread * v, see [2] for how to find sine + cosine of a sum of angles.
If you’ll do all that math in the symbolic form (you can use Maple or Mathematica or something similar), you’ll get the equivalent formulae for p1-p4 that won’t use any trigonometry, only simple math and probably a square root.
[1] https://en.wikipedia.org/wiki/List_of_trigonometric_identiti... [2] https://en.wikipedia.org/wiki/List_of_trigonometric_identiti...
https://gist.github.com/Const-me/46f90ce7fc2bc65dc12a41442ed...
I once reviewed an academic paper at a major CS conference that misspelled metaballs as meatballs throughout.
[1] https://www.youtube.com/watch?v=OonDPGwAyfQ
Touch blob joystick shader: https://www.shadertoy.com/view/4lfcRf
About 2 minutes in there's an excellent realtime metaballs implementation that ran smoothly on a 486-66mhz. Metaballs were an extremely popular effect in the early 90's.
http://www.pouet.net/prod.php?which=1023
http://www.pouet.net/prod.php?which=911
How about first on the C64? Here's Booze in 2010:
http://www.pouet.net/prod.php?which=56003
All comments shown.
Couldn't load more comments. Check your connection and try again.