## Straight lines in elliptic and hyperbolic space

A straight line is the shortest path between two points. Discussing curved space we would better call them geodesic lines to avoid confusion. I want to discuss these geodesic lines for surfaces of a sphere, elliptic space and hyperbolic space. Further we shall see how they are defined and that there is some resemblence between these spaces.

Geodesic lines on the surface of a sphere are great circles. An example is the equator of the earth. In general a great circle is the intersection between a plane going through the center of a sphere and the surface of the sphere. Thus we get a unique great circle for any two points on the surface of the sphere because these two points together with the center of the sphere define the plane that contains the great circle. This shows that two points determine a unique geodesic line in spherical geometry and that the geodesic line is not the same as in Euclidean space. Quite in general we expect that two points give a unique geodesic line. Its shape depends on the geometry of space.

We get an elliptic space from the stereoscopic projection of the surface of a sphere to an Euclidean drawing plane. Great circles on the surface of the sphere appear as circles too in the drawing plane. Thus the geodesic line between two points is now a circle going through these points. But what is its radius? We could find it by projecting the points back to the surface of the sphere, getting the great circle going through these points and projecting the great circle back to the drawing plane. But this is unnecessarily complicated and we better find a simple equation that directly defines us the radius of the circle in the drawing plane.

Note that the center of the stereoscopic projection is the north pole of the sphere and that the projection plane goes through the south pole. The projection plane is parallel to the equatorial great circle. The image of the equator is trivially a circle of twice the radius of the sphere. Any other great circle intersects the equator at two opposite points. Thus geodesic lines in the elliptic plane too intersect projected equator at opposite points. They look like this:

The red circle is the projection if the equator and the brown dot is the projection of the center of the sphere. The blue circles are geodesic lines that have their center on the black line. Note the yellow dots. As discussed, all these geodesic lines go through this point. If R is the radius of the red circle, r is the radius of the circle representing the geodesic line and d is the distance of its center from the projection of the center of the sphere, then we get

d² + R² = r².

This equation uniquely defines the geodesic line connecting two points in elliptic space. It is essential for creating images in elliptic space and relating them to images on the surface of a sphere.

For the Poincaré disc representation of hyperbolic space we get similar results. Geodesic lines are now circles that intersect the boundary of the disc at right angles:

The red line is boundary of the Poincaré disc and the brown dot is its center. The blue circles are geodesic lines that go through the yellow dot. If r is the radius of a geodesic and d the distance between its center and the center of the disc, then

d² – R² = r²,

where R is the radius of the disc. Again, this equation determines the radius of a circle going through two points and makes that geodesic lines are unique. We need it to create kaleidoscopic images in hyperbolic space. Obviously, there is some resemblance between the stereographic projection of a sphere and the Poincaré disc. But do not go to far on that.

Posted in Kaleidoscopes, programming | | 1 Comment

## Decorations of semi-regular tessellations

In the last posts I have shown kaleidoscopes that make repeating images in Euclidean, spherical and hyperbolic spaces. They are decorations of regular tilings. But what about semi-regular tilings? Could we decorate them too using mirrors? This would give us new designs. With real physical mirrors we probably can’t do it. On the other hand, with computer generated mirror symmetries this becomes possible.

Let us take as an example the regular tessellation of hexagons shown in the image below. Drawing lines between the mid points of adjacent sides we get a semi-regular tessellation of triangles and hexagons. Each triangle is made up of three corners cut off from the hexagons. A decoration of the regular tessellation arises from a triangular kaleidoscope with angles of 30°, 60° and 90°. It is shown in red lines in the image and uses the part of an input image that fits into this triangle. Mirror reflections cover the entire plane with copies of this image part. This emphasizes the regular tessellation of hexagons  because there are mirror symmetries at the borders of the hexagons. To get a decoration of the semi-regular tiling we need additional mirror symmetries at the borders between the triangles and the hexagons. We note that one of these border lines cuts the red triangle in two parts and we only use the pixels of the input image that lie inside the larger part, which is coloured yellow. We cover the other rose-coloured part of the triangle doing a mirror image at the border of the triangle. Thus we get an image with additional mirror symmetries that emphasize the semi-regular tessellation. In this sense we have made a decoration of the semi-regular tiling.

Regular tessellation with hexagons (blue lines) and semi-regular tessellation with hexagons and triangles (brown lines). The triangle of red lines shows the position of the mirrors of a kaleidoscope. Images of the yellow region and parts of it make a decoration of the semi-regular tessellation.

We can use the method discussed above to get semi-regular tessellations of the hyperbolic plane. Using a kaleidoscope with a right-angled triangle characterized by the numbers (k 2 n) we get a decoration of a regular tessellation with regular polygons that have k corners. Each corner point is shared by n polygons. To create a decoration of a semi-regular tessellation we again use reflection at additional lines. They go through the corner of the triangle which has the right angle, cross the opposite side at a right angle and are straight lines in hyperbolic space. In the Poincaré disc representation they are circles that are perpendicular to the boundary of the disc. These lines define the semi-regular tessellation. It is made of regular polygons. Half of them have n corners and the other half k corners. A corner point is shared by 4 polygons. Using reflections at these additional lines we get a decoration of the semi-regular tessellation. The image below shows an example.

Kaleidoscopic decoration of a semi-regular tessellation of pentagons and squares. The red lines show the basic (5 2 4) triangle that makes a regular tessellation of pentagons. The brown line cuts off the corners of the pentagon and creates smaller pentagons and squares by reflection at the red lines.

## further wallpapers for hyperbolic space

An equilateral triangle gives us a kaleidoscope of three-fold rotational symmetry. With a square we get two-fold rotational symmetry. Would reflection at the sides of other regular polygons too give periodic images with rotational symmetry ?

To get an h-fold rotational symmetry at a corner we need an angle of 180°/h between the sides meeting at the corner. This is not possible for polygons with more than four corners in Euclidean space because they would have angles of more than 90°. However, in hyperbolic space the corner angles can have any value smaller than (1-2/k)180°, where k is the number of corners of the polygon and the limit results from Euclidean geometry.

We use the Poincaré disc model for hyperbolic geometry. You can find a very interesting detailed discussion at http://www.malinc.se/math/noneuclidean/mainen.php. The most important facts are: An open disc represents the infinite hyperbolic space in our Euclidean space, straight lines in hyperbolic space become circles that intersect the boundary of the disc at a right angle and the inversion at these circles is equivalent to the mirror image at the straight lines in the hyperbolic space.

A regular polygon that has its center at the center of the Poincaré disc shows its dihedral symmetry in our Euclidean drawing plane. Its sides are arcs of equal width and they belong to circles of equal radius. These circles are straight lines in hyperbolic space. The angle between the two arcs at a corner is simply the angle between their tangents. Using basic trigonometry we get their radius from the desired value 180°/h for the angles, the number k of corners of the polygon and the radius of the Poincaré disc. This defines the reflection at the sides of the polygon as inversions at the circles bearing the arcs. Thus we get an easy generalization of the usual regular polygon with straight edges.

As in the earlier posts, we have to map points of the Poincaré disc into the polygon using reflections at its sides. The symmetries of the regular polygons make this easier than for triangles. As long as the point lies outside the polygon we use inversion at the circle with the arc that lies closest to the point. The required number of inversions increases going to the border of the Poincaré disc and finally diverges at its border. Thus we have to impose an upper limit and disregard points that take too many inversions.

We rapidly find the circle to use for inversion using a coordinate system with its origin at the center of the Poincaré disc and polar coordinates. A polygon with k corners has its corners at polar angles of i*(360°/k) where i goes from 1 to k. The sides of the polygon are arcs connecting the two corners at angles i*(360°/k) and (i+1)*(360°/k). Now, if the point that we are mapping has a polar angle φ we have to find the arc that covers this angle. Thus we have to find an integer number i with i*(360°/k) < φ < (i+1)*(360°/k), all obviously modulo 360°. This defines the arc that is closest to the point. It is part of a circle which has its center at the polar angle (i+1/2)*(360°/k). If the point lies outside this circle then it has to be inside the polygon and we can get the colour for the pixel at the starting point from an input image at this mapped position. If the point lies inside the circle we invert it at the circle and repeat this procedure.

For a pentagon with angles of 90° we get a result with this structure:The original pentagon is shown in yellow. All points that need an odd number of inversions are coloured light blue and those with an even number are shown dark brown. Away from the center we see strongly distorted pentagons, shrinking towards the border of the disc. But in hyperbolic space, they are all regular pentagons of the same size, tiling the hyperbolic plane. Actually, we get tilings for all k>2 and h>1. They are made of regular polygons with k corners and each corner belongs to 2*h polygons.

Using an asymmetric input image for the pentagon at the center we get kaleidoscopic images that look like this one:It has five different motifs of two-fold rotational symmetry, one for each corner of the pentagons. Often, such images seem to lack any order. Here we see strips of repeating green swirls with mirror symmetry. In hyperbolic space they are straight infinite friezes with horizontal and vertical reflection lines resulting from the mirror symmetries at two corners of the pentagon. These friezes are separated by narrow branching lines of lighter colour.

With an input image of rotational symmetry we get wallpapers with the same rotational symmetry if the symmetry is compatible with the polygon. The same pentagon as before and a rosette with five-fold symmetry gave this:Note that an input image with dihedral symmetry would give the same image as a kaleidoscope using the (5,2,4) triangle instead of this pentagon. In general, a regular polygon with k corners and angles of 180°/h using an input image of k-fold dihedral symmetry is equivalent to using a Möbius triangle (k 2 2*h) with corner angles of 180°/k, 90° and 90°/h.

For more images of higher resolution have a look at my Flickr album “hyperbolic wallpapers”.

## How to program fast kaleidoscopes

This post repeats parts of earlier posts but I am trying to expand the ideas and explain them better. First, I am showing you how to make rosettes with rotational symmetry and mirror symmetry. This is easier than making kaleidoscopic images, but uses the same principles. Further, it is an important step in efficient programs for kaleidoscopes.

Let’s have two straight lines that intersect and divide the plane into four sectors. We use one of the sectors with an acute angle between the lines at its apex. This angle has to be a unit fraction of 180°; thus its value is 180°/k where k is an integer number greater than 1. We can then use mirror symmetries at the two lines to get a non-overlapping covering of the plane by images of this sector. This seems to be trivial as we can create a symmetric image by cutting out such a sector from an input image with scissors. We would then make copies of the sector and of its mirror image and glue these pieces together to cover the plane. Here is a typical result with green lines at the border of the sector cut out from the input image. Its copies are shown in bleached out colours:How do we program a computer to create such images efficiently? We have to find a colour value from an input image for each pixel depending on its position. Because the mirror symmetries make a non-overlapping covering of the plane by copies of the sector we can map the position of the pixel into this sector using these symmetries. We use this unique mapped position to read a colour from the input image which determines the colour of the pixel. Fortunately we do not need to find the detailed sequence of mirror symmetries as it is difficult to figure out. Instead we use that the two mirror symmetries generate a dihedral group which combines a k-fold rotational symmetry and k mirror axis. You can discover the elements of this group in the above picture.

We choose a coordinate system with its origin at the intersection of the two lines and an x-axis parallel to one of the mirror lines. Using polar coordinates (r,φ) for the position of a pixel, we have to map it into the sector with the same value for r and a new angle φ<180°/k. As a first step we use the k-fold rotational symmetry. The image is thus a periodic function of φ with a period length 2π/k and we can replace φ by its rest φ-2π/k*⌊φ/(2π/k)⌋. Then 0<φ<2π/k. Be careful, the modulo operation of some programming languages might result in something different for negative φ and you better use the universal floor function. The second step is a mirror image and it is only needed if φ>π/k. In this case we put φ->(2π/k)-φ. This gets us rapidly the mapped point in the small sector for any pixel without bothering about sequences of mirror symmetries.

A kaleidoscope uses a triangle. We get it with a third line that cuts across the sector that generated the rosette. Again the angles are unit fractions of 180°. Three numbers (k m n)  characterize the triangle. They are larger than 1 and the angles of the triangle are 180°/k, 180°/m and 180°/n. Such triangles are known as Möbius triangles, which are special cases of Schwarz triangles. The mirror symmetries of the two lines meeting at a corner make k, m or n-fold rotational symmetries in the same way as for a simple rosette. The three mirror symmetries at the three sides of such a triangle generate a larger triangle group. Applying these mirror symmetries on the triangle we get a non-overlapping covering of the plane.

The result differs strongly if the sum of the three angles (1/k+1/m+1/n)*180° is smaller, equal or larger than 180°. Our drawing plane is flat and has no curvature. Thus the sum of the angles of a triangle made of straight lines is equal to 180° and (1/k+1/m+1/n)=1. This equation has only three solutions. With the numbers (4 2 4) we get a triangle having two 45° angles and a right angle. As a kaleidoscope it makes a periodic image with two distinct 4-fold rotational symmetries and a two-fold rotational symmetry. Then (3 3 3) give an equilateral triangle and periodic kaleidoscopic images with three distinct centers of three-fold rotational symmetry. The last triangle results from (6 2 3) and has 30°, 60° and 90° angles. This kaleidoscope has periodic images with 2, 3 and 6-fold rotational symmetries. For some images of these kaleidoscopes see my earlier post “Geometry of kaleidoscopes with periodic images“. Again, we have to find for each pixel the related the unique point in the basic triangle resulting from the mirror symmetries. We only care about the result and use that the image is periodic. In a first step we map the position of the pixel into the periodic unit cell. Then, depending on the position in the unit cell we use some of the mirror symmetries to map the point into the basic triangle. Obviously, this is really fast and needs only a few simple steps. On the other hand, the periodic lengths and mirror symmetries are different for each kaleidoscope and we have to program a different mapping function for each kaleidoscope. This too is expensive and inconvenient.

Is it possible to make a single efficient mapping procedure that works for all three cases? To do this we treat the three mirror symmetries differently as shown in this image for a kaleidoscope with a (6 2 3) triangle:As for the rosette, two mirror lines (shown in green) make a dihedral symmetry group around their point of intersection. The third line (shown in red) of the triangle adds an extra mirror symmetry. The triangle cut off from the input image is shown in full colours and its copies are bleached out. To map any point into this triangle we use an iterative procedure of two steps as indicated in the figure by the blue dots and arrows. First, the dihedral symmetry maps the point into the sector between its two mirror lines. Then, if the point is still not inside the triangle we apply the mirror symmetry at the third line. These steps are repeated until the point goes inside the triangle. The example shown above used two iterations. You can see that each iteration reduces the distance between the point and the origin. Thus this iterative procedure should generally terminate and give a solution. It is very fast, versatile and easy to program. To be safe we have to limit the number of iterations used for mapping a point. The number of iterations needed for mapping a point into the triangle increases with its distance from the origin. Thus the maximum number of iterations determines the size of the resulting image and affects its border.

If the sum of the angles of the triangle is not 180° we can still use the same iterative procedure. Two sides of the triangle are still straight lines making up the dihedral symmetry and we only have to replace the third straight line by a circle. This makes it possible to have any angles of intersection between the straight lines and the circle because we are free to choose its radius and center.

We have to replace the mirror symmetry at the third line by an inversion at the circle. A circle of radius R with its center at position c inverts a point p into an image point q=c+(pc)*R²/|pc|². This inversion at a circle is very similar to a mirror symmetry. Very close to the circle the inversion gives the same results as a mirror symmetry at a tangent line. The inversion does not change local angles of intersection between lines. Actually, looking only at a small region the inverted image is similar to the original as only its orientation and size changes. At a larger scale inversion causes distortions and bends straight lines. These are important differences to mirror images that have the same size as the original and that leave straight lines intact.

We have to know that the inverted images of circles and lines are circles and lines too, but usually with a different radius. Only circles and straight lines that are perpendicular to the circle do not change upon inversion, as in this figure:The blue and red circles intersect at a right angle. An inversion of the disk bounded by the blue circle at the red circle yields again the same disk and every point outside this disk stays outside. The area of intersection between the two discs is shown in orange colour. Inversion maps it into the area inside the blue circle and outside the red circle, which is shown in green. This property of inversion is important for analyzing kaleidoscopic images.

If the sum of angles of the triangle is less than 180° we get an image with hyperbolic geometry. As an example let us look at the kaleidoscope resulting from the (5 2 4) triangle. It has 5, 2 and 4-fold rotational symmetry resulting from its angles of 36°, 90° and 36° with a sum of 171°. This is an example image:

As before, the triangle cut out from an input image is shown in full colour and its copies are bleached out. The triangle has two straight lines as sides, shown in green. They generate a dihedral symmetry with five-fold rotational symmetry for the image. The third side of the triangle is a part of the circle shown in red. As mentioned above, we use the same iterative procedure as for triangles with three straight edges. Using the dihedral symmetry we map points outside the triangle into the sector containing the triangle. Note that the triangle lies outside the circle. Thus, if the point is inside the circle we invert the point at the red circle. If this does not map the point inside the triangle we repeat these mappings.

Using enough iterations, all points inside the blue circle are mapped into the triangle. The blue circle has its center at the intersection of the green lines and is perpendicular to the red circle. Inversion at the red circle does not map the points outside the blue circle into the blue circle. These points would thus never reach the triangle and they have to be disregarded. The image of this kaleidoscope fills only the inside of the blue circle. It is a decorated Poincaré disc model for hyperbolic space.

The number of iterations increases for points that are closer to the blue circle and becomes infinite at the circle. Thus we need to limit the number of iterations. If this limit is too small we would get a rough outer border for the image. But fortunately, only few pixels take a large number of iterations and we can use a very large limit, such that the border appears to be a smooth circle.

If the sum of angles of the triangle is less than 180° we get an image with elliptic geometry. As an example let us look at the kaleidoscope resulting from the (4 2 3) triangle. It has 4, 2 and 3-fold rotational symmetry resulting from its angles of 45°, 90° and 60° with a sum of 195°. This is an example image:

This is very similar to the hyperbolic images discussed above, except that the red circle making up the third side of the triangle now contains the triangle itself. We can use the same iterative procedure as before but now we invert the point at the circle if the point lies outside the circle. This procedure maps every point into the triangle with only a few iterations. The resulting images are stereographic projections of decorated regular tilings of a sphere.

For more images of higher resolution have a look at my Flickr album “kaleidoscopic”.

## Elliptic kaleidoscopes

In “further hyperbolic kaleidoscopes” I used two straight lines and a circle to make a triangle that defines a kaleidoscope. For k,n and m-fold rotational symmetries at its corners, the sum of its three angles is π(1/k+1/n+1/m). If this sum is larger than π we have to use elliptic geometry. For (1/k+1/n+1/m)>1 the point of intersection between the two straight lines always lies inside the circle that closes the triangle. We can do the same calculation as for the hyperbolic kaleidoscopes, but now we have to use the circle inversion to map points outside the circle to its inside. The circle is bent towards the outside and acts a bit like a magnifying concave mirror.

There are only a few choices for k, m and n that give elliptic kaleidoscopes. For m=n=2 we can use any value for k that is larger than 1. The center of the circle lies at the intersection of the straight lines and the circle crosses the straight lines at right angles. This gives us rosettes with the same symmetries as discussed earlier in “combinations of mirror symmetries“. But now we use explicit inversion at the circle instead of symmetric mapping function. Thus there is not a hole at the center and less distortion. A typical result looks like that:

More interesting are the remaining kaleidoscopes. They have the same symmetry as the tetrahedron, the octahedron and the icosahedron. An octahedron has a four-fold rotational symmetry at its corners, where four triangles meet. At the center of the triangles we have a three-fold and at the middle of its edges a two-fold rotational symmetry. A corresponding kaleidoscope has the same symmetries. It generates a stereo-graphic projection of a sphere with octahedral decoration as shown in this image:

The yellow triangle is the basic kaleidoscope. The dark brown triangles are its images with an odd number of reflections and inversions and images resulting from an even number are light blue. This is a typical image of this kaleidoscope:

There is a five-fold rotational symmetry at the corners of an icosahedron. The corresponding kaleidoscope has five-, three- and twofold rotational symmetries. The petals of a rose waterlily flower gave this result with icosahedral symmetry:

A tetrahedron has a three-fold rotational symmetry at its corners. A kaleidoscope with tetrahedral symmetry thus uses a triangle with three-fold rotational symmetry at two of its corners and a two-fold rotational symmetry at one corner. Its images look like this one:

## The rotational and mirror symmetry at the center

In the last post I used mirror symmetry at two crossing straight lines and the related inversion at a circle. The mirror symmetries generate a k-rotational symmetry for an angle of intersection of π/k. With these symmetries I map any point of the plane to the small sector between the lines containing the kaleidoscope.

This becomes easy if the intersection is at the origin and using polar coordinates. The mapping does not change the radius of the point. The angle ψ of the mapped point oscillates between 0 and π/k like a triangle wave with a period of 2π/k when the angle φ of the original point goes from 0 to 2π. Thus, in a first step I do the rotational symmetry with ψ=φ mod (2π/k). Then comes the mirror symmetry. For ψ>π/k I put ψ->(2π/k)-ψ.

To get the image of the kaleidoscope on the Poincaré disk I simply alternate this calculation with an inversion from the inside of the circle to its outside. This stops when the point lies inside the triangle of the kaleidoscope. But the resulting mapping has a discontinuous derivative at the mirror lines and at the inversion circle. This makes that sharp angles appear in the output image if the input image has straight lines and other artifacts. We can easily improve the image near the straight lines.

Without inversion at the circle we get a simple rosette. This is a typical result:

You can clearly see the discontinuities, especially the angles. We can improve and remove the discontinuities with an extra mapping that has a vanishing derivatives at the straight lines. In polar coordinates we can use a Fourier expansion of the triangle function of φ, as discussed in the earlier post “Better images from higher harmonics“. With the first three terms we get a smoother image with rounded edges:

This gives kaleidoscopic images like this one:

There is another possibility. We can use the rosette mappings discussed earlier in “How to generate rosettes” and “Rosettes with mirror symmetry“. They are built on powers of exp(i k φ) and cause strong distortions destroying details of the input image. This is a typical example:

At first sight this is a disappointing mush.  To my surprise I got nevertheless interesting kaleidoscopic images, such as this one:

## Further hyperbolic kaleidoscopes

In the last post I have used reflections at two parallel lines and a circle to get a Poincaré plane that shows a periodic decoration of hyperbolic space. What happens if the straight lines are not parallel and intersect? Then their mirror symmetries do not generate translations, instead we get rotations around their point of intersection. Thus together with the inversion at the circle we now have a Poincaré disk.

The two straight lines and the circle make a hyperbolic triangle, which we use as a kaleidoscope. We get a k-fold rotational symmetry if π/k is the angle of the intersection between the lines. As in the last post n- and m-fold rotational symmetries arise at the corners between the circle and the lines for angles of π/n and π/m. The sum of these three angles is π(1/k+1/n+1/m), which has to be smaller than π for hyperbolic space. Thus the condition 1/k+1/n+1/m<1 limits the choices for the rotational symmetries.

Now let us compare this with the usual Euclidean space. The sum of the angles is then equal to π and 1/k+1/n+1/m=1. Up to irrelevant permutations there are only three solutions with integer numbers of this equation. They are (k,l,m)=(3,3,3), (4,2,4) and (6,2,3). You can see the resulting kaleidoscopes in my earlier post “Geometry of kaleidoscopes with periodic images“.

To get a kaleidoscope for hyperbolic space we simply increase some numbers. An interesting choice is (k,n,m)=(5,2,4). The resulting Poincaré disk looks like this:

Here the yellow triangle is the inside of the kaleidoscope. Dark brown triangles show images with an odd number of reflections and light blue is for even number of reflections. The borders between triangles are circles with a right angle to the border of the disc. These are straight lines in hyperbolic space. Note that this is a periodic tiling of hyperbolic space with five-fold rotational symmetry.

And now for some images. From (5,2,4) I got this:

And the (4,3,3) kaleidoscope gave that:

The circle seems to act like a convex mirror and reduces the apparent size of the reflected images in the Poincaré disc. But actually, inversion at the circle is not the same as true optics and in the hyperbolic space all images have the same size. If you zoom in at the border you will see essentially the same image. Only the radius of the disc appears to increase in comparison to the distance between images. In the end we approach a Poincaré plane. The kaleidoscopes of the last post are thus actually limits of the kind (∞,n,m).

Note added on the 16 December 2017: These kaleidoscopes use Möbius triangles, which are Schwarz triangles with integer rotation number. Reflections at the sides of a Möbius triangle generate the triangle group and make a tiling of an elliptic, Euclidean or hyperbolic plane.