Distance between two barycentric coordinates

Let the barycentric coordinates be $(u,v,w)$ with as usual $u+v+w=1.$ If your point is interior to (or on the edge of ) the triangle we also have $u,v,w \ge 0.$

Now if we choose to map to the equilateral triangle in the $x,y$ plane with vertices $A'=(-1,0),\ B'=(1,0),\ C'=(0,\sqrt{3})$ then the barycentric point $X:(u,v,w)$ gets mapped into $u\cdot (-1,0)+v\cdot(1,0)+w \cdot(0,\sqrt{3})$ i.e into $$X':(v-u, w\sqrt{3}).$$ In particular the barycentric $P(1/3,1/3,1/3)$ ends up at $P':(0,(1/3)\sqrt{3}).$ Then the distance from $X'$ to $P'$ by the usual distance formula sqrt[(delta x)^2+(delta y)^2] becomes $$d(X',P')=\sqrt{(v-u)^2+3\cdot(w-1/3)^2}.$$


For aesthetic reasons I'm not happy with the asymmetry in the currently accepted solution by coffeemath. So let's try a different approach.

For a point with barycentric coordinates $(u,v,w)$ satisfying $u+v+w=1$ the point in the triangle is $uA+vB+wC$. Likewise a second point $(u',v',w')$ would be at $u'A+v'B+w'C$ and their difference vector would be $(u-u')A+(v-v')B+(w-w')C$.

Now I want to do this with complex numbers, using $\zeta_3=e^{i2\pi/3}$ as a third root of unity. So you can use $A=1,B=\zeta_3,C=\zeta_3^2=\zeta_3^{-1}$. The distance vector is represented by $d=(u-u')+(v-v')\zeta_3+(w-w')/\zeta_3$. Using $\lvert d\rvert^2=d\cdot\bar d$ we compute

\begin{align*} \lvert d\rvert^2&= \bigl((u-u')+(v-v')\zeta_3+(w-w')/\zeta_3\bigr)\bigl((u-u')+(v-v')/\zeta_3+(w-w')\zeta_3\bigr) \\&= (u-u')^2+(v-v')^2+(w-w')^2\\&\quad-(u-u')(v-v')-(v-v')(w-w')-(w-w')(u-u') \end{align*}

This is the distance in an equilateral triangle of edge length $\lvert 1-\zeta_3\rvert=\sqrt3$. For a triangle of unit edge length the squared length needs to be divided by $3$, so you can compute the distance as

$$\sqrt{\frac{(u-u')(u-u'-v+v')+(v-v')(v-v'-w+w')+(w-w')(w-w'-u+u')}3}$$

In the case of $u'=v'=w'=\frac13$ this becomes

\begin{gather*} \sqrt{\frac{(u-\tfrac13)(u-v)+(v-\tfrac13)(v-w)+(w-\tfrac13)(w-u)}3} \\= \frac13\sqrt{(3u-1)(u-v)+(3v-1)(v-w)+(3w-1)(w-u)} \end{gather*}

Now this formula looks quite different from what coffeemath wrote, why is that the case? On the one hand, he used a triangle of edge length $2$ not $1$ so we would expect twice the distances I got. On the other hand, neither formula makes use of the constraint $u+v+w=1$. If you substitute $w=1-u-v$ and scale my formula by $2$ then the (squared) formulas agree:

\begin{gather*} \frac49\bigl( (3u-1)(u-v)+(3v-1)(v-1+u+v)+(3(1-u-v)-1)(1-u-v-u) \bigr) \\=4u^2+4uv+4v^2-4u-4v+\tfrac43=\\ (u-v)^2+3\left(1-u-v-\tfrac13\right)^2 \end{gather*}

Actually Stephen Nand-Lal had written an even better answer which he later deleted (but which I'll vote to undelete). There he computed the distance as

$$\sqrt{\left(u-\tfrac13\right)^2+\left(v-\tfrac13\right)^2+\left(w-\tfrac13\right)^2}$$

This works by simply taking $A=(1,0,0)$, $B=(0,1,0)$ and $C=(0,0,1)$ as the corners of the triangle. Sure, that's in 3-space, but as long as $u+v+w=1$ the point in question will lie in the plane spanned by these three points. This is the distance computed for a triangle of edge length $\lVert A-B\rVert=\sqrt2$ so for unit edge length you might want to write

$$\frac1{3\sqrt2}\sqrt{\left(3u-1\right)^2+\left(3v-1\right)^2+\left(3w-1\right)^2}$$