How to parameterize the interior of a triangle

1.2k Views Asked by At

I would like to know how to parameterize a triangle over $[0,1] \times [0,1]$. I actually only care that the mapping is surjective but a bijection is always nice I suppose.

I found this in which an answer accidentally answers my question but when I check the result it doesn't seem to be correct. As I understand the proposition it states that $(u, v) \mapsto u\cdot A + v\cdot B + (1 - u - v)\cdot C$ where $A, B, C$ are the vertices of the triangle.

For instance take the triangle specified by the vertices $(0,0), (0, 1), (1, 0)$. If we follow though with the computations with $u = 1, v = 1$

$$1.0 \cdot (0,0) + 1.0 \cdot (0, 1) + (1.0 - 1.0 - 1.0)\cdot (1, 0) =$$ $$ (0, 1) - (1, 0) =$$ $$ (-1, 0) $$

which is not a point on the triangle that I mentioned. Did I make a mistake in my calculation? Have I misinterpreted the meaning of vertex here? If I have not made some kind of mistake, be it in calculation or interpretation, then

note: It has been noted that the linked parametrization maps the right triangle to any other triangle not the square requested. So is there a mapping of the unit square to the right unit triangle?

2

There are 2 best solutions below

7
On BEST ANSWER

The map $(u,v)\mapsto A+u(B-A)+uv(C-B)$ should work, but it is not bijective (all points of the form $(0,v)$ get mapped to the point $A$.

3
On

The parametrization that you found requires $u\ge0$, $v\ge0$, and $u+v\le1$. To handle the case $u+v\ge1$, you can apply the same parameterization but replacing coefficient $u$ with $1-u$ and coefficient $v$ with $ 1-v$ (since in that case $1-u+1-v\le1$, while $1-u$ and $1-v$ continue to be nonnegative). Then the coefficient $1-u-v$ becomes $u+v-1$. This ends up parameterizing the triangle twice over.