# Finding Collision Point

This topic is 4270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I´m computing the collision between a moving sphere and a mesh. I´m using OpCode, so I use a capsule (LSS) to represent the sphere movement. Opcode returns me the list of triangles collisioning with the capsule. But beside the triangles, I also need the collision point where the capsule collides so I be able move the sphere to that point. Opcode, just give me the triangle indices. I can extract the vertices of that triangle. Computing the collision normal is fairly simple, But how could I compute the collision point between the capsule (LSS) and the triangle?

##### Share on other sites
Getting the exact collision point/time of collision can be fairly complicated if using collision detection algorithms that only tests for overlapping geometry.

One way to get a good enough time of collision for arbitrary moving geometries is by using a binary search between the time before collision t1, and the time after collision t2. If a collision is detected during this time the time of movement tm is subdivided, for example tm = (t2 - t1) / 2.

The simulation is then re-run from t1 to t1 + tm. If collision is not detected then t1 + tm is the "closest" time before collision. If collision is detected then t1 + tm is the "closest" time after collision. This is repeated until tm is small enough. The point before collision is then approximated using velocity and tm.

Here's a link to a document that explains this: http://www.cescg.org/CESCG-2003/LKavan/index.html, see "Time of Contact".

There are other more specialized ways though. It's a good idea to use a capsule for sphere-mesh collision query, that tells that there is a collision. Since the sphere center is always offset from a triangle by its radius at the exact time of collision, the exact time is possible to find for a sphere. Offset the triangle by the sphere radius along the triangle normal, then perform a ray-triangle intersection test. That intersection is the center of the sphere at the time of collision.

I don't know if OPCODE can find the intersection point though, maybe you'll have to code the ray-triangle test yourself. Here's a reference for that: http://softsurfer.com/Archive/algorithm_0105/algorithm_0105.htm, see "Ray/Segment-Triangle Intersection". If several triangles are overlapped by the capsule, remember to find the closest intersection point.

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631758
• Total Posts
3002137
×