Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

I have a triangle $ABC$ with side lengths $a,b,c$ (edges $BC, CA, AB$ respectively).

I have a point $p$ with barycentric coordinates $u:v:w$.

These are normalised: $u+v+w=1$. $1:0:0$ corresponds to point $A$, $0:1:0$ is $B$ etc.

Is there a simple expression for the distance $d$ of the point $p$ from $A$ ?

(My initial naive guess based on $d(1:0:0)=0, d(0:1:0)=b, d(0:0:1)=c$ was that $d$ was linear $d(u,v,w)=v*b+w*c$ but this is clearly wrong as in the case of an equilateral triangle $a=b=c=1$ it returns $d=2/3$ for the centroid ($u:v:w = 1/3:1/3:1/3$), when the correct answer should be $1/\sqrt 3$ (the radius of the circumscribed circle)).

share|improve this question
This question seems not suitable for MO (not research level, this only uses Pythagore theorem), please read the FAQ. There is a formula, that you can devise by assuming $A$ is at the origin, $B$ is on the $x$-axis. The coordinates of $C$ are then easy to compute in terms of $a,b,c$, than you get the coordinates of your point. The distance is then given by the usual Euclidean formula. –  Benoît Kloeckner Aug 25 '10 at 13:40
better yet, try it on math.stackexchange.com –  Suresh Venkat Aug 25 '10 at 14:12
Sorry! Was completely unaware of math.stackexchange.com! Suspected I was a bit out of my depth here. Can it be migrated over ? –  timday Aug 25 '10 at 14:30
not AFAIK. but it looks like you got an answer, so it's all good :) –  Suresh Venkat Aug 25 '10 at 17:46
add comment

5 Answers

up vote 2 down vote accepted

There isn't really a simple formula, but you can use vector methods. Let $\mathbf{a}$, $\mathbf{b}$ and $\mathbf{c}$ be position vectors of the vertices. A point $P$ with normalized barycentric coordinates $(u,v,w)$ has position vector $\mathbf{p}=u\mathbf{a}+v\mathbf{b}+w\mathbf{c}$. Therefore $\mathbf{p}-\mathbf{a}=v(\mathbf{b}-\mathbf{a})+w(\mathbf{c}-\mathbf{a})$. This leads to $$|AP|^2=v^2|AB|^2+w^2|AC|^2+2vw|AB||AC|\cos\alpha$$ where $\alpha$ is the angle at $A$. Of course one can express $|AB||AC|\cos\alpha$ in terms of the three side-lengths of the triangle using the cosine rule.

This shows that neither $|AP|$ nor $|AP|^2$ is a linear function of the barycentric coordinates (actually this is geometrically evident too). But there is a simpler formula for the distance of $P$ to a given side of the triangle.

share|improve this answer
add comment

Robin gives the correct formula, but not in the simplest form. Since $$a^2=b^2+c^2-2bc\cos\alpha,$$ the desired distance satisfies $$d^2=(bw)^2+(cv)^2+vw(b^2+c^2-a^2).$$ A little manipulation also yields $$d^2=(bw-cv)^2+vw((b+c)^2-a^2)$$

share|improve this answer
add comment

Following from Benoît Kloeckner's comment above,

Place the points at $A=(0,0)$ at the origin, $B=(c,0)$ on the x-axis with the distance $|AB|=c$, and $C=(x,y)$, where we now want to satisfy $|AC|=b$ and $|BC|=a$.

Simple application of the Pythagorean theorem leads to

$x^2+y^2 = b^2$ and $(x-c)^2+y^2 = a^2$

as the two constraints to be applied.

Expanding and subtracting the two equations:

$x^2-2cx+c^2+y^2=a^2$ and $x^2 + y^2 =b^2$


$2cx = (b^2-a^2+c^2)$

$x = \frac{b^2-a^2+c^2}{2c}$

Now you can define $y$ in terms of $x$.

Simply scale the points $\vec{A}=(0,0), \vec{B}=(0,c)$, and $\vec{C}=(x,y)$ by their respective $(u,v,w)$ barycentric coordinates to get $D=(x_D,y_D)$ as a function of $a,b,c,u,v,w$, apply the Pythagorean theorem again to get $d = |\vec{D}|$ = the square root of $(x_d)^2 + (y_d)^2$. This last step shouldn't need to be spelled out for you, but $\vec{D}=u\vec{A}+v\vec{B}+w\vec{C}$

share|improve this answer
I would have added this as a comment, as Benoît Kloeckner did above; however, I did not have commenting ability at that time. Thus I replied as an answer. –  sleepless in beantown Aug 26 '10 at 7:13
add comment

So there is a paper A Hybrid GPU Rendering Pipeline for Alias-Free Hard Shadows

That claims to calculate the distance to a triangle $d(\omega,T)$ efficiently, they

resort to some tricks based on the concepts of barycentric coordinates

they describe the squared distance between a point $w$ and some vertex $v_i$ of the triangle $T$ as

$d(\omega,v_i)^2=\left\Vert \omega-v_{i}\right\Vert=\lambda_{i-1}^{2}\left\Vert e_{i-1}\right\Vert ^{2}+\lambda_{i+1}^{2}\left\Vert e_{i+1}\right\Vert ^{2}-2\lambda_{i-1}\lambda_{i+1}\left(e_{i-1}\cdot e_{i}\right)$

There is a derivation in the paper.

I think using the notation you described it'd look something like this

$d(p,A)^2=\left\Vert p-A\right\Vert=w^2b^2+v^2a^2-2wv(CA\cdot AB)$

but I'd check the math just to be sure

share|improve this answer
add comment

There actually is a delightful formula -- see page 11 at http://www.artofproblemsolving.com/Resources/Papers/Bary_full.pdf

Your displacement vector is (u-1,v,w), giving d^2=-(a^2vw+b^2w(u-1)+c^2v(u-1))

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.