As usual with my graphical stuff, you'll need the legacy (1.2) versions of SDL to compile this. And the font path may vary; adjust it for your system.
normal order
Tuesday, June 18, 2019
2048
Thursday, May 31, 2018
ramanujan's Π summation
For example, here's Ramanujan's sum for Π which, after just 3 terms, overwhelms IEEE 754 double precision. Modern discoveries, like spigot algorithms on non-decimal bases, can find a given individual digit in constant time. But for fully expanding Π, no one has surpassed Ramanujan's expression: both the Chudnovsky brothers and Yasumasa Kanada adapted it to achieve their milestone calculations.
Tuesday, March 13, 2018
generalizing langton's ant
Wednesday, December 13, 2017
gumowski-mira attractor
The system seems to give interesting results only when b is close to one. It behaves less chaotically when b > 1 is fixed, so you can actually animate it - click the thumbnail to see.
Monday, May 15, 2017
128-bit AES electronic codebook
Note that this code only does ECB mode; it computes rather than hard-codes the S-box; and it could be vulnerable to side-channel attacks. So enjoy reading it, but don't try to make a serious encryption app out of it. That kind of thing is best left to the professionals :)
Monday, March 6, 2017
butterfly curve
One application I thought of for this is object motion in games: I tried it out by writing this little Canvas game, where the comets follow the curve's trajectory. The differences in plot density along the curve create natural-looking comet tails.
Friday, February 24, 2017
bézier curves
Wednesday, February 22, 2017
convex hulls
A variation on the algorithm, noted by A.M. Andrew, sorts the set lexicographically and finds the upper and lower hull chains separately. This 'monotone chain' version is often preferred, since it's easier to do robustly.
Wednesday, February 15, 2017
more Π obscurantism
But as you can see from the comment, the series converges very slowly!
Friday, June 3, 2016
segment intersection search
Here's a simple method I learned from Gareth Rees for finding the intersection (or parallel / collinear status) of two line segments. Rees credits Ronald Goldman, though I'd imagine the technique goes further back.
Monday, March 28, 2016
today in oblique approaches
Wednesday, February 17, 2016
ikeda map
In these images, I've plotted the real and imaginary components along the x and y axes respectively. But the more popular way to visualize this attractor adds an extra parameter to the system and is expressed in trigonometric functions. Such adaptation of the code below yields these results.
Saturday, February 13, 2016
hénon attractor
French astronomer Michel Hénon reported on this strange, fractal attractor in 1976. Since then, it has been among the most studied examples of chaotic dynamical systems.
Tuesday, January 26, 2016
langton's ant
For a round of code golf, I wrote this spare implementation of Chris Langton's remarkably simple universal computer. If you want amenities like pause, random starting pattern or even quit, check out this more complete version.