# Gradient of the Barycentric Coordinate in 2D

I always forget this fact, so hopefully typing this out will help.

Let $T$ be a triangle with vertices $v_1, v_2, v_3$, then there exists unique linear functions $\lambda_i$ such that $\lambda_i(v_j) = \delta_{ij}$. This is the so called barycentric coordinates.

The fact here is that $\nabla \lambda_k = -\frac{|\gamma_k|}{2|T|}n_k$ where $|\gamma_k|$ is the length of the edge opposite vertex $v_k$, and $|T|$ is the area of the triangle. The vector $n_k$ is the unit outward normal.

The derivation is simple. The direction of the gradient is towards the highest growth, and as the barycentric coordinates are linear functions, it’s clear that $-n_k$ is the correct direction. The scaling is to simply note the area as $d|\gamma_k| = 2 |T|$ where $d$ is the shortest distance from the edge to the vertex. This gives us the inverse of the slop as the barycentric coordinate has a value of 1 at the vertex.

## 2 Replies to “Gradient of the Barycentric Coordinate in 2D”

1. ls says:

when you say “unit normal” which unit normal are you referring to?

1. Marshall Jiang says:

It’s probably best with an example. If the triangle has vertices (0, 0), (1, 0), (0, 1), then the unit outward normal for the edge (0, 0) — (1, 0) is (0, -1) (e.g. the vector which points directly south).

For the edge (0, 0) — (0, 1), it is (-1, 0).

For the edge (1, 0) — (0, 1), it is (1/sqrt(2), 1/sqrt(2)) (the square roots are there to normalize the vector).

This site uses Akismet to reduce spam. Learn how your comment data is processed.