I see these around the web and would like to make them in Mathematica.
Combining them in an array is actually quite mesmerizing!
|show 7 more comments|
One way to do it is to create the texture for one tile and then transform repeated copies of it in a way that resembles the original illusion.
First we create the tile:
Then we make repeated copies of it:
For the transformation we can use an exponential mapping, which will turn the $y$-coordinate into an angle and the $x$-coordinate into an exponent for radial distance. Since the mapping is most elegantly described with complex numbers but we need to work with cartesian coordinates we can use
Since this is so useful we wrap it in a procedure for easy reuse:
Now we just need a way to transform our checkerboard image according to our mapping, which is exactly what
Michael E2 pointed out another possible way, namely using the inverse mapping, so let's try that! Up to now we basically let Mathematica do a forward transform of our checkerboard into the disk shape and let it fill the holes via interpolation and throw away the points that got mapped outside of our
Instead we can go the reverse route and start with the destination pixel locations and ask where they came from before undergoing that exponential mapping. Since we made the effort to generalize the procedure of getting a cartesian mapping from any complex function we now can just plug in the inverse complex function, which is the (or rather a branch of) the complex
Great! Now we can use
where we had to adjust the
To see the difference here are images from both approaches, but generated from a tile with
|show 6 more comments|