# Bounce problem.

Hi there. Again.

I’ve been working on a bounce routine for a while, after failing miserably work it out myself I started looking for examples mentioned in another post as escape vectors. But I thought I’d start this one as hopefully my description will be better.

I have a circle, inside this circle there are objects that need to bounce around. Being a circle I always have a normal to the centre, and I always have the position and direction of the objects.

I found this example:
Vnew = -2*(V dot N)*N + V
Where V is the object vector and N is the surface normal.

So I wrote this
` Dim N As Vector2 = Vector2.Normalize(Ship.Position - Centre)

``````    Dim V As Vector2 = Vector2.Normalize(Ship.Direction)

Dim NewVector As Vector2 = -2 * (Vector2.Dot(V, N) * N + V)

Ship.Direction = NewVector`
``````

Where V is the vector of the object and N is the normal to the centre of the circle from the point of impact.

But, a 90’ hit works kind of ok, a shallow hit either bounces off at 90’ to the normal, or bounces back in the direction of the initial movement vector.

Have I got something wrong with the above? Surely the equation should take into account any angle of attack, so it can’t be a quadrant thing.

Any ideas? Thanks guys. And gals.

kosmo suggested an answer to this in a previous post of mine, I’ve inadvertently opened more than one topic on this.

The answer can be found at: Collision vectors on the inside of a circle.