Barycentric Coordinates: How do I keep track of Ratios

444 Views Asked by At

I am trying to write a java Program wich essentially lets a Point inside a given triangle move only in a straight line to one of the three corners (the specific corner being chosen randomly at every move), covering half the distance between its current point and the corner. For that i am using Barycentric coordinates (and it is my first time using them, so be gentle).

But now i have problems in calculating how the barycentric coordinates change with each move.

So the coordinate for the corner i am moving TO is easy, being

current + (1 - current)/2

so inside the triangle the barycentric coordinates always add up to 1, right? so the value added to the coordinate of the point were moving to has to be subtracted from the other two values. As i have now understood from other questions that the ration between those two values has to always stay the same.

But how do i do that? I tried a lot but i dont seem to find a formula to make those values right...

I would be extremely happy if someone would give me an idea how to solve this little problem.

1

There are 1 best solutions below

0
On

The second diagram in the Wolfram MathWorld entry for barycentric coordinates (reproduced below), illustrates that the barycentric coordinates of a point are proportional to the areas of the three sub-triangles created by it.

enter image description here

When the coordinates are normalized so that $t_1+t_2+t_3=1$, these are exactly the ratios of the areas of the sub-triangles to the total area.

Let’s say that we move $P$ to $P'$, halfway to vertex $A_1$, as illustrated above. It’s clear from the diagram that this halves the altitudes of the triangles that correspond to the second and third coordinates $t_2$ and $t_3$, so the corresponding coordinates of $P'$ are just those of $P$ divided by 2. You’ve already determined that $t_1'=t_1+(1-t_1)/2=(t_1+1)/2$, so we can write this transformation of the normalized barycentric coordinates of $P$ in the succinct form $$[t_1:t_2:t_3]\mapsto\frac12[t_1+1:t_2:t_3].$$ You can verify for yourself that no normalization of the result is necessary. To move toward a different vertex, add one to the corresponding coordinate instead.