This is a follow-up on the post about Triangular Grids, to see how easily we could adapt a regular grid for Truchet tiles.
Rectangular Grid
Simple tile
We start, as always, with the simple Cartesian grid, and the simplest set of two Truchet tiles.
For the grid, we randomly choose from either of the two tiles. Lovely, isn't it?
More complex tiles
We of course are not limited to these two tiles. In fact, we can come up with as many tiles as we like, as long as they contain strokes that "exit" the tile at the four cardinal directions.
Naïve Triangular Grid
Triangle rotation
As an aside, let me tell you about rotating triangles. When working with triangular grids, you'll find yourself wanting to rotate a triangle both at 180° (flip it upside down), as well as 120° and 240° (turn it a third around). What was somewhat surprising to me is that the centers of rotation are not the same for the two actions! For 180°, we use the point that is halfway down the height of the triangle. For 120° rotations, use the midpoint of the triangle, which would be of the height of the triangle.
Simple Truchet Tile
Surely, we could extend this idea to equilateral triangles, since they, too, can tile the plane beautifully! The first problem is that a triangle has three sides, so we only have three potential edge connection points. If we only choose tiles that use one line to connect two of the sides, while leaving the third empty, we get a disjointed grid that isn't much fun.
Triangular grid with two notches per edge
Circular curves
What we really want is to ensure that lines continue throughout the plot, like we see in the Rectangular grids above. For this, we can outline two points (or "notches") on each side, making six potential connection points. We then merely need to come up with all the tiles that have these properties. For the first approach, I will connect pairs of edge points such that they do not cross. For three pairs of points, the number of such tiles actually turns out to be equal to the Catalan number . One way to think of this as a Catalan expression is to imagine a sequence of balance parentheses. If we number the edges clockwise from the top left, starting with 1, then one way to represent the first tile on the right is as '12,34,56', or as '()()()'. For now I'll stick to using just circular segments, which lead to a slight overlap for the last three tiles. We'll have to use Bézier curves to get rid of this overlap.
Bézier curves
Next, let's see how to make sure those lines don't overlap. To make sure the lines don't look disconnected or jagged, it is wise to ensure that they connect to the edge of the tile perpendicularly. Luckily, so long as we keep the first and last Bézier edge perpendicular to the tile edge, this should work!
For this, it might be helpful to talk about the measurements of the triangle. I've decided that it would be best to handle a triangle that has side length of 100 units. The height of the triangle is then . I divide each edge into three equal parts of length . The midpoint of the triangle is of course of the way down the height. I extend the notches on the edges until they intersect, leading to three points on the interior, which will form the control points of the Bézier curves.
Finally, it is helpful to know that Bézier curves are contained within the convex polygon outlined by its control points, and the normal vector at each endpoint is parallel to the control edge touching it, so we get perpendicularity for free.
So let's take a look at the five tiles using Bézier curves. They look much neater this time!
Intersecting connections
We of course don't need to restrict ourselves to non-intersecting segments. We can start by naively letting them cross all over the place. The number of such unique tiles would be tiles. For your intution, you can think about how notch "1" can be connected to any of the 5 remaining notches. This leaves 4 notches not connected. Take the lowest number one, and you can choose between three other notches to connect it to. That leaves two notches which have to be connected, so there is no choice.
We merely have to iterate over all possible combinations. I list the tiles vertically, starting with ones beginning with "12", then "13", and so on.
Triangular grid with 4 notches
We can try to expand the triangular tiles by etching four instead of two notches on every side. This will result in twelve notches in total, which makes 6 pairs of notches to connect. Let's start by planning out how we'll render all of the possible connections.
Figuring out how to connect all of the curves is not very trivial. I start off by connecting all pairs of notches that show axial symmetry along one of the heights of the triangle, giving six cases to consider. I'll admit, the logic here was not very pretty, sometimes I had to pick odd midpoints, but it worked out in the end.
Next, we have to consider the remaining curves on only one side of the height of the triangle, which only leaves two remaining curves. Again, I chose Quadratic and Cubic Bezier curves and picked from the control points listed above.
I know that I will have tiles. I generate all them using a simple algorithm, and you can see them all below. For brevity, I've ommitted the dash between pairs of letters. I also use the characters 'A' - 'C' for values 10 through 12.
Further ideas to explore
- Let's say we want to render a continuous curve from a Truchet tiling. In the current implementation, each tile is rendered separately, the appearance of a continuous curve is purely coincidental. This might be come in handy when dealing with plotting a tiling with a pen plotter.
- What about hexagonal grids?
- What about other Euclidean tilings?
- How do I make one Bézier curve overlap another such that the one "under" doesn't render for a bit? Do I need to break the Béziers into two?
Further resources
- This fun Tile Generator at https://emh.io/tiles/