# Collision vectors on the inside of a circle.

Hi folks.

I have the simple code for working out the exit vectors of moving, colliding objects, but I have a slightly different situation which I haven’t been able to find the answer for.

I have an object moving around inside a large circle, (900,900 px) when it hit’s (bounces) off the inside of the circle I want a realistic exit vector. The simple equations either expect two objects to have velocities, or don’t account for glancing blows.

So if the object hits the inside of the circle head on (90 degrees) it will bounce straight back, but a glancing blow would send the object off at a shallow angle to hit the circle again.

The bit I can’t seem to work out is creating a second vector of the circle circumference at the point of the impact.

Has anyone done this, or have the math for it? Or a link with an example?

Thanks.

Yes, XNA / Monogame has built in funtions for that - namely Vector2.Reflect.

It works like this - you have an incidence vector and a normal. The normal is the vector that defines a surface orientation, the incidence is the (negative) movement vector of your object.

For a circle you can easily get the normal vector for each point, it’s simply normalized ( position - circle origin ). If you want to have the normal look to the inside you just put a minus in front.

So your exit vector is Vector2.Reflect( movement, normal)

Well blow me!! I wish I’d looked through my messages a couple of days ago! I have inadvertently opened 3 threads around this issue. I will point them all to this.

So Many Thanks kosmo.