Linear Algebra

Barycentric Coordinates

Express a point as affine triangle weights and use their signs to distinguish its interior, edges and exterior.

By Riano · Published · Updated · Report a correction

Barycentric Coordinates

Barycentric coordinates express any point p in the plane as a unique affine combination of three non-collinear triangle vertices v1, v2, and v3, directly encoding whether p lies strictly inside, on the boundary, or outside the triangle.

Affine Combinations and Signed Sub-Triangle Areas

For triangle vertices v1, v2, v3 in 2D, any point p can be written as p = λ1v1 + λ2v2 + λ3v3 subject to the affine normalization constraint λ1 + λ2 + λ3 = 1. By Cramer's rule, each weight λi equals the ratio of the signed area of the sub-triangle opposite vi to the signed area of the full triangle (v1, v2, v3).

Linear System and Point Classification

Solving the 3x3 linear system with rows [v1,x, v2,x, v3,x], [v1,y, v2,y, v3,y], and [1, 1, 1] requires a nonzero signed-area determinant det ≠ 0. Because each λi divides its sub-determinant by det, reversing vertex orientation from counter-clockwise to clockwise flips the sign of both numerator and denominator, leaving (λ1, λ2, λ3) invariant. Point p is classified as: Inside if all λi > 0; Boundary if all λi ≥ 0 and at least one λi = 0; and Outside if any λi < 0.

Worked Example

Find the barycentric coordinates of p = (0, 1) with respect to v1 = (-1, 0), v2 = (2, 0), and v3 = (0, 2):

  1. Set up the equations: x-coordinate: -λ1 + 2λ2 + 0λ3 = 0; y-coordinate: 0λ1 + 0λ2 + 2λ3 = 1; affine sum: λ1 + λ2 + λ3 = 1.
  2. Solve for λ3: From 2λ3 = 1, we obtain λ3 = 1/2 = 0.5.
  3. Solve for λ1 and λ2: Since λ1 = 2λ2 and λ1 + λ2 = 1/2, we get 3λ2 = 1/2 → λ2 = 1/6 and λ1 = 1/3.
  4. Classify: All three weights (1/3, 1/6, 1/2) are strictly positive and sum to 1, so p lies Inside the triangle.

Experiment

Explore interior interpolation, edge boundaries, exterior extrapolation, and collinear degeneracy in https://riano.app/module/barycentric-coordinates:

  1. Keep the default triangle (0,0), (3,0), (0,3) with p = (1,1) to verify equal weights (1/3, 1/3, 1/3) and classification Inside.
  2. Move Point x to 0 and Point y to 0 so p coincides with v1, yielding weights [1, 0, 0] and classification Boundary.
  3. Set collinear vertices (-1,-1), (0,0), (1,1) to verify that the singular system reports Degenerate and hides undefined weights as Unavailable.

Limitations

Barycentric coordinates are uniquely defined only when the simplex vertices are affinely independent (non-collinear in 2D). When vertices are collinear or repeated, the system matrix is singular and no unique affine coordinate representation exists.

Common Pitfalls

Using unsigned triangle areas instead of signed determinants fails to detect points outside the triangle (where at least one signed coordinate must be negative) and breaks when vertices are listed in clockwise order.

References

Affine simplex transforms and barycentric coordinate computation follow standard computational geometry references:

Experience it interactively

Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Barycentric Coordinates module.

Try Barycentric Coordinates on Riano →

More in Linear Algebra