Thursday 20 March 2008

Simple Collision Response for Plane

Lets say we have a plane (B) with a slope of (delta Y / delta X), the slope of the normal (n) must be (-delta X / delta Y). In vector form, thats the same as B = [delta X, delta Y] and n = [delta Y, -delta X].

Let's assume the incoming velocity as U, the result velocity as R.
Now, it's time to find the projection (P) of -U onto the normalized normal (N).
By using dot product of -U and N, we will get the length of the projection on N.
Thus, P = (-U . N) * N --> Eq. 1

To find the reflection, we add in V where V = U + P --> Eq. 2.
Result velocity (R) = P + V --> Eq.3

Substitute Eq.2 into Eq.3,
R = P + U + P
= 2 * P + U

Substitute Eq.1 into it,
R = U + 2 * (-U . N)N or R = U - 2 * (U . N)N

No comments: