dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Bouncing a ball bounded by a circle

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    1

    Bouncing a ball bounded by a circle

    http://www.flickr.com/photos/60395315@N00/3621325296/

    I am working on figuring the math for this, wondering if I am on the right path

    Lets say the ball is starting from (a,b) inside the circle (see figure) hitting any point (c,d) on the circle. The next point the program calculates based on the acceleration /velocity is outside the circle (m,n).

    Now when we check the bounds, the ball should have bounced from the point (c,d).

    The line (a,b) & (m,n) intersects the circle at (c,d)

    The tangent of the line is x.c + y.d = r*r (x,y are points on the line)

    The distance of m,n from the tangent is equal to the point p1, p2 where the bounces to at this point I reverse the velocity & reduce it to .75 percent of its original(approximation).

    Am I on the right path here. How do I find point (p1,p2), where I am going to draw the ball?

  2. #2
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    well, you can solve for the length l1 of the line segment (a,b)(m,n) which should be the magnitude of your velocity * delta time and you can solve for the length l2 of (a,b)(c,d). intuitively, t = (l2 / l1) is in the range 0 < t <= 1 if there is an intersection with the bounding circle this time step. so (1 - t) would be the remainder over which to step to find (p1,p2). so it would go something like move circle from (a,b) to (c,d), solve for your new velocity, and scale it by 1 - ( l2 / l1 ). add this vector to (c,d) to find (p1,p2).

    usually this type of accuracy isn't necessary as you can just move to the point of collision, apply an elastic impulse and integrate the response in the next time step.
    Last edited by newblack; 06-21-2009 at 11:33 AM.

  3. #3
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    916
    I could swear this was asked before here... or somewhere.

    edit: oh look not what I had in mind though.
    Last edited by realMakc; 06-22-2009 at 06:32 AM.
    who is this? a word of friendly advice: FFS stop using AS2

  4. #4
    Member
    Join Date
    Mar 2008
    Posts
    82
    Hey strikerjax. Looks like we're both looking for the same answer.
    How to find the point at which an object traveling in a straight line passes through a circle. I posted the same question a couple of days ago.

    http://board.flashkit.com/board/showthread.php?t=802149

    There are a couple of ideas in there using either quadratics or a law of sines approach.
    Good luck.

    ----------------------------------------------------------------------1
    5-------------3-------------2-------------1-------------0-------------0
    -------0-------------0-------------0-------------0-------------0------0
    ----------------------------------------------------------------------0
    3-------------2-------------0-------------0---------------------------2
    --------------------------------------------------------3-------------3

  5. #5
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    916
    who is this? a word of friendly advice: FFS stop using AS2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center