# Barycentric coords in triangle sweeps

A “triangle sweep” can be defined as 2 triangles `(A,B,C)`

and `(D,E,F)`

and the 3 bilinear patches at the sides of both triangles. It’s kind of a “twisted” triangular prism.

We can define some sort of `(u,v,w)`

barycentric coordinates here, such that each point `P`

interior to the sweep could be written as `P=(A+AD*w)*u+(B+BE*w)*v+(C+CF*w)*(1-u-v)`

.

As soon as the sweep is “twisted” the behavior of those *barycentric* coords is no longer linear. *i.e.,* linear motion in the `(u,v,w)`

space does not translate to linear motion in 3D space and viceversa. However these coordinates can be useful for certain applications.

One way to find `(u,v,w)`

for a given `P`

is to solve for `w`

first (the red plane below) and then find `u`

and `v`

as regular barycentrics in the triangular section. After massaging the numbers a bit, solving for `w`

turns out to be a cubic equation, which is the wiggly orange curve below.

We are only interested in solutions where `w IN [0..1]`

.