   Sliding vector from velocity vs a wall
  Or whatever you want to call it...I'll make my case clear with this drawing:W is a wall along which I want to slide the purple object. The object has velocity vector A and I want to know the sliding vector C. I know C definitely does not have the same length as A and I know C = A + B, but the question is, how do I find B without knowing C?I have read the articles on collision detection around here and they did not gave me a clear answer, thus my post here, I hope someone can help ;) I tried using the normal of W scaled to the length of A, and got close, but then C is not the accurate sliding vector (its direction is a little off) so that can't be the correct math.   
  You could split A into a part perpendicular to the wall (I assume that is what you meant with B) and a part C along the wall.With N being the (unit length) normal of the wall, pointing into the room where the object is, thenN dot -A := -1 * ||A|| * cos<N,A>will result in the projected length of A against N. HenceB := A * ( N dot -A ) / ||A||and, as you already have stated,C := A - BIf e.g. the object run perpendicular to the wall (and you use unit normals for simplicity), thenN dot -A = ||A||andB = AandC = 0what is correct.EDIT: Sorry, the first posted version has had A and C confused.   ;  But I don't know C, I only know A and the wall W and want to know B (the force the wall gives in response to A) so that I can calculate C = A + B. (I want to calculate it that way, because that math also works when the object is only touching the end (corner) of the wall in which case it slides in a direction not parallel to the wall.);  Yes, I have confused A and C; sorry for that. Is already corrected in the post above.   ;  Appendix: The object touches the wall in a single point. Furthurmore the wall has a single normal only if not doing a more elaborate stuff. If you want the object "go around the corner" of the wall, it may be necessary to compute the normal on the fly, e.g. as the unit vector pointing from the contact point to the center of the circle. So the normal will "wrap around" the corner of the wall.   ;  Yes, I have already worked that out. In my case N is the vector from the nearest point on the wall to the center of the object and B = A * (N dot -A) / ||A|| and then C = A - B, did I understand that right?;  I think that is right as long as your N is of unit length. (If not, then there is an additional dependence of the length of N!)   ;Quote:Original post by CodeImpYes, I have already worked that out. In my case N is the vector from the nearest point on the wall to the center of the object and B = A * (N dot -A) / ||A|| and then C = A - B, did I understand that right?You meant: B = N * (N.A);  Yes ofcourse, N must be normalized.ToohrVyk: B = N * (N.A) is the same as B = A * (N . -A) / ||A|| ?;Quote:Original post by ToohrVykYou meant: B = N * (N.A)Ahh, yes. Damned. Thx ToohrVyk.N * (N dot A)will shift the object back against N, whileA * (N dot -A) / ||A||will shift it back from where it has come. The latter formula is typical for "non sliding" collision correction!   