private Vector2 CrossPoint(float x, float y)
{
Vector2 _point = new Vector2(0f, 0f);
float dx = _fx - x;
float dy = _fy - y;
if(dx == 0) {
_point.x = _fx;
_point.y = (_fy > y) ? (_fy - _r) : (_fy + _r);
} else {
float a, b;
a = dy / dx;
b = _fy - a * _fx;
double ta, tb, tc;
ta = 1 + a * a;
tb = 2 * (a * (b - _cy) - _cx);
tc = (_cx * _cx) + (b - _cy) * (b - _cy) - (_r * _r);
float delta = (float)((tb * tb) - 4 * ta * tc);
delta = (float)Math.Sqrt(delta);
float x1 = (float)((-tb + delta) / (2 * ta));
float y1 = (float)(a * x1 + b);
float x2 = (float)((-tb - delta) / (2 * ta));
float y2 = (float)(a * x2 + b);
Vector2 vt1 = new Vector2(x1 - _fx, y1 - _fy);
Vector2 vt2 = new Vector2(x - _fx, y - _fy);
if(((vt1.x * vt2.x) >= 0) && ((vt1.y * vt2.y) >= 0)) {
_point.x = x1;
_point.y = y1;
} else {
_point.x = x2;
_point.y = y2;
}
}
return _point;
}