Results 1 to 1 of 1
Thread: 2D - Collision messed up
- 06-22-2011, 09:20 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 43
- Rep Power
- 0
2D - Collision messed up
I'm trying to simulate 2D balls to colliding. Somehow I messing up things, but I can't really see what it is. If anyone could point me in the right direction, so to speak. The iterating works and the collision is detected like it should be. The problem occurs when I try to calculate the new velocity.
Java Code:if(2500 > Math.pow(b.getX() - x, 2) + Math.pow(b.getY() - y, 2)){ // System.out.println("collision OK!"); double pvX = b.getX() - x; double pvY = b.getY() - y; double vXE = b.getVelocityX(); double vYE = b.getVelocityY(); double v = (vYE * pvY + vXE * pvX) / (pvX * pvX + pvY * pvY); pixelsXPerMilli += v * pvX; pixelsYPerMilli += v * pvY; }
Similar Threads
-
Object streams messed up!
By Ruuhkis in forum New To JavaReplies: 0Last Post: 03-18-2011, 02:18 PM -
[BUG]: jframe objects messed up
By batia in forum Advanced JavaReplies: 4Last Post: 03-09-2011, 07:27 AM -
Is object of my class in a thread or I messed up again?
By atch in forum Threads and SynchronizationReplies: 5Last Post: 02-09-2010, 08:51 AM -
[newbie] messed up code
By jon80 in forum New To JavaReplies: 2Last Post: 05-31-2009, 04:29 PM -
I must be seriously messed up...
By jpnym15 in forum New To JavaReplies: 2Last Post: 11-16-2008, 07:20 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks