ANN: Bouncing Ball Tools
Jim Hurley
jhurley at infostations.com
Fri Feb 25 13:14:40 EST 2005
(It took me two years to figure out that ANN meant Announcement.)
There was some discussion recently on how to motive oneself. Being
retired, I have entered that enviable time of life when I do whatever
I feel like-within reason. This does not present a difficult
motivational problem.
But if you're doing what you feel like, the problem becomes one of
stopping, letting go. I'm sure many of you have this problem when you
are engaged on a Run Rev problem that strikes your fancy.
Well, I got intrigued with simulations, all kinds. Recently I have
taken up bouncing balls. And I am having a hard time letting go.
So here is what I have tried so far:
1) Let the ball flex when it strikes the wall. Easy to do. Just
decrease the width and increase the height of the graphic as the ball
strikes a vertical wall. And vice-versa for horizontal walls.
2) This flexing is harder to do with walls that are not vertical or
horizontal, so I next considered a ball bounding about within a
polygon of arbitrary shape. The first problem was keeping the ball in
the polygon. I tried the within function but the ball kept escaping.
So I used the perpDist function I posted a while back for collision
detection between the ball and the individual lines that make up the
polygon. This is the perpendicular distance between a point (the ball
loc) and a line (polygon line.) The flexing was a bit simplistic. I
just flexed the radius.
3) But I found there was a problem if the polygon was not concave,
i.e. all interior angle less than 180 degrees. Here it became
necessary to introduce a new tool, a new function to determine
whether the collision took place between the end points of the line.
That tool was the perpProj function, which drops a perpendicular from
any point (the ball loc) to any line (polygon line.) It was easy to
determine when this projection point was between the end points of
the line.
4) I had very limited success in my attempt to deal with collisions
between a ball and isolated lines, so I took up ball-on-ball
collisions. This is a very conventional problem, just move the ball
incrementally until the distance between balls is less than the
combined radii. But I found three problems: (1) accuracy (2) smooth
motion and (2) the screen refresh problem in OS X. I wanted to move
the ball from one point to the collision point using the Run Rev Move
command, not in incremental steps. That necessitated predicting the
collision point in advance. This took my down a long path.
Which is detailed, along with the other three problems above, in the
stack: BouncingBallTools.rev which can be loaded in Run Rev by
running this line in the message box:
go url http://home.infostations.net/jhurley/BouncingBallTools.rev
And wait a little bit.
This is not an application, not even close, but a series of tools for
those of you who want to develop a Pin Ball Construction Set.
Jim
More information about the use-livecode
mailing list