Let's say we have a several tetrahedrons $T\_i$ whose faces touch so that each face belong to two tetrahedrons. Each tetrahedron contain a value $V\_{i}$.


Given a position $P$ inside the tetrahedron $T\_0$, and neighboring tetrahedron are labeled $T\_1, T\_2, T\_3, T\_4$.


How to compute the value $V(P)$ such that its value is a linear interpolation between all $V\_i$?


Following this, given a direction $\vec{d}$ and the origin $O$ and a scalar $t$ such that $P(t)=O+d\*t$, what is the equation giving the interpolated value along this segment $V(t)$, considering only the part where the segment is inside $T\_0$?


I tried to use barycentric coordinates, and I think it confused me more than it helped.


What would be a simple explanation for solving such a problem?



tetrahedral interpolation and integration along a segment
One common method is to assign values to the vertices of your central tetrahedron $T$,
and then use
[Barycentric coordinates](https://en.wikipedia.org/wiki/Barycentric_coordinate_system#Barycentric_coordinates_on_tetrahedra) to interpolate from the vertices of $T$ to any point $p \in T$.
The link shows how to convert between the coordinates of $p$ to its barycentric
coordinates $\lambda\_1,\lambda\_2,\lambda\_3,\lambda\_4$. Then use those $\lambda$'s to form a
weighted version of the values at the corners to $T$ to the value at $p$.


To use this approach, you need values at the vertices of $T$. I assume when you say that
each tetrahedron $T\_i$ "contains a value" $v\_i$, you mean that $v\_i$ is somehow appropriate
throughout $T\_i$. Then it makes sense to assign to a vertex $u$ of $T$ the average of the
values $v\_i$ for the three tetrahedra incident to $u$, and the
value of your central tetrahedron $T$.
To make this calculation less of a heuristic would require explicit criteria
the interpolation is to achieve.


So:


* Compute values for the four corners of $T$.
* Compute the barycentric coordinates $\lambda\_i$ for $p$. (Requires inverting a $3 \times 3$ matrix.)
* Use the $\lambda$'s to weight the vertex values to an appropriate value for $p \in T$.


