Collision detection between bezier and ball.

OK, I got a really weird problem. I have a cubic bezier curve in 3d space and a sphere. The bezier curve is static, the sphere moves. Given the curve's definition a, c1, c2, e, each of which is a 3d vector, and the ball's position and movement vector, I need to find out the closest the bezier and the ball ever get to each other.

This is probably confusing.

Code:

`Ball`

{

Vector3d center;

Vector3d movement;

}

Bezier

{

Vector3d start;

Vector3d control1;

Vector3d control2;

Vector3d end;

}

Find

1) the least distance between any point on the bezier curve and any point on the line segment (Ball.center, Ball.movement).

2) the point on the line segment that is closest.

3) the bezier parameter t of the point on the bezier that is closest.

Given these three, I can achieve the other things I need to do.

Any ideas are GREATLY appreciated! I've been sitting on this for 2 days, and it has mostly given me a headache.