   How to find the sliding plane (2D)
  I am trying to write a 2D circle/line collision algorithm. I have managed to detect the the collision of the circle with both the line, and the vertices of the line. I am having trouble finding the sliding planes for the collision response. I could probably come up with something, but it would be the really long way of doing it. I would like to do it using information that I already have. By the time I need to calculate the sliding plane, I will already have these things:A vector for the edgeA vector for the Ray of the circle's path through spaceA normalized vector for the Ray of the circle's path through spaceThe length of the RayT(0-1.0) of the time of collision along the RayT(0-1.0) of the circle's center at collisionA vector for the normalized normal of the edgeA vector for the point of collision on the vertex or edgeA vector for the new center of the circle at time of collisionThis is my code, thanks for any help anyone can offerPrivate Type VECTOR    X As Double    Y As DoubleEnd TypeDim bLeft As BooleanDim bRight As BooleanPrivate Sub Form_Load()    bLeft = False    bRight = FalseEnd SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)    If Button = vbLeftButton Then bLeft = True    If Button = vbRightButton Then bRight = TrueEnd SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)    bLeft = False    bRight = FalseEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)    If bLeft = True Then   Line2.X2 = X   Line2.Y2 = Y    ElseIf bRight = True Then   Line2.X1 = X   Line2.Y1 = Y    Else   Exit Sub    End If   Me.Refresh    Call Collide(CVector(Line1.X1, Line1.Y1), CVector(Line1.X2, Line1.Y2), _CVector(Line2.X1, Line2.Y1), CVector(Line2.X2, Line2.Y2), _30)End SubPrivate Function Collide(E0 As VECTOR, E1 As VECTOR, R0 As VECTOR, R1 As VECTOR, R As Double) As Boolean    Dim Edge As VECTOR, Ray As VECTOR, Rd As VECTOR    Dim PerpEdge As VECTOR, N As VECTOR, CN As VECTOR    Dim O As VECTOR    Dim C As VECTOR, PC As VECTOR   Dim LR As Double    Dim Lc As Double    Dim D As Double    Dim T As Double    Dim SL As Double, SV As VECTOR   Ray = Subtract(R1, R0)   Rd = Normalize(Ray, LR)    If LR = 0 Then 'the circle is not moving   Collide = False   Exit Function    End If   Edge = Subtract(E1, E0)   PerpEdge = Perp(Edge)    D = Dot(Ray, PerpEdge)   N = Normalize(PerpEdge, 0) 'determine which side of the edge the circle collides with, if any    If D < 0 Then   CN = MulS(N, R)    ElseIf D > 0 Then   CN = MulS(Opp(N), R)    Else   Exit Function 'edge and ray are perpendicular..will fix this later    End If   O = Subtract(E0, R0)   T = Dot(O, PerpEdge) / D    Lc = (T * LR) - Abs(R / Dot(Rd, N))   PC = Subtract(Subtract(MulS(Rd, Lc), CN), O)    T = Dot(PC, Edge) / Dot(Edge, Edge)   If Lc <= LR And Lc >= 0 And T > 0 And T < 1 And D <> 0 Then  'The circle does collide with the line.  C = Add(R0, MulS(Rd, Lc))  Circle (C.X, C.Y), R, vbRed   Else   If T <= 0 Then 'check vertex 1  PC = Subtract(E0, R0)   ElseIf T >= 1 Then 'check vertex 2  PC = Subtract(E1, R0)   End If T = Dot(PC, Ray) / Dot(Ray, Ray)  C = MulS(Ray, T)   Lc = Distance(PC, C) If (Lc < R) Then  Lc = Sqr(R ^ 2 - Lc ^ 2)  If ((T * LR) - Lc) >= 0 And ((T * LR) - Lc) <= LR Then C = Add(R0, Subtract(C, MulS(Rd, Lc))) Circle (C.X, C.Y), R, vbRed    End If   End If    End IfEnd FunctionPrivate Function CVector(vX As Double, vY As Double) As VECTOR    CVector.X = vX    CVector.Y = vYEnd FunctionPrivate Function Add(v1 As VECTOR, v2 As VECTOR) As VECTOR    Add.X = v1.X + v2.X    Add.Y = v1.Y + v2.YEnd FunctionPrivate Function Subtract(v1 As VECTOR, v2 As VECTOR) As VECTOR    Subtract.X = v1.X - v2.X    Subtract.Y = v1.Y - v2.YEnd FunctionPrivate Function MulS(V As VECTOR, Scalar As Double) As VECTOR    MulS.X = V.X * Scalar    MulS.Y = V.Y * ScalarEnd FunctionPrivate Function Dot(v1 As VECTOR, v2 As VECTOR) As Double    Dot = (v1.X * v2.X) + (v1.Y * v2.Y)End FunctionPrivate Function Normalize(V As VECTOR, retLength As Double) As VECTOR    Dim vLen As Double    vLen = Length(V)    Normalize.X = V.X / vLen    Normalize.Y = V.Y / vLen    retLength = vLenEnd FunctionPrivate Function Length(V As VECTOR) As Double    Length = Sqr(V.X ^ 2 + V.Y ^ 2)End FunctionPrivate Function Distance(v1 As VECTOR, v2 As VECTOR) As Double    Distance = Sqr((v2.X - v1.X) ^ 2 + (v2.Y - v1.Y) ^ 2)End FunctionPrivate Function Perp(V As VECTOR) As VECTOR    Perp.X = -V.Y    Perp.Y = V.XEnd FunctionPrivate Function Opp(V As VECTOR) As VECTOR    Opp.X = -V.X    Opp.Y = -V.YEnd Function
  I think you should be fine just using the vector from your line intersection point to the circle's origin at time of impact.Excellent article for reference: General Collision Detection for Games Using Ellipsoids.   ;  Thanks for the suggestion, but I already read that one. I found a way though.here is the new algorithm. It needs optimization, and a final check for errors, but it is fully functional and accurate.Private Function Collide(E0 As VECTOR, E1 As VECTOR, R0 As VECTOR, R1 As VECTOR, R As Double) As Boolean    Dim Edge As VECTOR, Ray As VECTOR, Rd As VECTOR    Dim PerpEdge As VECTOR, N As VECTOR, CN As VECTOR    Dim O As VECTOR    Dim C As VECTOR, PC As VECTOR   Dim LR As Double    Dim Lc As Double    Dim D As Double    Dim T As Double    Dim S As Double, SV As VECTOR   Ray = Subtract(R1, R0)   Rd = Normalize(Ray, LR)    If LR = 0 Then 'the circle is not moving   Collide = False   Exit Function    End If   Edge = Subtract(E1, E0)   PerpEdge = Perp(Edge)    D = Dot(Ray, PerpEdge)'determine which side of the edge the circle collides with, if any    If D < 0 Then   S = 1    ElseIf D > 0 Then   S = -1    Else 'Edge and Ray are parallel. Circle can only hit a vertex   GoTo CheckVerts    End If   N = Normalize(PerpEdge, 0)    CN = MulS(MulS(N, S), R)   O = Subtract(E0, R0)   T = Dot(O, PerpEdge) / D    Lc = (T * LR) - Abs(R / Dot(Rd, N))   PC = Subtract(MulS(Rd, Lc), CN)    T = Dot(Subtract(PC, O), Edge) / Dot(Edge, Edge)   If Lc <= LR And Lc >= 0 And T > 0 And T < 1 Then  'The circle does collide with the line.   C = MulS(Rd, Lc) SV = MulS(Rd, Lc)   SV = Perp(Subtract(PC, SV))   S = Dot(MulS(Rd, LR - Lc), SV) / Dot(SV, SV)   SV = MulS(SV, S) C = Add(R0, C)   Circle (C.X, C.Y), R, vbRed   C = Add(C, SV)   Circle (C.X, C.Y), R, vbGreen    ElseCheckVerts:   D = Dot(Ray, Edge)   If D > 0 Then 'check vertex 0  PC = Subtract(E0, R0)   ElseIf D < 0 Then  'check vertex 1  PC = Subtract(E1, R0)   Else  Exit Function 'Perpendicular. Edge collisions have already been checked.   End If T = Dot(PC, Ray) / Dot(Ray, Ray)   C = MulS(Ray, T)   Lc = Distance(PC, C)' On Error Resume Next   If (Lc < R) Then  Lc = Sqr(R ^ 2 - Lc ^ 2)  If ((T * LR) - Lc) >= 0 And ((T * LR) - Lc) <= LR Then C = Subtract(C, MulS(Rd, Lc))  SV = Perp(Subtract(PC, C)) S = Dot(MulS(Rd, LR - ((T * LR) - Lc)), SV) / Dot(SV, SV) SV = MulS(SV, S)  C = Add(C, R0) Circle (C.X, C.Y), R, vbRed C = Add(C, SV) Circle (C.X, C.Y), R, vbGreen  End If   End If    End IfEnd FunctionWhat I did, is find the vector that is perpendicular to the vector from the point of contact to circle's center at collision:SV = Perp(Subtract(PC, C))Then I used this formula to find project the remainder of the circle's ray onto it by finding the closest point on the line to the endpoint of the ray.S = Dot(MulS(Rd, LR - ((T * LR) - Lc)), SV) / Dot(SV, SV)Then I just multiplied it out and added the vectors together.SV = MulS(SV, S)C = Add(C, SV);Nexon continues its assault on the Western market with a console-like PC MMO, Vindictus , which marries action gameplay with the microtransaction framework and online gameplay knowhow the Korean studio is most famous for -- and director Eun-Seok Yi explains it all to Gamasutra.  View the full article