I want to write a field in maya that applies a force in the space between 2 pieces of geometry. They can be topologically identical triangulated meshes. So the problem comes down to testing if a particle is in the volume swept out between a pair of triangles, and if so, finding its coordinates. If the particle is in the sweep, there will be a line passing through it and meeting both triangles at the same barycentric coordinates on each triangle. It would be nice to know the barycentric coordinates because then the force can be UV textured. Also I would need to know the parameter along the line so the force can be attenuated. I managed a bad hack once that worked if the triangles were nearly parallel and similar size, but it fell apart fairly fast. Intuitively it seems doable though.
I will try this. If anyone else would like to try, be my guest ;)
bool pointInSweptTriangle( triangle t0, triangle t1, point p, vector &bary, float &t);

100 rep bounty to whoever sends code, as described by Mr Grumpy ;)
Do you care about what language it’s in? Or are you happy to translate anything (understandable!) into whatever language you require?
I don’t mind what language. If I could get the math in pseudocode I’ll be able to insert it into my maya plugin.