Collision's From a Ball to ???

Blitz3D Forums/Blitz3D Programming/Collision's From a Ball to ???

Paul "Taiphoz"(Posted 2005) [#1]
I'm working on some code just now, that requires, a Ball or Circle i should say, to collide off of a few different shapes.

Circle - Circle
Circle - Tri
Circle - Squ
Circle - Star
Circle - flatwall or line.

I am currently working on the following code.



Space Bar, will add another circle, at the moment, I seem to be getting a change in velocity(x,y) from some collisions and I dont want that, I need for the collision to only change the vector the circle is moving along and not its speed.

I also need as stated above to work out how to best detect a collision vs a square, and have the circle reflect at the correct angle, but im not sure where to start with that, not to mention a star lol..

Anyway . thanks in advance for any help.


Paul "Taiphoz"(Posted 2005) [#2]
fyi math aint my strong point, my brain works maths problems out differently to normal people so I appologise if its something you might consider stupid.


Najdorf(Posted 2005) [#3]
it aint a trivial problem at all


WolRon(Posted 2005) [#4]
Couldn't you just use Blitz collisions with the stop method?

Then check the collision normals for the angles (CollisionNX, ...NZ, etc.), and then just reverse (* -1) the velocity of the axis' that hit?


Stevie G(Posted 2005) [#5]
Much better to use the inbuilt collisions for this ... especially non-circular shapes. It will save you some major headaches .. trust me. Check out the code archives ... I think Sswift and Darkeagle have some code there to calculate the correct angle of reflection. These will be for 3d ..

These examples will not assume the velocity magnitude is preserved on collision which is physically correct. I guess you could normalise the resulting reflection velocities and multiply them by the speed you want to retain. I don't think it would look right though.


Paul "Taiphoz"(Posted 2005) [#6]
the collisions aint to much of a problem, as i do in the end intend to use the built in blitz collisions.

Its more that I need help working out the reflection angles after a collision.