Here are some observations based on the math at the start of this pdf
http://www.ifi.unicamp.br/~coluci/f129i/wallace.pdfThis case is for friction-free collision of a cue ball with a stationary target ball of the same size and mass,
with no spin, and fully elastic (no energy or momentum loss).
The target ball is going to move in a direction formed by a line between the cue ball and the
target ball at the moment of collision. You can use the arctan2 block with the differences
between the coordinates of the two balls for the x and y values, but there is a catch:
The y pixels run from top to bottom of the screen, the opposite from typical math graphing
examples. That means you might have to use y1-y2 instead of y2-y1 in your blocks.
Experiment to see what works.
The cue ball, if slightly off from the center line to the target ball, will continue moving,
but at
right angles to the
new direction of movement of the target ball.
(This is derived in that Wallace pdf, but seems to be well known.)
This direction is easy to calculate from the direction of the target ball.
Just add (or was it subtract?) 90 degrees to or from the target ball's
new direction. The +/- problem comes from whether you are hitting
on the right or left side of the target ball.
Now to the speeds of the two balls after collision ...
The original cue ball direction is along a line.
Where that line hits the edge of the target ball,
the target ball goes off in a new direction (see above).
The angle between those two lines (call it
theta) determines the
distribution of speeds between the cue ball and target ball
after collision.
Assign the original speed of the cue ball to a variable
v.
The cue ball should get a new speed of
sin(theta) times
v.
The target ball should get a new speed of
cos(theta) times
v.
You will have to fiddle with the sign of theta -
if it's negative, the sin(theta) will come out negative and give you a negative
speed for the cue ball. Use the abs() block for this, or see if failure to
compensate for the choice of right/left side collision earlier
will give you a direction that compensates for this. I suspect AI2
will not like a negative speed.
I have not had the time to code this or test this.
I hope this reading of the math from the Wallace pdf
helps.
ABG
The target ball goes off with a speed of