We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Collision detection
Page Index Toggle Pages: 1
Collision detection? (Read 1364 times)
Collision detection?
Dec 8th, 2006, 8:04pm
 
Hey just wondering if someone can help me. I want two objects (Ellipse) to be like a magnet...1 attracted and 1 unattracted.
Re: Collision detection?
Reply #1 - Dec 23rd, 2006, 8:24pm
 
Hmm, we'll need a little more info about what exactly you're trying to do to help you -  I don't understand what you mean by "1 attracted and 1 unattracted."  You mean as in one end of an object is positively charged and one is negative?  That's a dipole, and http://en.wikipedia.org/wiki/Dipole is as good a place to start as any.

For collision detection, you've just stepped into one of the most irritating areas of physical simulation.  Ellipse-ellipse collisions are notoriously tricky to calculate, simply because the equations are complicated.  I'm not entirely sure if there's a simple formula that will give you the answer - I've never used one, at least.  For circle-ellipse collisions, http://mathworld.wolfram.com/Circle-EllipseIntersection.html has enough for you to probably get it eventually.  Honestly, though, if I were you, I would approximate each ellipse as a series of line segments in order to solve that type of collision, as long as you have the CPU cycles to spare in your loop.  If you really want to do it, head to http://www.kevlindev.com/blog/?p=15 to see an example in Javascript; the meat is in http://www.kevlindev.com/gui/2D.js and to me it's absolutely unreadable because each function is collapsed onto a single line.  But there you go...
Page Index Toggle Pages: 1