This note is for some auxilary information on some maps between the disc and square. A fair amount of the math is convered by Fong1 2 and the survey by Lambers3. Specifically this contains:

  • A pair of animated plots between the various maps
  • Show the Jacobian matrices and determinates and visualize with interactive plots
  • Reduced complexity radial stretch in both directions
  • Reduced complexity concentric disc to square
  • Show a (perhaps) new radial approximate area preserving map

I will use the convention that $ \left(x,~y \right)$ is a coordinate on the square and $ \left(u,~v \right)$ a coordinate on the disc.

Define a signum like function:

Area distortion

This shadertoy is intended to visualize how shapes and angles are transformed under the various maps. Clicking through to the site allows interactivity.

Point set

As an alternate visualization this plot take uniform points on the square and shows how the various square to disc mappings transform the point set.

Radial Stretching

Simplest square to disc map is to simply stretch (scale factor of $L_1$ over $L_2$ norm):

Fong followed by Lambers provide an alternate formulation intended to be computationally friendly. Note that we can reformulate the scale factor $s$ applied to the input coordinate as the following pseudo-code:

float x2 = x*x;
float y2 = y*y;
float m  = x2 >= y2 ? x : y;
float s  = abs(m)*inversesqrt(x2+y2+epsilon);
// return s*(x,y)

where $\text{epsilon}$ is some sufficiently small constant4. Formulated in this manner only needs a single select/cmov like operation and no branching to handle all cases including degenerate.

A method to measure area distortion (growth/shrinkage) at infinitesimal around a point is to compute the Jacobian determinate5 of the function.

First we need the Jacobian, for $x^2 > y^2$:

and for $x^2 \leq y^2$

The determinates of these are respectively:

Combining these into a single expression gives:

The area of the square is 4 and that of the disc is $\pi$, so the value where no area distortion occurs is $\frac{\pi}{4} \approx 0.785398$. Larger/smaller values are the local stretch/compressing respectively. The plot of the area distortion (determinate):

The disc to square transform is simply inverting the scale factor:

and like above all cases can be handled with no branches and a single select.


Peter Shirley and Kenneth Chiu in 19976 derived an area preserving map between square to disc.

The square to disc map as given in Shirley’s blog post7 (modifications noted by Dave Cline):

Phase shift and pulling out signs:

The more interesting form will be architecture/code specific. The second form trig inputs are on $\pm\frac{\pi}{4}$, so the cosine terms are always positive and removable without sign fixup and a narrow enough range for light weight approximation.

The Jacobian for $\abs{x} \geq \abs{y}$:

The Jacobian for $\abs{x} < \abs{y}$:

The determinant of both are constant $\left(\frac{\pi}{4} \right)$ as expected for an area preserving map.

The disc to square map:

Where $\text{atan}$ is single parameter. This is degenerate when $v$ is approaching zero. This could be corrected by a select or since $\text{atan}$ is an odd function one possible rewrite choice is:

In either case the range of $\text{atan}$ in on $\pm 1$ so can be lightweight (for it) approximated. ($\epsilon$ is some small constant4 as above)

F.G. Squircle

Fong1 derivated mappings based on Fernandez-Guasti’s squircle.

The Jacobian:

The Jacobian determinate:

the plot of the area distortion (determinate):

The disc to square map:


The square to disc mapping was derived by Nowell in a blog post8:

The Jacobian:

The Jacobian determinate:

the plot of the area distortion (determinate):

Fong1 provides two derivations of the inverse map, one of which:


Approximate equal area

I haven’t been able to find this method referenced anywhere and a twitter query came up negative as well.

The basic idea here is to form a low complexity middle ground between radial stretch and concentric. See the point set animation above. As such it is only of interest if computationally cheaper than concentric and higher performance is a priority.

The disc to square map:

The square to disc map:

Which is degenerate when $y \le x $ and $y$ approaching zero. Since the division term is positive we can simply add a bias as before. More likely to be interesting is we can multiply through by the denominator and get:

or leave the half inside:

The Jacobian for $\abs{x} \geq \abs{y}$:

and the determinate:

The Jacobian for $\abs{x} < \abs{y}$:

and the determinate:

and the heat map of area distortion. Recall equal area value is $\frac{\pi}{4} \approx 0.785398$

References and Footnotes

  1. “Analytical Methods for Squaring the Disc”, Chamberlain Fong, 2015. (PDF 2 3

  2. “Analytical Methods for Squaring the Disc (presentation slides)”, Chamberlain Fong, 2014. (link

  3. “Mappings between Sphere, Disc, and Square”, Martin Lambers, 2016. (link

  4. A reasonable(ish) epsilon for the funcs here under generic usage is the smallest normal fp value (single: $2^{-126}$).  2

  5. “Jacobian matrix and determinant”, Wikipedia. (link

  6. “A Low Distortion Map Between Disk and Square”, Peter Shirley, Kenneth Chiu, 1997. (PDF

  7. “Improved code for concentric map”, Peter Shirley’s blog, 2011. (link

  8. “Mapping a Square to a Circle”, Philip Nowell, 2005. (link