iDevGames Forums
Elastic Collisions in Objective C - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Elastic Collisions in Objective C (/thread-8874.html)



Elastic Collisions in Objective C - Mattonaise - Apr 20, 2011 05:26 PM

In my game I am planning to have some simple elastic physics, so I am currently researching on it. The math isn't too complicated, and I have found this page: "http://freespace.virgin.net/hugo.elias/models/m_snokr.htm". Can anyone verify if the information on this page is accurate? I am also looking for a math library that will allow me to do simple vector operations (adding, normalizing, dot product). I have heard of the Accelerate framework by apple, is this what I'm looking for?


RE: Elastic Collisions in Objective C - SethWillits - Apr 20, 2011 09:02 PM

No, Accelerate is not related. That's a different meaning of vector.

For simple vector math, you really just write your own.
http://www.idevgames.com/articles/vector-tutorial


Also: http://code.google.com/p/chipmunk-physics/


RE: Elastic Collisions in Objective C - Skorche - Apr 21, 2011 07:00 AM

My Chipmunk Physics library has a decent set of 2d vector operations defined for it. It would be pretty easy to separate them from the rest of the library if you wanted too. It's also pretty trivial to write them yourself.

You don't want to use the Accelerate framework for this sort of thing. Accelerate is good for things like image processing where you have an array of 100k numbers you want to add together, then multiply by another array of numbers. Basically it's taking advantage of SIMD instructions (also sometimes called vector instructions) of whatever CPU type it's running on to process this sort of data faster.


RE: Elastic Collisions in Objective C - Mattonaise - Apr 22, 2011 04:52 PM

Ok, thanks guys. Does anyone know whether the page I found is accurate?


RE: Elastic Collisions in Objective C - Lazer - May 13, 2011 11:40 PM

The math isn't necessarily incorrect, but it is oversimplified and not how I would work elastic collisions in objectiveC, and the diagram is misleading as the resulting vectors c and d will only go that direction if the objects have the same mass and same speeds to begin with. As far as I can tell that pseudocode doesn't determine the directions of the resulting vectors. Taking the dot product also won't work for orthogonal collisions. Are you having two objects that are moving collide, or is it collisions between a stationary object and something bouncing into it?