Hi thanks for replying, I got distracted from this project by things so sorry for disappearing.
Hmm I'm concerned with C(p) = || p - (pn0 + pv ) || 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 - (pn0 + pv ) || is always positive.
None the less I gave it a try, I found the gradient of C(p) = || p - (pn0 + pv ) || to be (p - (pn0 + pv)) / || p - (pn0 + pv ) ||
Set pn0 to the position of an endpoint before the constraint iterations. And pn1 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 pv 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.