Triangles

Barycentric Coordinates and Locating Points Inside a Triangle

Describe any point by three weights on a triangle's corners, then test inclusion, find ratios and blend values.

Key takeaways

  • Every point in the plane of a triangle has exactly one set of weights α, β, γ with sum 1.
  • Each weight equals a signed area ratio, such as area PBC divided by area ABC for α.
  • A point is inside the triangle exactly when all three weights are positive.
  • The centroid is (1/3, 1/3, 1/3), and other triangle centers have weights built from the side lengths.
  • Values given at the corners can be blended across the triangle with the same weights.

Barycentric coordinates describe a point by three weights attached to the corners of a triangle. If the weights are α, β and γ and they add to 1, the point is P = αA + βB + γC. Each weight tells you how strongly P leans toward that corner.

The weights are also area fractions, which makes them easy to compute and to picture. Once you have them, you can tell at a glance whether a point is inside the triangle, how it divides the lines through the corners and what value to assign it when numbers are known only at the vertices.

The balancing picture

Imagine a weightless triangular plate with small masses at the corners. Put mass α at A, β at B and γ at C. The plate balances at one point, and that point is P. The word barycentric comes from a Greek root meaning heavy, and August Möbius developed the idea systematically in 1827.

Putting all the mass at A places P at A, so A is (1, 0, 0). Equal masses at A and B and none at C place P at the midpoint of AB, written (1/2, 1/2, 0). Equal masses everywhere give (1/3, 1/3, 1/3).

Only the ratios of the masses matter for the balance point. So you may write coordinates as (2 : 3 : 1), with colons, and divide by the total, here 6, when you need weights that add to 1. Mass point geometry is this physical picture used as a problem-solving tool.

Weights as areas

Join P to the three corners. You get three smaller triangles. The one opposite A is PBC, and:

α = area PBC / area ABC
β = area PCA / area ABC
γ = area PAB / area ABC

Why? The triangle PBC and the triangle ABC share base BC, so their area ratio equals the ratio of their heights above that line. The height above BC is zero at B and C and full at A. In the formula P = αA + βB + γC, only the A term lifts the point off line BC, and it lifts it by the fraction α.

This is an instance of comparing areas of triangles with a shared base or height.

Signs and regions

Use signed areas: positive when the corners are listed counterclockwise and negative when clockwise. Then the formulas hold for every point in the plane, and the three signed pieces always add up to the whole.

Signs of (α, β, γ) Where P is
all positive inside the triangle
one zero, two positive on a side, between the corners
two zeros, one equal to 1 at a corner
one negative, two positive beyond one side, facing that side
two negative, one positive beyond a corner, between the side lines extended

All three cannot be negative, because they add to 1. The three side lines cut the plane into seven regions, and the sign patterns label them, one pattern per region.

A worked example

Take A = (0, 0), B = (6, 0), C = (0, 3) and P = (3, 1). The area of ABC is 9. For a triangle with corner P, use half the cross product of the vectors from P to the other two corners.

area PBC: vectors (3, −1) and (−3, 2):  (3·2 − (−1)(−3))/2 = 1.5
area PCA: vectors (−3, 2) and (−3, −1): ((−3)(−1) − 2·(−3))/2 = 4.5
area PAB: vectors (−3, −1) and (3, −1): ((−3)(−1) − (−1)·3)/2 = 3
α = 1.5/9 = 1/6,  β = 4.5/9 = 1/2,  γ = 3/9 = 1/3

The weights add to 1. Check the position: (1/6)(0, 0) + (1/2)(6, 0) + (1/3)(0, 3) = (3, 1). All three are positive, so P is inside.

Example weights of P = (3, 1) in triangle ABC
α, weight on A (area PBC) 16.7% β, weight on B (area PCA) 50% γ, weight on C (area PAB) 33.3% α, weight on A (area PBC) 16.7% β, weight on B (area PCA) 50% γ, weight on C (area PAB) 33.3%

Hypothetical example: the numbers are made up to show the method, not a quote or an average.

Testing whether a point is inside

The sign table turns a picture question into arithmetic, which is what a program needs. To decide whether P lies in triangle ABC:

  1. Compute the signed doubled areas of PBC, PCA and PAB.
  2. If all three have the same sign as the doubled area of ABC, the point is inside.
  3. If one is zero and the other two share that sign, it is on a side.
  4. Otherwise it is outside, and the odd sign tells you across which line.

No division is needed for the yes or no answer. Try the point Q = (5, 2) in the example triangle. The doubled area of QBC, using vectors (1, −2) and (−5, 1), is 1·1 − (−2)(−5) = −9. The doubled area of ABC is positive, so α is negative: Q lies beyond side BC. Indeed α = −9/18 = −1/2.

When a point is extremely close to a side, rounding in floating point arithmetic can give either sign. Careful software decides in advance how to treat edges, so that a pixel shared by two neighboring triangles is drawn once.

Solving directly from coordinates

There is also an algebraic route. Replace α with 1 − β − γ to get:

P − A = β(B − A) + γ(C − A)

This is a pair of linear equations, one for x and one for y, in two unknowns. In the example, (3, 1) = β(6, 0) + γ(0, 3), so β = 1/2 and γ = 1/3 at once. The system has exactly one solution whenever A, B and C are not on one line.

It also shows what β and γ mean: they are coordinates of P on a slanted grid whose axes run along AB and AC.

Lines through the corners

Extend AP until it meets BC at D. The barycentric coordinates make the ratios immediate:

BD : DC = γ : β
AP : PD = (β + γ) : α

In the example, BD : DC = (1/3) : (1/2) = 2 : 3, and AP : PD = (5/6) : (1/6) = 5 : 1. A segment from a corner to the opposite side is called a cevian, and multiplying the three side ratios for cevians through one point always gives 1, which is Ceva's theorem.

Lines in barycentric form

A straight line in the plane is the set of points whose weights satisfy one equation of the form uα + vβ + wγ = 0, with u, v and w not all equal. The line BC is simply α = 0. The median from A is β = γ, and the internal bisector from A is β/γ = b/c.

A line parallel to BC keeps α constant. In the example, every point with α = 1/6 sits one sixth of the way from line BC toward A, including P. Those points are exactly the triples (1/6, t, 5/6 − t) for any value of t.

Drawing the lines α = 1/4, 1/2 and 3/4, and the matching lines for β and γ, covers the triangle with a grid of small congruent triangles. Reading a point off that grid is like reading a map reference, and it is the idea behind the triangular charts used to plot mixtures of three ingredients.

Coordinates of triangle centers

Let a, b, c be the side lengths opposite A, B, C. Several centers have neat ratio coordinates.

Center Ratio coordinates
Centroid 1 : 1 : 1
Incenter a : b : c
Excenter opposite A −a : b : c
Symmedian point a² : b² : c²
Circumcenter a²(b² + c² − a²) : b²(c² + a² − b²) : c²(a² + b² − c²)

Try the incenter on a 3-4-5 triangle with C = (0, 0), B = (4, 0) and A = (0, 3). The sides are a = 4, b = 3 and c = 5. The weighted sum (4A + 3B + 5C)/12 is (12/12, 12/12) = (1, 1), and the inradius of this triangle is indeed 1.

Notice the circumcenter formula: when angle A is obtuse, b² + c² − a² is negative, so the first coordinate is negative and the center lies outside the triangle.

Blending values across a triangle

Suppose a quantity is known at the corners, such as temperature, height or one channel of a color. The linear estimate at P is the same weighted sum:

value at P = α·(value at A) + β·(value at B) + γ·(value at C)

With values 10, 40 and 70 at A, B and C in the example, P receives 10/6 + 20 + 70/3 = 45.

Graphics software does this for every pixel a triangle covers, blending vertex colors and texture positions. For surfaces seen in perspective, an extra correction for depth is applied, since screen weights and weights on the tilted surface differ. The same weights supply the inside test used in point-in-polygon work on meshes.

Three ingredients, one point

Any quantity split into three nonnegative shares that total a whole can be drawn as a point in a triangle. Soil scientists plot sand, silt and clay this way. A pure sample sits at a corner, a two-part mix sits on a side, and a balanced mix sits at the center.

On an equilateral triangle, the weights are proportional to the distances from the sides. The weight of an ingredient is the distance from the opposite side divided by the height. That the three distances always total the height is Viviani's theorem, and in this language it only says α + β + γ = 1.

Mixing two samples gives a point on the segment between them, placed closer to the sample used in the larger amount.

Why they travel well

Stretch, shear, rotate or slide the whole picture. Straight lines stay straight and area ratios stay the same, so the weights of P with respect to the moved triangle do not change. Maps with this property are called affine.

That means a statement about ratios proved for one convenient triangle holds for all of them. It does not mean lengths or angles are preserved, which is why centers such as the incenter need the side lengths in their coordinates while the centroid does not.

Common mistakes

  • Pairing a weight with the wrong small triangle. The weight for A uses the triangle that does not touch A.
  • Using unsigned areas for outside points, which makes the weights add to more than 1.
  • Forgetting to divide ratio coordinates by their total before taking weighted sums.
  • Expecting the weights to be proportional to distances from the corners. They are tied to distances from the sides, scaled by side length.

As an exercise, find the weights of the point (2, 1) in the same triangle. You should get 1/3 each, which identifies it as the centroid.

Written for 4Geometry with AI writing tools and not reviewed line by line by a person. Check anything you rely on against a textbook or primary source. Report an error.

Keep reading

All 57 articles in Triangles →

Latest news on this topic