# Push remaining distance to the plane of collision?

Alright, so I have this collision detection code, and I'm trying to push the remaining distance (move from 0 to +5, wall at +2, remaining = +3) across the plane of the wall. Like this: Now I got most of it down, I know I need the remaining distance from the move, and the cross product of the normal for the wall, but I need some help getting the forumula right.

My question is, whats's the correct forumula for to move the remaining distance along the plane of the wall?

```if(distRemaining.length() > 0){
cProduct = cross(distRemaining, wallNormal);
dest += new Vector3f(cProduct.x, 0, cProduct.z);
}
```

Call your start point A, and the point of impact B, and the normal vector N to your wall plane. Calculate the vector that takes A to B (AB) and calculate the vector product between it and N. Call this X

```    X = AB x N
```

This is a vector perpendicular to both N and AB which also lies in the plane of your wall. Take a further vector Y as the vector product between X and N

```    Y = X x N
```

This is now a another vector in your wall that points in the direction of motion of your particle ALONG the wall after your collision. You will need to normalise this vector Y (calculate Y / |Y|) and multiply it by the amount you want to move along the wall, then add it to your collision point B. It is possible that this vector will point in the opposite direction but if you are careful with the order that you take the vector products you should be fine.

This is how you could do it in 3D which I am assuming you want from your question. In 2D it would be considerably simpler.

### Selenium - Check if an element is under another one

I'm using Selenium to do Java test.

### Why is this while loop not terminating? Comparing ints

I am trying to create a sort of menu. And if none of the options in the menu are selected then it should keep repeating the options. However this while loop is not termintating and I'm not sure why...