# Interpolation on a Triangular/Quad Facet

The $r,s$ coordinates of a triangular facet can be determined from the use of interpolation (shape) functions. Let

\begin{aligned}u_{i} &= (1 - r - s)u_{1} + ru_{2} + su_{3} &\\v_{i} &= (1 - r - s)v_{1} + rv_{2} + sv_{3}\end{aligned}

These can be rewritten as

\begin{aligned}\left( u_{i} - u_{1} \right) &= \left( u_{2} - u_{1} \right)r + \left( u_{3} - u_{1} \right)s &\\\left( v_{i} - v_{1} \right) &= \left( v_{2} - v_{1} \right)r + \left( v_{3} - v_{1} \right)s\end{aligned}

and then

\begin{aligned}r &= \frac{\left( v_{3} - v_{1} \right)\left( u_{i} - u_{1} \right) - \left( u_{3} - u_{1} \right)\left( v_{i} - v_{1} \right)}{\left( v_{3} - v_{1} \right)\left( u_{2} - u_{1} \right) - \left( u_{3} - u_{1} \right)\left( v_{2} - v_{1} \right)} &\\s &= \frac{\left( u_{i} - u_{1} \right) - \left( u_{2} - u_{1} \right)r}{\left( u_{3} - u_{1} \right)}\end{aligned}

Then

$f_{i} = (1 - r - s)f_{1} + rf_{2} + sf_{3}$

On a quadrilateral facet using the interpolation functions gives

\begin{aligned}u_{i} &= \frac{1}{4}(1 - r)(1 - s)u_{1} + \frac{1}{4}(1 + r)(1 - s)u_{2} + \frac{1}{4}(1 + r)(1 + s)u_{3} + \frac{1}{4}(1 - r)(1 + s)u_{4} &\\v_{i} &= \frac{1}{4}(1 - r)(1 - s)v_{1} + \frac{1}{4}(1 + r)(1 - s)v_{2} + \frac{1}{4}(1 + r)(1 + s)v_{3} + \frac{1}{4}(1 - r)(1 + s)v_{4}\end{aligned}

these can be rewritten

\begin{aligned}u_{i} &= u_{a} + u_{b}r + u_{c}s + u_{d}rs &\\v_{i} &= v_{a} + v_{b}r + v_{c}s + v_{d}rs\end{aligned}

Using the first of these gives

$s = \frac{\left( \left( u_{i} - u_{a} \right) - u_{b}r \right)}{\left( u_{c} + u_{d}r \right)}$

which can be substituted into the second to give

$v_{i} = v_{a} + v_{b}r + \left( v_{c} + v_{d}r \right)\frac{\left( \left( u_{i} - u_{a} \right) - u_{b}r \right)}{\left( u_{c} + u_{d}r \right)}$

This can then be solved for $r$ & $s$ and then the interpolation function used as for the triangular facet.