Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Simple dynamic-static circle collision response

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple dynamic-static circle collision response

    Hellooooo! I have spent an endless amount of time this weekend trying to figure out simple physics for a pong-ish game I'm work on in which the paddles are circles rather than lines. I am having a hard time finding a well explained way to bounce the ball of of the circular paddles realistically. Most tutorials are for dynamic-dynamic collisions and I find them hard to understand and thus manipulate it to how I need it to work. I understand conservation of energy and stuff, the problem is the angles and figuring out the x+y velocities after. If someone could give me some guidance and perhaps a code snippet / an equation I could use it would be greatly appreciated!

    Just need a way to get the final x+y velocities after the collision with the paddle ^^ thnx ahead of time


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Simple dynamic-static circle collision response

    Pseudo-code:
    Assuming the paddle isn't moving (or at least its movement doesn't affect the solution)

    1. Compute the normal at the point of contact (simple, for a circle it's the line from the center of the circle to the collision point)
    2. Reflect the balls velocity around that line. See: Coordinate rotations and reflections - Wikipedia, the free encyclopedia for a 2D transform matrix that will do this for you.

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Simple dynamic-static circle collision response

    Ok well I didn't understand any of that :$ aha I did find out however that R = 2W - P for reflecting off of an angled wall which is essentially what I'm doing. I'm however not mathematically smart enough to manipulate that to give me a vector after... HELPS

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,541
    My Mood
    Hungover
    Thanks
    145
    Thanked 648 Times in 553 Posts

    Default Re: Simple dynamic-static circle collision response

    Why don't you just get the delta X and delta Y from the center of the circle and use those?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Troubles with toString and static and non-static
    By BadgerWatch in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 3rd, 2011, 06:04 AM
  2. [SOLVED] non static variable this cant be referenced from a static context
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 20th, 2011, 07:13 PM
  3. java (circle)
    By coder.freak in forum Member Introductions
    Replies: 3
    Last Post: March 26th, 2011, 01:01 PM
  4. non-static method cannot be referenced from a static context
    By Kaltonse in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 21st, 2010, 07:51 PM
  5. Replies: 10
    Last Post: September 6th, 2010, 05:48 PM

Tags for this Thread