Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Perfect Circle - Circle Collision Detection
Index -> Programming, Turing -> Turing Tutorials
Goto page Previous  1, 2, 3
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Turing_Gamer




PostPosted: Wed Feb 03, 2010 8:27 am   Post subject: Re: Perfect Circle - Circle Collision Detection Worth a look

This is a nice tutorial but after looking over that huge descripion I'm going to stick with 1 ball collision like in pong. Maybe once I understand the words and techniques more I could use this.

+ KARMA

P.S. Why would anyone give negative karma???

EDIT: Can Math.Distance also work in the 2 ball collision?
Sponsor
Sponsor
Sponsor
sponsor
pcaston2




PostPosted: Mon May 07, 2012 1:27 pm   Post subject: Re: Perfect Circle - Circle Collision Detection

Wonderful article! I am running into an issue though and can't seem to find an elegant solution.

I use the code in this article over the course of a "second" (change in t = 1). After each second the velocity of each object is updated by acceleration, and a percentage of the velocity is removed (for drag). Once I've made changes to velocity, I proceed with the next second.

I have two circles continually accelerating towards each other. They detect the collision and bounce apart. As mentioned in the article, at time of collision the objects could technically be inside each other (rounding error). What sometimes happens is that two objects collide, and before they can be propelled apart, the velocity is updated (acceleration towards each other) and the collision doesn't occur (collision time is negative and not within {0,1}).

I can detect that the objects are within each other and no time has gone by, but what do I do in this case? I get stuck in an infinite loop where no time is going by and the circles aren't moving.

Any advice?

Thanks!
Raknarg




PostPosted: Mon May 07, 2012 7:41 pm   Post subject: RE:Perfect Circle - Circle Collision Detection

post some code, maybe?

Also, mightve made more sense to make a new topic
AnsonKindred




PostPosted: Sat Sep 22, 2012 4:21 pm   Post subject: Re: Perfect Circle - Circle Collision Detection

Really awesome concept and clear explanation, but I have one question. In your timeToCollision method

Quote:

A := balls (i).vx ** 2 + balls (i).vy ** 2 - 2 * balls (i).vx * balls (j).vx + balls (j).vx ** 2 - 2 * balls (i).vy * balls (j).vy + balls (j).vy ** 2
B := -balls (i).x * balls (i).vx - balls (i).y * balls (i).vy + balls (i).vx * balls (j).x + balls (i).vy * balls (j).y + balls (i).x * balls (j).vx - balls (j).x * balls (j).vx + balls (i).y * balls (j).vy - balls (j).y * balls (j).vy
C := balls (i).vx ** 2 + balls (i).vy ** 2 - 2 * balls (i).vx * balls (j).vx + balls (j).vx ** 2 - 2 * balls (i).vy * balls (j).vy + balls (j).vy ** 2
D := balls (i).x ** 2 + balls (i).y ** 2 - balls (i).r ** 2 - 2 * balls (i).x * balls (j).x + balls (j).x ** 2 - 2 * balls (i).y * balls (j).y + balls (j).y ** 2 - 2 * balls (i).r * balls (j).r - balls (j).r ** 2
DISC := (-2 * B) ** 2 - 4 * C * D


A and C appear to be exactly the same:

Quote:

A := balls (i).vx ** 2 + balls (i).vy ** 2 - 2 * balls (i).vx * balls (j).vx + balls (j).vx ** 2 - 2 * balls (i).vy * balls (j).vy + balls (j).vy ** 2
C := balls (i).vx ** 2 + balls (i).vy ** 2 - 2 * balls (i).vx * balls (j).vx + balls (j).vx ** 2 - 2 * balls (i).vy * balls (j).vy + balls (j).vy ** 2


Am I missing something here?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Tutorials
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 3 of 3  [ 34 Posts ]
Goto page Previous  1, 2, 3
Jump to:   


Style:  
Search: