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
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
Fong followed by Lambers provide an alternate formulation intended to be computationally friendly. Note that we can reformulate the scale factor
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
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
and for
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
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.
Concentric
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
The Jacobian for
The Jacobian for
The determinant of both are constant
The disc to square map:
Where
In either case the range of
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:
Elliptical
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:
where:
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
or leave the half inside:
The Jacobian for
and the determinate:
The Jacobian for
and the determinate:
and the heat map of area distortion. Recall equal area value is
Approximate area preserving (variant 2)
In another post9 we have a volume preserving map between cylinder and sphere which breaks the space into two parts: point inside and outside of the embedded conic. We can take a planar slice through the cylinder’s axis to form a square to disc map. Reducing the 3D equation to the slice gives:
We can rewrite the
and re-express the
The Jacobian for for the cases are:
with the determinates:
The area distortion:
For the disc to square map, start with a common term:
then the map is:
References and Footnotes
-
“Analytical Methods for Squaring the Disc”, Chamberlain Fong, 2015. (PDF) ↩ ↩2 ↩3
-
“Analytical Methods for Squaring the Disc (presentation slides)”, Chamberlain Fong, 2014. (link) ↩
-
“Mappings between Sphere, Disc, and Square”, Martin Lambers, 2016. (link) ↩
-
A reasonable(ish) epsilon for the funcs here under generic usage is the smallest normal fp value (single:
). ↩ ↩2 -
“A Low Distortion Map Between Disk and Square”, Peter Shirley, Kenneth Chiu, 1997. (PDF) ↩
-
“Improved code for concentric map”, Peter Shirley’s blog, 2011. (link) ↩
-
“Mapping a Square to a Circle”, Philip Nowell, 2005. (link) ↩