0
$\begingroup$

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.

$\endgroup$
  • $\begingroup$ Is there any particular reason that you’re using barycentric coordinates? The movement is quite simple to compute in Cartesian. $\endgroup$ – amd Jun 22 '17 at 20:52
  • $\begingroup$ is it really? In my mind the barycentric version looked a lot more logical... and now it is a bit to late to change $\endgroup$ – Roman Leipe Jun 22 '17 at 20:56
  • $\begingroup$ In Cartesian coordinates, the midpoint of $P$ and $Q$ is simply $(P+Q)/2$. $\endgroup$ – amd Jun 22 '17 at 21:15
  • $\begingroup$ Barycentric coordinates are proportional the areas of the three sub-triangles formed by the point $P$, so look at what happens to the areas of the triangles that correspond to the other two coordinates when you shift $P$ toward a vertex. $\endgroup$ – amd Jun 22 '17 at 21:17
  • $\begingroup$ @amd youre absolutely right, and i am just amazed how i didnt see that and instead spent hours and hours on this... thank you very much $\endgroup$ – Roman Leipe Jun 22 '17 at 22:05
0
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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