Sliding vector from velocity vs a wall

Started by
12 comments, last by CodeImp 18 years, 4 months ago
ok I understand that was a correction :)
To summerize it all;

B = N * (N . A) and C = A - B
Where A is the object velocity vector,
N is the normalized vector from nearest point on the wall to the object,
B is the force coming from the wall in response to A,
and C is the resulting slide vector that the object will follow.
Kind regards,
Pascal van der Heiden

CodeImp - My trademark and website
Advertisement
[edit: oops beaten ...]

I'll just clarify something here that might make it easier to understand. The projection of a vector u onto another vector v is given by

projv(u) = (u.v)/(v.v) * v

where . represents dot product. In your case B is the projection of A onto the wall normal, which I'll call N. If N is a unit vector then the above simplifies to

B = projN(A) = A.N * N

since N.N = |N|2 = 1

To get the sliding vector C, as you have said simply compute C = A-B.
At the moment _I_ think it is correct ;-)

N dot A should be negative, so that B points against the direction of N. In
N * (N dot A)
only a single vector of non unit length is contained, so the length should be projected correctly. Yes, I think now it is ok.
I just implemented this and it looks perfect, thanks for the help!
Kind regards,
Pascal van der Heiden

CodeImp - My trademark and website

This topic is closed to new replies.

Advertisement