// The chart is the input: baryPoints is [P, A, B, C], the blue point and the
// red triangle's corners, and every move re-runs the cells that read it.
viewof baryPoints = VM.plotting.draggablePoints(baryPlot, {
value: [{x: 0.3, y: 0.4}, {x: 1.5, y: 0}, {x: 3, y: 0}, {x: 2, y: 1}],
label: ["Blue point", "Corner A", "Corner B", "Corner C"],
color: ["var(--vm-color-fn)", "var(--vm-color-alt)", "var(--vm-color-alt)", "var(--vm-color-alt)"],
xBounds: baryXRange, yBounds: baryYRange,
step: {x: 0.01, y: 0.01},
constrain: (p, index) => index === 0 ? intoStandard(p) : p,
format: (p, index) => {
if (index > 0) return `x ${p.x.toFixed(2)}, y ${p.y.toFixed(2)}`
const w = weightsOf(p)
return `i ${w.i.toFixed(2)}, j ${w.j.toFixed(2)}, k ${w.k.toFixed(2)}`
}
})Barycentric Coordinates
Discrete Math
Geometry
Explore barycentric coordinates on a triangle, the setting for Sperner’s Lemma.
Barycentric coordinates are a coordinate system for describing points inside a triangle.
For a triangle with vertices \(A\), \(B\), and \(C\), any point \(P\) inside the triangle can be expressed as a weighted sum of the vertices: \[ P = iA + jB + kC \] where \(i\), \(j\), and \(k\) are the barycentric coordinates, satisfying \(i + j + k = 1\) and \(i, j, k \geq 0\). The barycentric coordinates can be interpreted as the relative areas of the sub-triangles formed with the point \(P\) and the vertices of the triangle.
Move the blue point around the triangle and watch how the barycentric coordinates change. The green point has the same coordinates in the red triangle; drag its vertices and watch it follow. With the keyboard, Tab to a point and use the arrow keys.
Consider the triangle with vertices \((0, 0)\), \((1, 0)\), and \((0, 1)\). A point \((x, y)\) lies inside this triangle exactly when: \[ 0 \le x, \quad 0 \le y, \quad \text{and} \quad x + y \le 1 \] In this case, we can write the point \((x, y)\) as: \[ \begin{bmatrix} x \\ y \end{bmatrix} = (1 - x - y) \begin{bmatrix} 0 \\ 0 \end{bmatrix} + x \begin{bmatrix} 1 \\ 0 \end{bmatrix} + y \begin{bmatrix} 0 \\ 1 \end{bmatrix} \] So the barycentric coordinates of \((x, y)\) are \((1 - x - y, x, y)\), all of which are non-negative and sum to 1.
Now all you need to do is map \((0, 0)\), \((1, 0)\), and \((0, 1)\) to the vertices \(A\), \(B\), and \(C\), respectively, via an affine transformation. Write \(T\) for the affine map sending \[ \begin{aligned} (0,0) &\mapsto A, \\ (1,0) &\mapsto B, \\ (0,1) &\mapsto C. \end{aligned} \] Being affine, \(T\) preserves weighted combinations whose coefficients sum to 1: \[ \begin{aligned} &T\big((1-x-y)(0,0) + x(1,0) + y(0,1)\big) \\ &= (1-x-y)\,T(0,0) + x\,T(1,0) + y\,T(0,1) \\ &= (1-x-y)A + xB + yC. \end{aligned} \] The left-hand side is just \(T(x, y)\), so the barycentric coordinates of \(T(x,y)\) with respect to \(A, B, C\) are exactly \((1-x-y, x, y)\) — the same triple as the barycentric coordinates of \((x,y)\) with respect to the standard triangle. This is why the formula transfers unchanged to any triangle.