Hi thanks for replying, I got distracted from this project by things so sorry for disappearing.

Hmm I'm concerned with C(p) = || p - (p_{n0 }+ p_{v} ) || because in Müller's paper he describes contact constraints as being inequality constraints, meaning that the constraint's Δp is only applied if C(p) < 0. C(p) = || p - (p_{n0 }+ p_{v} ) || is always positive.

None the less I gave it a try, I found the gradient of C(p) = || p - (p_{n0 }+ p_{v} ) || to be (p - (p_{n0 }+ p_{v)) / }|| p - (p_{n0 }+ p_{v} ) ||

Set p_{n0 }to the position of an endpoint before the constraint iterations. And p_{n1 }to the closest point on the other line segment. The implementation didn't work but it could be I've just written it incorrectly.

However satisfying this constraint doesn't in fact guarantee the two segments will no longer collide. Because p_{v} isn't along the vector thats formed by the two closest points between the two colliding segments.

In the case of the red dot being pn0, pn0 - pn1 has to be larger than 2*r for the collision to be resolved. Moving along pn0 - pn1 when pn0 is the green dot then pn0 - pn1 must be 2*r to resolve the collision.