Feedback

What's your question?

By: [ Admin ] Asked from India

Find the coordinates of a particle in a swept triangle.

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);

Add comment viewed 242 times Latest activity 7 months ago

NN comments
julian
-

100 rep bounty to whoever sends code, as described by Mr Grumpy ;)

hugh_gid
-

Do you care about what language it’s in? Or are you happy to translate anything (understandable!) into whatever language you require?

julian
-

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.

or Cancel

1 answer

  • 1

mr grumpy [ Editor ]

If 't' is the parameter along the line, then section 6 of this has a cubic in 't' which you can solve to find the "time" at which the swept triangle and particle are coplanar (assuming the particle velocity is zero, and disregarding any solutions outside 0-1). Then lerp the triangle vertices using 't', and find the barycentric coordinates of the particle with respect to that interpolated triangle in the usual way. It breaks down if the two triangles are coplanar though.

NN comments
julian
-

that looks good! Seeing it as a collision with a moving cloth helps. Not sure if my high-school-math brain can turn cubic root equations into code, but I will try. Cheers!

julian
-

sorry Mr Grumpy – I have since found out that the reason the bounty wasn’t awarded was because your answer was posted before the bounty was started ;( – still learning the nuances of this system myself.

or Cancel