# How do I map the torus to a plane?

A bit of background. Imagine a solid texture, like an actual block of sky and cloud. If you "cut a sheet" of sky and display it as an image, you'd get something like this:

Now you want that "sheet of sky" to be repeatable, so you cut the sheet of sky by using a torus:

I'm trying to remove the distortion that appears in the resulting image:

Because clearly the portion from the inner side of the donut is "thinner" than the outer side of the donut.

So I need to map the surface of a torus to a unit square. I'm not sure how to say this correctly but the mapping must be such that each tiny square $dS$ on the unit square must map to something non-square on the surface of the torus.

For a start, I looked at trying a mapping from u, v to spherical coordinates..

$$\theta = 2 \cos^{-1} \sqrt{1-\zeta_x} \\ \phi = 2\pi\zeta_y$$

But that didn't seem to lead to a solution.

-
Why so complicated? As given in the top-rated answer to the linked question, you can embed a torus in 4D space with no distortion at all. Is there some reason that you want 3D space specifically? – Lopsy Feb 10 '12 at 23:58
Because I'm interested in the problem – bobobobo Feb 11 '12 at 1:24

Everything below assumes that you have already cut two seams on the torus, so that it is homeomorphic to the unit square.

There is no local isometry (i.e. a map that preserves local distances and angles) between the torus and the unit square, or any flat domain for that matter. This is a consequence of Gauss's Theorema Egregium and the fact that the Gaussian curvature of the torus is not everywhere zero. Therefore, an infinitesimal patch in the unit square will have to get stretched, squeezed, or sheared when mapped to the torus. The Theorema Egregium is the same reason why you can't flatten a sphere without distortion, making a perfect map of the Earth impossible.

There is, however, a conformal map (i.e. a map that preserves angles but may not preserve lengths) between the torus and a flat rectangle. What this means is that you won't get the "stretching" sort of distortion you can see near the edges of your image, but the texture will look bigger in some places and smaller in others. A nice example is the first figure on CGAL's page on planar parameterization; observe that the squares remain squarish instead of being squeezed into rectangles or parallelograms. For the torus, a nice explicit formula should be possible if that's what you want.

-
One who is not convinced of Theorema Egregium might want to try wrapping a donut sometime... you'll find that you'll have to crumple or tear in a few places to wrap properly. – J. M. Feb 11 '12 at 2:54
Thanks for this interesting answer. – bobobobo Feb 11 '12 at 4:08

Distortion is inevitable by virtue of Gauss Egregium theorem.

Fwiw, I suggest the following:

For portions visible from torus center O and for portions invisible from O : At first project points on torus onto a circle/sphere of inversion with radius of inversion at horizon H, centers coinciding. Again use stereographic inversion from North Pole to map/transfer to either side i.e., the top and bottom sides of an annular plate whose inner and outer radii are set by horizon circle projections.

The mapping function can be found out from the diagram:

.

-