title: Bézier triangle
text: # Bézier triangle
  
  A Bézier triangle is a special type of Bézier surface that is created by (linear, quadratic, cubic or higher degree) interpolation of control points.
  
  ## nth-order Bézier triangle
  
  A general nth-order Bézier triangle has (n +1)(n + 2)/2 control points $α^iβ^jγ^k$ where i, j, k are non-negative integers such that i + j + k = n. The surface is then defined as
  
      $(\alpha s+\beta t+\gamma u)^{n}=\sum _{\begin{smallmatrix}i+j+k\,=\,n\\i,j,k\,\geq \,0\end{smallmatrix}}{n \choose i\ j\ k}s^{i}t^{j}u^{k}\alpha ^{i}\beta ^{j}\gamma ^{k}=\sum _{\begin{smallmatrix}i+j+k\,=\,n\\i,j,k\,\geq \,0\end{smallmatrix}}{\frac {n!}{i!j!k!}}s^{i}t^{j}u^{k}\alpha ^{i}\beta ^{j}\gamma ^{k}$
  
  for all non-negative real numbers s + t + u = 1.
  
  With linear order (n=1{\textstyle n=1}), the resulting Bézier triangle is actually a regular flat triangle, with the triangle vertices equaling the three control points. A quadratic (n=2{\textstyle n=2}) Bézier triangle features 6 control points which are all located on the edges. The cubic (n=3{\textstyle n=3}) Bézier triangle is defined by 10 control points and is the lowest order Bézier triangle that has an internal control point, not located on the edges. In all cases, the edges of the triangle will be Bézier curves of the same degree.
  
  ## Cubic Bézier triangle
  
  A cubic Bézier triangle is a surface with the equation
  
      ${\begin{aligned}p(s,t,u)=(\alpha s+\beta t+\gamma u)^{3}=\;&\beta ^{3}\,t^{3}+3\,\alpha \beta ^{2}\,st^{2}+3\,\beta ^{2}\gamma \,t^{2}u\;+\\&3\,\alpha ^{2}\beta \,s^{2}t+6\,\alpha \beta \gamma \,stu+3\,\beta \gamma ^{2}\,tu^{2}\,+\\&\alpha ^{3}\,s^{3}+3\,\alpha ^{2}\gamma \,s^{2}u+3\,\alpha \gamma ^{2}\,su^{2}+\gamma ^{3}\,u^{3}\end{aligned}}$
  
  where $α^3,$ $β^3,$ $γ^3,$ $α^2β,$ $αβ^2,$ $β^2γ,$ $βγ^2,$ $αγ^2,$ $α^2γ$ and αβγ are the control points of the triangle and s, t, u (with 0 ≤ s, t, u ≤ 1 and s + t + u = 1) are the barycentric coordinates inside the triangle.
  
  Alternatively, a cubic Bézier triangle can be expressed as a more generalized formulation as
  
      ${\begin{aligned}p(s,t,u)&=\sum _{\begin{smallmatrix}i+j+k\,=\,3\\i,j,k\,\geq \,0\end{smallmatrix}}{3 \choose i\ j\ k}s^{i}t^{j}u^{k}\alpha ^{i}\beta ^{j}\gamma ^{k}=\sum _{\begin{smallmatrix}i+j+k\,=\,3\\i,j,k\,\geq \,0\end{smallmatrix}}{\frac {6}{i!j!k!}}s^{i}t^{j}u^{k}\alpha ^{i}\beta ^{j}\gamma ^{k}\end{aligned}}$
  
  in accordance with the formulation of the § nth-order Bézier triangle.
  
  The corners of the triangle are the points $α^3,$ $β^3$ and $γ^3.$ The edges of the triangle are themselves Bézier curves, with the same control points as the Bézier triangle.
  
  By removing the γu term, a regular Bézier curve results. Also, while not very useful for display on a physical computer screen, by adding extra terms, a Bézier tetrahedron or Bézier polytope results.
  
  Due to the nature of the equation, the entire triangle will be contained within the volume surrounded by the control points, and affine transformations of the control points will correctly transform the whole triangle in the same way.
  
  ### Halving a cubic Bézier triangle
  
  An advantage of Bézier triangles in computer graphics is that dividing the Bézier triangle into two separate Bézier triangles requires only addition and division by two, rather than floating point arithmetic. This means that while Bézier triangles are smooth, they can easily be approximated using regular triangles by recursively dividing the triangle in two until the resulting triangles are considered sufficiently small.
  
  The following computes the new control points for the half of the full Bézier triangle with the corner $α^3,$ a corner halfway along the Bézier curve between $α^3$ and $β^3,$ and the third corner $γ^3.$
  
      ${\begin{pmatrix}{\boldsymbol {\alpha ^{3}}}{'}\\{\boldsymbol {\alpha ^{2}\beta }}{'}\\{\boldsymbol {\alpha \beta ^{2}}}{'}\\{\boldsymbol {\beta ^{3}}}{'}\\{\boldsymbol {\alpha ^{2}\gamma }}{'}\\{\boldsymbol {\alpha \beta \gamma }}{'}\\{\boldsymbol {\beta ^{2}\gamma }}{'}\\{\boldsymbol {\alpha \gamma ^{2}}}{'}\\{\boldsymbol {\beta \gamma ^{2}}}{'}\\{\boldsymbol {\gamma ^{3}}}{'}\end{pmatrix}}={\begin{pmatrix}1&0&0&0&0&0&0&0&0&0\\{1 \over 2}&{1 \over 2}&0&0&0&0&0&0&0&0\\{1 \over 4}&{2 \over 4}&{1 \over 4}&0&0&0&0&0&0&0\\{1 \over 8}&{3 \over 8}&{3 \over 8}&{1 \over 8}&0&0&0&0&0&0\\0&0&0&0&1&0&0&0&0&0\\0&0&0&0&{1 \over 2}&{1 \over 2}&0&0&0&0\\0&0&0&0&{1 \over 4}&{2 \over 4}&{1 \over 4}&0&0&0\\0&0&0&0&0&0&0&1&0&0\\0&0&0&0&0&0&0&{1 \over 2}&{1 \over 2}&0\\0&0&0&0&0&0&0&0&0&1\end{pmatrix}}\cdot {\begin{pmatrix}{\boldsymbol {\alpha ^{3}}}\\{\boldsymbol {\alpha ^{2}\beta }}\\{\boldsymbol {\alpha \beta ^{2}}}\\{\boldsymbol {\beta ^{3}}}\\{\boldsymbol {\alpha ^{2}\gamma }}\\{\boldsymbol {\alpha \beta \gamma }}\\{\boldsymbol {\beta ^{2}\gamma }}\\{\boldsymbol {\alpha \gamma ^{2}}}\\{\boldsymbol {\beta \gamma ^{2}}}\\{\boldsymbol {\gamma ^{3}}}\end{pmatrix}}$
      equivalently, using addition and division by two only,
      ${\begin{matrix}&&\beta ^{3}:=(\alpha \beta ^{2}+\beta ^{3})/2\\&\alpha \beta ^{2}:=(\alpha ^{2}\beta +\alpha \beta ^{2})/2&\beta ^{3}:=(\alpha \beta ^{2}+\beta ^{3})/2\\\alpha ^{2}\beta :=(\alpha ^{3}+\alpha ^{2}\beta )/2&\alpha \beta ^{2}:=(\alpha ^{2}\beta +\alpha \beta ^{2})/2&\beta ^{3}:=(\alpha \beta ^{2}+\beta ^{3})/2\\\end{matrix}}$ ${\begin{matrix}&\beta ^{2}\gamma :=(\alpha \beta \gamma +\beta ^{2}\gamma )/2\\\alpha \beta \gamma :=(\alpha ^{2}\gamma +\alpha \beta \gamma )/2&\beta ^{2}\gamma :=(\alpha \beta \gamma +\beta ^{2}\gamma )/2\\\end{matrix}}$ $\beta \gamma ^{2}:=(\alpha \gamma ^{2}+\beta \gamma ^{2})/2$
      where := means to replace the vector on the left with the vector on the right.
      Note that halving a Bézier triangle is similar to halving Bézier curves of all orders up to the order of the Bézier triangle.
  