Sunday, 3 May 2009

mg.metric geometry - Distance of a barycentric coordinate from a triangle vertex

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-c^2=b^2-a^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}=uvec{A}+vvec{B}+wvec{C}$

No comments:

Post a Comment