var ax = -1;
var ay = 0;
var bx = 1;
var by = 0;
var ab = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));
var ac = 1;
var bc = 1;
//验证数据
//var ax = 4088.368;
//var ay = 1992.79;
//var bx = 4734.408;
//var by = 2444.842;
//var ab = Math.sqrt(Math.pow(ax - bx, 2) + Math.pow(ay - by, 2));
//var ac = 385.23;
//var bc = 492.57;
//输出
//4252.88118224958
//2341.12542134862
//4471.98580959676
//2027.99694619228
L = ab;
if (bx == ax || by == ay) {
K1 = 0;
K2 = 0;
} else {
K1 = (by - ay) / (bx - ax);
K2 = -1 / K1;
}
X0 = ax + (bx - ax) * (Math.pow(ac, 2) - Math.pow(bc, 2) + Math.pow(L, 2)) / (2 * Math.pow(L, 2));
Y0 = ay + K1 * (X0 - ax);
R = Math.pow(ac, 2) - Math.pow((X0 - ax), 2) - Math.pow((Y0 - ay), 2);
//则要求点C1(cx1,cy1),C2(cx2,cy2)的坐标为
cx1 = X0 - Math.sqrt(R / (1 + Math.pow(K2, 2)));
cy1 = Y0 + K2 * (cx1 - X0);
cx2 = X0 + Math.sqrt(R / (1 + Math.pow(K2, 2)));
cy2 = Y0 + K2 * (cx2 - X0);
//选出唯一解 (需要缩放前坐标 coding...)
trace(cx1);
trace(cy1);
trace(cx2);
trace(cy2);