Thanks.

Anyway, that link you gave me helped me optimize some of my code, but I'm still having problems.

What I'm doing now is look for the possible intersection point on the circle's radius, which is where the line normal would cross if reaching for the circle's centre. I came up with two ways of calculating the distance between the line and this intersection point parallel to the circle's velocity; one from the web site you gave me Lilian and another site at

http://www.gamespp.com/algorithms/collisionDetectionTutorial02.html.

First I get the intersection point:

1 2 3
| double intsect1X = A.x() + (-Nx * A.radius()); double intsect1Y = A.y() + (-Ny * A.radius()); |

Getting the distance based on the second site:

1 2
| double d = (line.getX1() * Nx) + (line.getY1() * Ny); double actDist = d - ((intsect1X * Nx) + (intsect1Y * Ny)); |

Getting the distance based on the first site:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| double intsect2X = A.x() + (-Nx * A.radius()) + A.dx(); double intsect2Y = A.y() + (-Ny * A.radius()) + A.dy();
double denom = ((line.getX2() - line.getX1()) * (intsect2Y - intsect1Y)) - ((line.getY2() - line.getY1()) * (intsect2X - intsect1X)); if (denom == 0) return 1.0; double r2 = (((line.getY1() - intsect1Y) * (intsect2X - intsect1X)) - ((line.getX1() - intsect1X) * (intsect2Y - intsect1Y))) / denom; double Zx = line.getX1() + (r2 * (line.getX2() - line.getX1())) - intsect1X; double Zy = line.getY1() + (r2 * (line.getY2() - line.getY1())) - intsect1Y; double actDist = Math.sqrt((Zx * Zx) + (Zy * Zy)); |

Both of these are followed by this:

1 2 3 4
| if (dV <= Math.abs(actDist)) return 1.0; return Math.abs(actDist) / dV; |

The problem is first of all that it looks like my line is "one-sided," the ball is only blocked from one side. It can still pass through the other side. Even on the side where it's blocked, it seems to be still possible for the ball to pass through if I press the forward key long enough (I'm controlling the ball with the keyboard).