Spheres and planes are warm-ups. The real scene — every character, prop and landscape — is a mesh: thousands of triangles stitched together. So the workhorse intersection of a ray tracer is ray–triangle, and the elegant coordinate system that runs it, barycentric coordinates, doubles as the engine behind smooth shading and texture mapping. One idea, two superpowers.
A triangle has three corners
Step 1 — write a point as a blend of the corners. Pick three weights
Step 2 — make the weights sum to one. To land on the triangle's plane (not float off it), the weights must be a true average — they sum to one:
With this constraint,
Step 3 — read off "inside" from the signs. A point sits inside the triangle exactly when all three weights are non-negative. A negative weight means you've stepped past the edge opposite that corner:
That single sign test is the whole containment check — no angle sums, no winding loops.
Step 4 — intersect by meeting the plane, then testing the weights. To hit
triangle
Step 5 — Möller–Trumbore does it in one shot. The famous Möller–Trumbore
algorithm fuses those two steps: using
Step 6 — reuse the weights to interpolate. Here is the payoff. Each vertex
carries data — a normal, a colour, a texture coordinate. The same
The intersection test and the shading interpolation share one set of numbers. That is why barycentrics are everywhere in graphics.
Barycentric interpolation is not a niche trick — it is how a rasteriser fills a
triangle. Assign each corner a colour and blend by
Swap "colour" for "texture coordinate