Use exact barycentric weights to decide whether a point is inside a triangle.

Example

Use barycentric weights to decide whether a point is inside a triangle.

highlighted = computed this step

Step 1 — Set up

Set up the triangle and test point.

A=(1,1), B=(6,1), C=(2,5), P=(3,2)A=(1,1),\ B=(6,1),\ C=(2,5),\ P=\hlmath{(3,2)}
Barycentric triangle testTriangle vertices and the point classified by barycentric weights.ABCP

Step 2 — Compute alpha

Compute alpha from the area ratios.

α=25\alpha=\frac{2}{5}
Barycentric triangle testTriangle vertices and the point classified by barycentric weights.ABCP

Step 3 — Compute beta

Compute beta from the area ratios.

β=720\beta=\frac{7}{20}
Barycentric triangle testTriangle vertices and the point classified by barycentric weights.ABCP

Step 4 — Compute gamma

Compute gamma from the area ratios.

γ=14\gamma=\frac{1}{4}
Barycentric triangle testTriangle vertices and the point classified by barycentric weights.ABCP

Step 5 — Check the sum

Check that the three weights sum to one.

α+β+γ=25+720+14=1\alpha+\beta+\gamma=\frac{2}{5}+\frac{7}{20}+\frac{1}{4}=1
Barycentric triangle testTriangle vertices and the point classified by barycentric weights.ABCP

Step 6 — Result

State the inside or outside verdict.

inside\text{inside}
Barycentric triangle testTriangle vertices and the point classified by barycentric weights.ABCP
barycentric-on-triangle Barycentric weights describe a point as a weighted mix of the triangle vertices. If the weights sum to one and stay nonnegative, the point is inside or on the triangle.