collision

personal_username's icon

Hi all,

i have three *bidimensional* elements, each of them with x and y coordinates.
I'd like to be able to detect when two of them get closer than a certain distance, and then send a bang.
Right now i'm using a web of [if].
I take every couple of x and y coordinates and process them. like this: [if $1-$2 < mythreshold && $1-$2 >0 then bang], but it seems to be a (very) dumb approach, and never ending...
anybody has an idea?
thanks much!

Tim Lloyd's icon

I recently got loads of forum help on something similar to this. I needed to detect the collision of the mouse with the edge of an ellipse drawn in lcd. I'm not sure if it will be helpful for you, but the maths needed will be similar, although this depends on what shapes you need to detect for........it could get very complex!

Also, check out the cosm externals from CNMAT. They offer collision detection, but I'm not sure if that includes unusual shapes as well as spherical. I'm not familiar with them 'yet', and they seem to be geared towards 3D applications, but they're worth checking out.

Floating Point's icon
Max Patch
Copy patch and select New From Clipboard in Max.

is this what you want?

personal_username's icon

Terry and Tim, thank you very much.
Terry, your patch is as elegant as can be ;-) , AND it what i was looking forward. thanks!