# How to detect and collide two elastic line segments?

There are 4 moving physical nodes in 3D space. They are paired with two elastic line segments / strings (1 <-> 2; 3 <-> 4).

Part I: How to detect the collision of two segments?

Part II: On the moment of collision, fifth node is created at the intersection point and here you have the force-based graph. 5-th node (bend point) can slide among the strings as in a real world. Given the new coordinates of 4 nodes, how to calculate the position of the 5-th node on the next frame? I assume string force on the nodes to be F = -k * x where x is the string length.

All I came up to is that the force between 5 and 1 equals 5 and 2 (the same with 3 and 4). What are the other properties?.

• Is this homework? Jan 21, 2011 at 0:59
• True, it's written a bit in that way.. I'd love to know what school gives such schoolwork though =) Jan 21, 2011 at 7:09
• No, it's not a homework. I would love too to have such a project as a home task. Jan 21, 2011 at 9:38

I realized one can detect two segment collision by observing 180° change in shortest distance vector comparing with previous frame.

Update:

Yep, collision seems to be detected correctly and guess what? The length of the elastic strings is actually zero. It only has this super ability to stretch infinitely. If the length is zero, no sliding is possible. From visual observation, everything seems real, sliding is not needed here.

Update:

Something is still wrong. Sliding is needed. It's very visible, when you turn on global gravity and observe one horizontal pair hit vertical pair with velocity. Horizontal one should slide down, but instead, it remains stuck in the middle of the string. Looking in further.

Update:

I managed to fix up a formula:

k - general pair's tension.
k1 and k2 - two new tensions for 1 <-> 5 and 2 <-> 5
d - distance 1 <-> 2
d1 and d2 - distance 1 <-> 5 and 2 <-> 5

k2 = k * d / (2 * d2)
k1 = d2 * k2 / d1

Update k1 and k2 for a pair each frame before physics forces integration kicks in and it behaves OK. Basic frictionless sliding has been enabled, finally.

for very fast moving line segments or large time intervals, I believe you can still get realistic behavior in a system with constant "energy" without very much calculation, but I have not yet found the solution, I'm curious as to what thoughts you dismissed when you went to the "change in occlusion order" method.