# Homeomorphisms Between the Circular Disc and the Square

- 274 Downloads

## Abstract

The circle and the square are among the most common shapes used by mankind. Consequently, it is worthwhile to study the mathematical correspondence between the two. This chapter discusses three different ways of mapping a circular region to a square region and vice versa. Each of these mappings has nice closed-form invertible equations and different interesting properties. In addition, this chapter will present artistic applications of these mappings such as converting the Poincaré disk to a square as well as molding rectangular artworks into oval-shaped ones.

## Keywords

Conformal square Escheresque artworks Invertible mappings Non-Euclidean geometry Poincaré disk squircles## Introduction

*homeomorphism*is equivalence relation between two geometric objects that can be continuously deformed into one another. Two objects are homeomorphic if there is a continuous invertible mapping between them. An opt-repeated humorous example of this is the homeomorphism between the donut and the coffee cup. Joking aside, a coffee cup is not at all easy to define mathematically. Instead, this chapter will focus on two objects that are simple and well-defined mathematically – namely, the circular disc and the square. We shall study ways to map the circular disc to a square region and vice versa (Fig. 1).

Needless to say, there are infinitely many ways to map a circular disc to a square. Of particular interest to us are mappings with nice closed-form invertible equations. This chapter will discuss three such mappings. In addition, this chapter will also introduce and discuss different curious properties of these mappings. These properties include concepts such as uniform grids, radial constraints, and conformality. But before we proceed, this is an important lingering issue that needs to be addressed. This mathematical problem sounds all too familiar. Are we dealing with a classic problem in mathematics? Is this problem just “squaring the circle” under a modern guise?

Indeed, there is a famous classic problem in mathematics called “squaring the circle.” This well-known geometric construction problem involves using a straightedge and a compass to produce a circle and square with equal area. At first glance, our mapping problem seems similar to “squaring the circle.” However, the two problems are only superficially alike and ultimately quite different. Our mapping problem involves finding two-dimensional mapping equations that a computer can calculate, whereas the classic problem has to do with geometric construction using a draftsman’s tools.

## Canonical Mapping Space

*u*,

*v*) as a point contained in the unit disc and (

*x*,

*y*) as the corresponding point contained in the square after the mapping.

Mathematically speaking, we want to find functions *f* that maps every point (*u*, *v*) in the circular disc to a point (*x*, *y*) in the square region and vice versa. In others word, we want to derive equations for *f* such that (*u*, *v*) = *f*(*x*, *y*) and (*x*, *y*) = *f*^{−1}(*u*, *v*).

## Mapping Diagram with Equations

*Tapered2 Squircular*,

*Elliptical Grid*, and the

*Conformal Square mapping*. In order to illustrate the visual properties of these mappings, there are diagrams for a disc with a radial grid converted to a square. These appear on the left side of Fig. 3. Similarly, on the right side, there are diagrams for a rectilinear square grid converted to a circular disc. Each of these mappings has corresponding forward and inverse equations accompanying the diagrams. From here, one can observe that these equations come in varying degrees of mathematical sophistication.

For the Tapered2 Squircular mapping, it is convenient to use vector notation. In contrast, for the Conformal Square mapping, it is most appropriate to use complex numbers to come up with relatively compact equations. On the other hand, the Elliptical Grid mapping can be expressed simply by using plain algebraic equations. Each of these mappings will be discussed in more detail in the next section.

*sgn*(

*x*) and is defined as

## Some Mathematical Details

### Fernandez-Guasti Squircle

*s*that can be used to blend between the circle and the square smoothly. Figure 4 illustrates the Fernandez-Guasti squircle at varying values of

*s*.

The squareness parameter *s* can have any value between 0 and 1. When *s* = 0, the equation produces a circle with radius *r*. When *s* = 1, the equation produces a square with side length 2*r*. In between, the equation produces a smooth curve that is a geometric hybrid of the circle and the square.

### Tapered2 Squircular Mapping

A circular disc can be considered as a continuum of concentric circles. Likewise, a square region can be considered as a continuum of concentric squircles with increasing squareness. These concentric squircles become increasingly square-like as they approach the bounding rim. We shall denote this phenomena as the *squircular continuum* of the square.

*radial constraint*. In a nutshell, this means that points are only allowed to move radially during the mapping process. This is illustrated in Fig. 6.

By coupling the radial constraint with a nonlinear squircular continuum, it is possible to derive a set of equations for mapping the circular disc to a square. This is a geometric overview of how the Tapered2 Squircular mapping was derived. For more details, see Fong (2019).

The mapping equations provided in Fig. 3 are not exactly precise. In the interest of brevity, some important details were intentionally left out. For example, in the square-to-disc mapping equation, there are degenerate points that cause a division by zero. These degenerate points are located at the center and the four corners of the square. At these locations, the mapping equation results in the indeterminate form \(\frac {0}{0}\). However, the limiting value of the mapping for these points is well-defined.

### Lamé Squircle

*p*and

*r*. The power parameter

*p*allows the shape to interpolate between the circle and the square. When

*p*= 2, the equation produces a circle with radius

*r*. As

*p*→

*∞*, the equation produces a square with a side length of 2

*r*. In between, the equation produces a smooth planar curve that resembles both the circle and the square. Figure 7 shows the Lamé curve at increasing powers.

Although the Lamé squircle exhibits qualitative similarities with the Fernandez-Guasti squircle, there is a major difference between the two. The Lamé squircle can only approximate the square. It requires an infinite exponent in order to fully realize the square. Moreover, since the polynomial equation for the Lamé curve has unbounded exponents, it is unwieldy and difficult to manipulate algebraically. Nevertheless, the Lamé squircle can be used as groundwork for devising another disc-to-square mapping.

*x*and

*y*coordinates of points on the curve can be specified in terms of parameter

*t*. The parametric equations are

This mapping based on the Lamé squircle has several undesirable properties that make it less useful than the other mappings shown in Fig. 3. For one thing, explicit inverse equations are not provided. It is quite likely that there are no closed-form equations for expressing the inverse mapping. This means that the inverse mapping can only be computed using iterative root-solving techniques in numerical analysis.

Another egregious property of this mapping is that it only works on the open circular disc and the open square region. This means that mapping does not include the circular boundary of the disc or the rim of the square region. Mathematically, the domain of the mapping is the open circular disc {(*u*, *v*)|*u*^{2} + *v*^{2} < 1}, and the range of the mapping is the (−1, 1) × (−1, 1) open square region.

### Elliptical Grid Mapping

Essentially, for each vertical line segment of constant *x* inside the square, there is a corresponding equation of an ellipse centered in the circle. The bounds, eccentricity, and semi-major and semi-minor axial lengths of this ellipse vary depending on the value of x. Specifically, the left and right vertex tips of the ellipse follow the value of *x*. Meanwhile, the top and bottom vertex tips vary as \(\pm \sqrt {2-x^2}\).

Essentially, for each horizontal line segment of constant *y* in the square, there is a corresponding equation of an ellipse centered in the circle. The bounds, eccentricity, and semi-major and semi-minor axial lengths of this ellipse vary depending on the value of y. Specifically, the top and bottom vertex tips of the ellipse follow the value of *y*. Meanwhile, the left and right vertex tips vary as \(\pm \sqrt {2-y^2}\).

Note that the ellipses get more and more eccentric as *x* or *y* approach zero. Also, the ellipses get more circular as x or y approach ± 1.

*u*and

*v*in terms of

*x*and

*y*. This can be done by starting with the vertical constraint equation and doing some algebraic manipulations to isolate

*u*

^{2}.

*u*

^{2}value into the horizontal constraint equation

*x*

^{2})(2 −

*y*

^{2})

*y*

^{2}to remove fractions and get

*v*

^{2}into one side of the equation

It is also possible to derive the inverse equations for this mapping, but the algebraic manipulation needed is much more elaborate. Instead, we refer the reader to Fong (2014) for a lengthy derivation of denested inverse equations.

### Conformal Square Mapping via Schwarz-Christoffel

A conformal mapis a mapping that preserves angles between geometric features after the mapping operation is performed. In other words, a conformal mapping does not distort angles. This section will discuss a disc-to-square mapping that is conformal. However, in order to do this, we need to take a small detour through the complex plane beforehand and discuss some theory first.

One of the most celebrated results in nineteenth-century complex analysis is the Riemann mapping theorem (Frederick and Schwarz, 1990). It states that there exists a conformal map between the open unit disc and every simply connected subset of the complex plane. Moreover, it states that this conformal map is unique if we fix a point and the orientation of the mapping. In theory, the Riemann mapping theorem is nice, but it is only an existence theorem. It does not specify how to find the conformal mapping. The next important breakthrough came with the works of Hermann Schwarz and Elwin Christoffel. In the 1860s, Schwarz and Christoffel independently developed a formula for a conformal mapping between the unit disc and simple polygonal regions in the complex plane. The formula is complicated and involves an integral in the complex plane.

Furthermore, for most polygons, the integral can only be approximated numerically. Fortunately, for the special case of the square, the Schwarz-Christoffel formula can be reduced to an explicit analytical expression involving complex-valued elliptic integrals and elliptic functions (Langer and Singer, 2011).

#### Legendre Elliptic Integrals

It is appropriate to make a segue here and briefly discuss elliptic integrals and elliptic functions. Of particular interest to us are Legendre elliptic integralsand Jacobi elliptic functions. Specifically, we are interested in the incomplete Legendre elliptic integral of the first kind called *F* and its closely related inverse function, the Jacobi elliptic function *cn*.

Note that this integral cannot be simplified using any of the standard techniques covered in freshman calculus classes. This integral was originally studied in the context of measuring the arc length of an ellipse. That is the reason why it is called an elliptic integral (Rice and Brown, 2012).

The two arguments provided with this function are also intimately tied to the ellipse. The first parameter *ϕ* is some sort of angular parameter. It originates from the angle subtended by an arc of the ellipse. The second parameter *k* is closely related to the eccentricity of the ellipse.

*cn*can be considered as some sort of inverse to

*F*. Mathematically, it is related to

*F*by the following equation:

#### A Fundamental Conformal Map

*cn*on the complex plane. In essence, one could map every point inside the unit disc to a square region conformally by just an evaluation of the complex-valued Jacobi elliptic function

*cn*. Furthermore, the inverse of the mapping can be calculated using the incomplete Legendre elliptic integral of the first kind

*F*.

#### Canonical Alignment

*x*and

*y*coordinates are not in the canonical mapping space. Figure 13 shows a square with corner coordinates in terms of a constant

*K*

_{e}instead of the ± 1 that is desired. Moreover, the square is tilted by 45

^{∘}and off-center from the origin. In order to get this mapping into the canonical mapping space, one needs to perform a series of affine transformations on the square. These include centering the square to the origin and scaling it down to have a side length value of 2. In order to do this, one has to introduce a rotational factor for the 45

^{∘}tilt as well as

*K*

_{e}offsets and scale factors. This is exactly what happens in the explicit equations for the Conformal Square mapping. Basically, this is the canonized mapping equation in the complex plane

*is the complex number*

**z***x*+

*y*

**i**and * w* is the complex number

*u*+

*v*

*.*

**i**It is probably appropriate to explain the \(\sqrt {\pm i}\) factors that appear throughout the equations. These multiplicative constants are just a compact way of representing the ± 45^{∘} rotational adjustments needed to align the equations to the canonical mapping space in Fig. 2.

*e*

^{iθ}. For 45

^{∘}rotation, the multiplicative factor is

^{∘}rotation, the multiplicative factor is

#### Software Implementation

In order to implement this mapping on a computer, one needs to be able to calculate special functions such as *cn* and *F*. Source code for numerical computation of these functions is readily available in open-source libraries such as Boost and the GNU Scientific Library. Also, there is a reference implementation appearing in the popular Numerical Recipes book (Press et al., 1992).

One possible pitfall in software implementation is that the mapping requires complex-valued versions of the special functions. These complex variants are typically not included in open-source libraries. Nonetheless, these complex variants are well-defined mathematically. The formulas for computing complex-valued *cn* and *F* are given by L.M. Milne-Thomson in the classic AMS-55 reference book (Abramowitz and Stegun, 1972).

It is worth mentioning here that there are well-established fast and robust algorithms for computing the *F* and *cn* special functions (Carlson, 1977). As a matter of fact, Gauss has shown that elliptic integrals can be calculated quickly using the arithmetic-geometric mean (Hancock, 1958). It is suffice to say that these special functions can be calculated about as fast as standard trigonometric functions.

### A Complex Class of Squircles

The Fernandez-Guasti squircle was used as groundwork in the development of the Tapered2 Squircular mapping. This section will discuss using a similar idea but acting in reverse to derive another type of squircle. Specifically, one can start with the Conformal Square mapping and come up with a different type of squircle called the *complex squircle*.

Let us revisit the squircular continuum in Fig. 5 which was originally discussed in the derivation of the Tapered2 Squircular mapping. By working backward this time and starting from the Conformal Square mapping, it is possible to derive equations for a curve that is an intermediate shape between the circle and the square.

One can then intuitively surmise from Fig. 14 that the concentric shapes inside the square are some sort of squircular curve. Indeed, these concentric shapes exhibit all of the defining characteristics of a hybrid curve between the circle and the square. Therefore, it makes sense to classify them as yet another type of squircle – the *complex squircle*.

*e*

^{it}, with 0 ≤

*t*≤ 2

*π*. By applying the Conformal Square mapping on the circle, one can come up with a complex-valued function

*ψ*that serves as an auxiliary representation of the complex squircle.

*ψ* is a two-parameter complex function that is based on the disc-to-square equation of the Conformal Square mapping. The first argument *t* is used for curve parametrization. The second argument *q* is just a squareness parameter analogous to the *s* parameter of the Fernandez-Guasti squircle.

*ψ*function, the complex squircle can be defined as the curve arising from these parametric equations:

*q*and

*r*. The squareness parameter

*q*allows this shape to interpolate between the circle and the square. When

*q*= 0, the equation produces a circle with radius

*r*. When

*q*= 1, the equation produces a square with a side length of 2

*r*. In between, the equation produces a smooth planar curve that resembles both the circle and the square. This is shown in Fig. 15.

Three different types of squircles discussed in this chapter

Name | Squareness | Equation | Key property |
---|---|---|---|

Fernandez-Guasti squircle |
| \(x^2 + y^2 -\frac {s^2}{r^2}x^2 y^2 = r^2\) | Quartic polynomial equation |

Lamé squircle |
| | | Unbounded polynomial power |

Complex squircle |
| \(\begin {array}{c} \psi \scriptstyle (t,q)= 1-i-\frac {\sqrt {-2i}}{K_e} F(cos ^{-1} (q e^{it} \sqrt {i}),\frac {1}{\sqrt {2}}) \\ \\ x(t) \; = \; \Re [\psi (t , q)] \; \frac {r}{\psi (0 , q)} \\ y(t) \; = \; \Im [\psi (t , q)] \; \frac {r}{\psi (0 , q)} \end {array}\) | Complex parametric equations with parameter |

## Application: Squaring the Poincaré Disk

*Circle Limit IV*(1960). The pattern on the left is its conversion to a square.

In order to delve more into Escheresque artworks (Dunham, 2009), some mathematical background in non-Euclidean geometry is necessary. In particular, we need to discuss a type of non-Euclidean geometry called hyperbolic geometry. To make things simple, we shall restrict ourselves to a two-dimensional construct of hyperbolic geometry called the hyperbolic plane. One can intuitively think of the hyperbolic plane as a surface with negative curvature everywhere (Taimina, 2009). In contrast, the Euclidean plane is a flat surface with zero curvature everywhere.

This formulation is known as Playfair’s axiom. It is illustrated in the left diagram of Fig. 17. Meanwhile, hyperbolic geometry arises when Playfair’s axiom is overturned with the following statement:In a plane, given a line and a point not on it, at most one line parallel to the given line can be drawn through the point.

In a hyperbolic plane, given a line and a point not on it, there are several lines parallel to the given line than can be drawn through the point.

In order to qualify this statement in hyperbolic geometry, one needs to have well-defined and consistent notions of points, lines, and parallelism in the hyperbolic plane. First, let us introduce the Poincaré disk.

Mathematicians have come up with many different models of the hyperbolic plane in order to study hyperbolic geometry. The most popular model is probably the Poincaré disk. The Poincaré disk can be considered as some sort of projection of the hyperbolic plane onto a unit circular disc in the Euclidean plane. It has several interesting properties that make it desirable for representing the hyperbolic plane.

One important property of the Poincaré disk is that it presents the entire hyperbolic plane within the confines of a finite circular disc in IR^{2}. Every point in the hyperbolic plane is represented by a unique point inside the Poincaré disk. This makes it easy to visualize the entire hyperbolic plane within the model.

Another important property of the Poincaré diskis conformality. In a conformal model, the hyperbolic measure of angle is the same as the Euclidean measure of angle. In other words, this hyperbolic model does not distort angles. One can measure hyperbolic angles between geometric entities inside the Poincaré disk by simply making Euclidean angular measurements. Unfortunately, the same does not hold true for hyperbolic distance. Hyperbolic distances are greatly distorted in the Poincaré disk.

In the Poincaré disk model, the origin at (0, 0) lies at the center of the circular disc. The bounding circle at the rim of disc is infinitely far away from the origin. The hyperbolic distance of a point away from the origin gets larger and larger as the point gets closer to the bounding circle. As a consequence of this, geometric entities appear smaller as they approach the bounding circle.

One can think of the Poincaré disk in analogy to the Cartesian coordinate system. Just like the Cartesian coordinate system faithfully models the Euclidean plane, the Poincaré disk is a meaningful representation of the hyperbolic plane. The Cartesian coordinate system allows one to convert geometric statements about the Euclidean plane into algebraic equations. In a similar manner, the Poincaré disk allows one to do the same for the hyperbolic plane.

Hyperbolic entities in the Poincaré disk

Geometric entity | Corresponding feature inside the Poincaré disk |
---|---|

Hyperbolic point | This corresponds to a Euclidean point in the interior of the bounding circle of the Poincaré disk model |

Hyperbolic line | This corresponds to a circular arc orthogonal to the bounding circle. Circular arcs can be part of circles of arbitrary radius |

Hyperbolic angle | The angle between two hyperbolic lines is the same as the Euclidean angle between their corresponding circular arcs inside the Poincaré disk model |

Hyperbolic parallelism | Hyperbolic lines are parallel if and only if they do not intersect in the interior of the Poincaré disk model |

### Hyperbolic Tilings

The most relevant and appropriate way to convert the Poincaré disk to a square is via Conformal Square mapping. There is a very simple reason for this – conformality. Recall that the Poincaré disc model is a conformal model of the hyperbolic plane. It follows that the conformal square is a natural extension of the Poincaré disc to a square region. In essence, undistorted Euclidean angles in the Poincaré disk remain intact in the conformal square.

The two other mappings can also be used to convert the Poincaré disk to a square, but the results are less than stellar. For the Elliptical Grid mapping, the corners of the square appear as a muddled mess. Meanwhile, the Tapered2 Squircular mapping produces fairly decent results, but there is significant shape distortion of the octagons.

## Application: Elliptification of Rectangular Imagery

Most of the world’s photographs are rectangular. However, one might want to convert them into circular or elliptical images for artistic reasons. This section will extend the previously discussed square-to-disc mappings to handle ellipses and rectangles. After which, one can apply these mappings to rectangular artworks to produce elliptical ones. Henceforth, this process of molding a rectangle into an ellipse will be referred to as *elliptification*.

The artistic process of elliptification is not new. For centuries, artists would paint on oval-shaped canvases, and photographers would cut their pictures into oval regions. Creating oval-shaped artworks is an important form of artistic expression and stylization. This has traditionally been done by just cropping or cutting out the corner regions of the artwork.

*“A Bar at the Folies-Bergere”*(1882) converted into an oval region using the different mappings discussed in this chapter. The traditional process of simply cropping the picture to produce an oval region is quite unacceptable because it removes many noteworthy features near the corners of the painting. For example, observe that in Manet’s cropped painting, the bar patron with the top hat is gone. Also, the dangling legs of the trapeze artist at the top left corner of the painting are nowhere to be found. In contrast, the mathematically mapped paintings keep all these features intact, albeit distorted.

### Size Versus Shape Distortions

In differential geometry, two-dimensional distortion is generally categorized into two major types: size and shape distortions (Floater and Hormann, 2005). The elliptification of Manet’s painting highlights the difference between these two types of distortion. The stretched Schwarz-Christoffel based on the Conformal Square mapping has significant size distortions near the corner. This is quite evident by observing the dangling legs of the trapeze artist, which has shrunk to the point of being barely visible. In contrast, the Elliptical Grid mapping has significant shape distortions near the corner. Specifically, the gentleman with a top hat appears considerably deformed. On the other hand, the Tapered2 Squircular mapping offers a good compromise between size and shape distortions. It provides the best result among the three mappings for Manet’s painting. In fact, the circularized chessboard shown in Fig. 1 also uses the Tapered2 Squircular mapping. One can observe that the size and shape fidelity of the corner rooks is reasonably intact.

## Conclusion

This chapter discussed three explicit methods for mapping the circular disc to a square and vice versa. In addition, some artistic applications of these mappings were provided. For hyperbolic art, the Conformal Square mapping gives the best results. However, for other artistic applications such as elliptification, this is not necessarily the case because the mapping has sizeable distortions near the four corners.

## Cross-References

## References

- Abramowitz M, Stegun I (1972) Handbook of mathematical functions. Dover Publications Inc., New YorkzbMATHGoogle Scholar
- Carlson B (1977) Special functions of applied mathematics. Academic, New YorkzbMATHGoogle Scholar
- Dunham D (2009) Hamiltonian paths and hyperbolic patterns. Contemp Math 479:51–65MathSciNetCrossRefGoogle Scholar
- Fernandez-Guasti M (1992) Analytic geometry of some rectilinear figures. Int J Math Educ Sci Technol 23:895–901CrossRefGoogle Scholar
- Floater M, Hormann K (2005) Surface parameterization: a tutorial and survey. In: Dodgson N, Floater M, Sabin M (eds) Advances in multiresolution for geometric modelling. Springer, New York, pp 157–186CrossRefGoogle Scholar
- Fong C (2014) Analytical methods for squaring the disc. In: Seoul ICM 2014Google Scholar
- Fong C (2019) Elliptification of rectangular imagery. In: Joint mathematics meeting SIGMAA-ARTSGoogle Scholar
- Frederick C, Schwarz E (1990) Conformal image warping. IEEE Comput Graph Appl 10(2):54–61CrossRefGoogle Scholar
- Hancock H (1958) Elliptic integrals. Dover Publications Inc., New YorkzbMATHGoogle Scholar
- Langer J, Singer D (2011) The lemniscatic chessboard. Forum Geometricorum 11:183–199MathSciNetzbMATHGoogle Scholar
- Nowell P (2005) Mapping a square to a circle (blog). http://mathproofs.blogspot.com/2005/07/mapping-square-to-circle.html
- Press W, Flannery B, Teukolsky S, Vetterling W (1992) Numerical recipes in C. The art of scientific computing, 2nd edn. Cambridge University Press, CambridgezbMATHGoogle Scholar
- Rice A, Brown E (2012) Why ellipses are not elliptic curves. Math Mag 85(3):163–176MathSciNetCrossRefGoogle Scholar
- Shirley P, Chiu K (1997) A low distortion map between disk and square. J Graph Tools 2:45–52CrossRefGoogle Scholar
- Taimina D (2009) Crocheting adventures with hyperbolic planes. AK Peters, WellesleyCrossRefGoogle Scholar