I am writing a Python script to make a ternary parametric plot. The domain of the parameters has to be rectangular so that it can be expressed as a 2D array, but the domain of the plot has to be an equilateral triangle.
Specifically I want to know if there is a (known) function
$$f: [0,1]^2\to T =\left\{(x, y)\in\mathbb R\Bigg| 1-\frac{y}{\sqrt 3}\geq x\geq\frac{y}{\sqrt 3}, \quad y\geq 0\right\}$$
Where the (unoriginally denoted "T" for triangle) set $T$ is an equilateral triangle of side one.
Preferably $f$ should be an isometry because that would save me from the effort of adjusting the mesh points to make them evenly spaced in the triangle. The corollary of Gauss's Theorema Egregium (i.e., "There is no isometry between surfaces with different Gaussian curvature") doesn't preclude the existence of such an isometry but does it really exist? If so, it would be great to have a specific formula.
In the event that such a map does not exist I would settle with any map between a rectangle and an equilateral triangle.
2 answers A) and B) :
A) A possible coordinate transformation from a square to an equilateral triangle is :
$$\binom{x}{y} \to \binom{x'}{y'}=\binom{(y-x)/2}{\sqrt{3}xy/2}\tag {1}$$
(add $+1/2$ to $x'$ in order to be in the triangle you are used to).
The following figure illustrates this transformation on a family of ellipses :
The explanation comes from barycentric coordinates $(a,b,c)$ of a point $M$ with respect to a reference triangle, here $A(-1/2,0)$, $B(1/2,0)$, $C(0,\sqrt{3}/2)$.
Indeed, barycentric coordinates are known to be proportional to areas $MBC$, $AMC$ and $ABM$ (https://en.wikipedia.org/wiki/Barycentric_coordinate_system).
Which areas are we going to consider on the square ? See figure 2.
The areas we associate to point $(x,y)$ in the unit square are as shown on the figure (classical formulas for the area of a rectangle and for the area of a trapezoid).
It remains to use these areas as (normalized) barycentric coordinates of $M$ :
$$\binom{x'}{y'}=aA+bB+cC$$ $$=\dfrac12(x+1)(1-y)\binom{-1/2}{0}+\dfrac12(y+1)(1-x)\binom{1/2}{0}+xy\binom{0}{\sqrt{3}/2}$$
to obtain formulas (1).
B) Another rather straightforward answer of mine can be found here.