**barycentric coordinates** are also often referred to as

area coordinates. They are extremely useful in

mathematics and

engineering, being used often for the

evaluation of

functions over

triangles.

Consider a triangle defined by the three vertexes **v**_{1},
**v**_{2} and **v**_{3.} Any point **r** inside that triangle can be written in terms of barycentric coordinates β_{1}, β_{2} and β_{3} as

r = β_{1} **v**_{1} + β_{2} **v**_{2} + β_{3} **v**_{3}

where the barycentric coordinates are constrained by the relationship

β_{1} + β_{2} + β_{3} = 1

This operation represents a linear interpolation of the triangle's three vertex coordinates. Any point inside the triangle may be found through each unique combination of barycentric coordinates.

Consider now that you have a triangle as defined above, and some scalar function P defined only at each vertex, i.e. you've got P_{1}, P_{2} and P_{3}, and you wish to interpolate a value at some point **r** inside the triangle. You can use the formula above to obtain the interpolated value P(**r**) if you find the barycentric coordinates for point **r**.

We can use the relationships above to solve for β_{1}, β_{2} and β_{3} in terms of vertex coordinates **v**_{1}, **v**_{2}, and **v**_{3}. Define the components of each vector as

**v**_{1} = (x_{1}, y_{1}, z_{1})

**v**_{2} = (x_{2}, y_{2}, z_{2})

**v**_{3} = (x_{3}, y_{3}, z_{3})

Given a known point (x, y, z) inside the triangle, the barycentric expansion is

x = β_{1} x_{1} + β_{2} x_{2} + β_{3} x_{3}

y = β_{1} y_{1} + β_{2} y_{2} + β_{3} y_{3}

z = β_{1} z_{1} + β_{2} z_{2} + β_{3} z_{3}

subject to the constraint

β_{1} + β_{2} + β_{3} = 1

This represents three equations in two unknowns, since

β_{3} = 1 - β_{1} - β_{2}

so, making this substitution

x = β_{1} x_{1} + β_{2} x_{2} + (1 - β_{1} - β_{2}) x_{3}

y = β_{1} y_{1} + β_{2} y_{2} + (1 - β_{1} - β_{2}) y_{3}

z = β_{1} z_{1} + β_{2} z_{2} + (1 - β_{1} - β_{2}) z_{3}

Rearranging, this is

β_{1}(x_{1} - x_{3}) +
β_{2}(x_{2} - x_{3}) + x_{3} - x = 0

β_{1}(y_{1} - y_{3}) +
β_{2}(y_{2} - y_{3}) + y_{3} - y = 0

β_{1}(z_{1} - z_{3}) +
β_{2}(z_{2} - z_{3}) + z_{3} - z = 0

Solving for β_{1} and β_{2} yields

β_{1} = (B*(F + I) - C*(E + H))/(A*(E + H) - B*(D + G))

β_{2} = (A*(F + I) - C*(D + G))/(B*(D + G) - A*(E + H))

where

A = x_{1} - x_{3}

B = x_{2} - x_{3}

C = x_{3} - x

D = y_{1} - y_{3}

E = y_{2} - y_{3}

F = y_{3} - y

G = z_{1} - z_{3}

H = z_{2} - z_{3}

I = z_{3} - z

and β_{3} is found from the other two.

If you find these relationships useful let me know.