QRS is an alternative 2d grid based on the hexagonal lattice for use with equilateral triangular tesselation. Since ancient times curious minds have tried to work out ways to tile the 2 dimensional plane. Three regular shapes are able to tessellate naturally over the entire plane, the equilateral triangle, the square, and the hexagon. The square tessellation of course went on the become known as the Cartesian coordinate system and became the standard. This paper will explore the other possibilities of coordinate systems built on the hexagonal and triangular tessellations. If you find this useful and would like more information about how this coordinate system could be used for triangular prism voxels, hexagonal prism voxels, or simply triangles and hexagons then please let me know by email at "dave at davehardee dot com". Please no spam or solicitations.
The hexagonal tessellation is useful, but has some major drawbacks as one can not fit a number of smaller hexagons into a larger one no matter how they try. In the hexagonal grid there is also the issue of not being able to use a line to divide one group of hexagons from another along their borders. One is only able to follow the zigzag between the hexagonal edges. Hexagons do have some excellent qualities in that all of the neighboring hexes are equidistant, and they mimic naturally occurring phenomenons such as the cones placement inside our eyes and honeycomb made by bees.
The triangular tessellation is actually closely related to the hexagonal tessellation in that the faces of the hexagon are the voronoi diagram of the vertices of the triangular tessellation (this will be explained below). The triangular grid does have some of the features comparable to the square grid in that half sized triangles do fit inside of full sized and there are straight lines that could divide the whole plane of tiles very nicely.
Triangles don’t make the best shape for creating extents around other objects. If for example I have a circle that I want to encase in each of the three regular shapes that tessellate, the triangle would have a lot more area that is wasted in encapsulating the circle. The most efficient shape would actually be the hexagon as demonstrated below.
Triangles do make excellent building blocks on the other hand. Two triangles can be put together to create a rhombus, which is a four sided parallelogram similar to the square with the main difference being that there are two corners using a 60 degree angle and two that use 120 degree angles. Six triangles put together make the hexagon. In this way custom extents could be created. For example the if the triangular extent above was divided into triangles a third the size, a hexagonal extent could be created from the smaller triangles.
In looking at these systems very basic relationships can be teased out. For example the triangular tessellation is a dual of the hexagonal tessellation, and the square is the dual of itself. When I say dual, I mean that if one were to take the vertices of one tessellation it will correspond to the faces of the other and vice versa as demonstrated by the diagram below. This is what is meant by one being the voroni diagram of the other.
So given the relationships of these tessellations, we are able to work out some possible coordinate systems. When starting with a hexagonal tiling of the plane there are a few ways to determine how a tile relates to the origin as defined by 0x,0y. One could attempt to order the hexagonal grid by forcing the hexagons into a traditional square grid having the odd or even row be offset. Another is to use a skewed set of 2 axes as proposed by Wesley E. Snyder, Hairong Qi, and William Sander from the North Carolina State University. One system that I found to be very intuitive was the cubic system as defined by Charles Fu back in 1994, though it is possible that others before him have defined this same system. The concept is that each hexagonal face has three variables relating it to the x, y, and z coordinates of a cube. Amit Patel proposed that we call this the Q,R,S system, and I have adopted it for consistency sake. First we start by looking at a cube with an orthogonal view lining up one corner of the cube to the opposite corner on the other side.
When viewed from this perspective it actually makes a hexagon, especially if you take out the inner lines. Now if we were to tile the entire 2 dimensional plane with these cubes/hexagons a honeycomb grid would be displayed. If we apply a 3 dimensional coordinate system to these hexagons as though they were cubes with x extending positive in the lower left direction or 210 degrees, y extending positive directly upwards or 90 degrees, z extending positive in the lower right or 330 degrees, essentially making three sets of hexagonal columns. Please note that this whole system can also be rotated by 90 degrees clockwise to get flat topped hexagons as opposed to pointed topped. What comes out of that is what is referred to as the cubic coordinate system.
Please note that the sum of the three coordinates at any hex sum to 0. This happens in part because one of the axes is redundant, really the whole space could be described by any two of the axes just like in standard orthogonal 2 space. If we now transform each hexagon so it is very small, so small that it could be considered a point, but the relationships to the neighboring hexes are maintained as these three axis. What comes out of it is a hexagonal lattice, or a tiling of the plane as equilateral triangles.
I have chosen arbitrarily that s will be the axis that runs parallel to the traditional x or y axis. The r and q axes are rotated at 60 and 120 degrees respectively from the s axis. Just as before each of the axes will be positive in a direction that is 120 degrees from the other 2. All of the points could be described by any two of the axes, and because of the aforementioned redundancy. Also because of the nature of the sum of the values for each point being 0, if two of the values are known the third could easily be calculated.
Now the distance from one level to the next level of one of these axes (e.g. s=0 to s=1) is the height of an equilateral triangle. If we assume that the side of one of the triangles is a basic unit of 1, then the height of the triangle will be √3/2. I like to refer to this as a bee-unit, and when programming you can set it as a constant. This then allows the conversions from the X,Y plane to the Q,R,S plane. The conversion between a standard system to this Q,R,S system is fairly straightforward. I found that the easiest to convert to from the three 2D options was the RS plane. The X values is equal to R - ½ S, and the Y value is S*(2/√3). Likewise when converting to this system R is X + ½ Y and S is Y*(√3/2). The last coordinate Q can be found by adding R to S and finding the term that makes them equal to 0. If you instead want to have S go along the Y axis, the conversion is simply swapped between the X and Y.
With this 3 axis coordinate system there are a few things that can be described. If for example we wish to find any equilateral triangle of any size that is aligned with the axes all that is needed is to know the value of each of the axes that represent the edges. This means that all that is needed to describe a triangle is a simple triplet with the edge values.
The three vertices of the triangle would be found by taking two of the edge values, adding them together, and determining a third value that if added to the first two would make the sum zero. Using these coordinates it is possible to build extents. For example if I was given the triplet (5, 3, -4) the first corner would be 5+(3) = 8 -> 5+(3)+(-8)= 0 so (5,3,-8). The second corner would be 5 +(-4) = 1 -> 5+(-4)+(-1)= 0 or (5, -4, -1). The third corner would be -4 + 3= -1 -> 1+ 3+ (-4)= 0 so (1, 3, -4).