In an affine space there’s the concept of affine combination which states that any point in space can be represented as a affine combination in the form
We can add an additional restriction on the values of $\lambda_i$ to define a triangle built out of three points, if $\lambda_1 = \beta, \lambda_2 = \gamma$, $\beta + \gamma = 1$ and $\beta, \gamma \in [0,1]$ then a triangle is defined as the affine combination
![barycentric coordinates](/images/triangle!barycentric.jpg)
barycentric coordinates
One geometric property of the scalar values is that they’re the signed scaled distance from the lines that pass through the triangle sides, to compute the scalar values $\beta$ and $\gamma$ we can use the fact that when the implicit equation of the line that pass through a side is evaluated with points that don’t lie on the line the result is equal to
![beta](/images/triangle!beta.jpg)
beta
Where $d_{(x,y)}$ is the distance from the point $(x,y)$ to the line, $A$ and $B$ are the coefficients of $x$ and $y$ of the general equation of the line that passes through $a$ and $c$
To find the value of $\beta$ we can use the value of the implicit equation of the line to map the distance between any point to the line in the range $[f_{ac}(x_a, y_a), f_{ac}(x_b, y_b)] = [0, f_{ac}(x_b, y_b)]$, we can use a simple division to find the value of $\beta$
In a similar fashion the value of $\gamma$ is
References
- Shirley, P. and Ashikhmin, M. (2005). Fundamentals of computer graphics. Wellesley, Mass.: AK Peters.