function getCenterParameters(x1, y1, x2, y2, fa, fs, rx, ry, phi) {
const { abs, sin, cos, sqrt } = Math;
const pow = n => Math.pow(n, 2);
const sinphi = sin(phi), cosphi = cos(phi);
const x = cosphi * (x1 - x2) / 2 + sinphi * (y1 - y2) / 2,
y = -sinphi * (x1 - x2) / 2 + cosphi * (y1 - y2) / 2;
const px = pow(x), py = pow(y), prx = pow(rx), pry = pow(ry);
const L = px / prx + py / pry;
if (L > 1) {
rx = sqrt(L) * abs(rx);
ry = sqrt(L) * abs(ry);
} else {
rx = abs(rx);
ry = abs(ry);
}
const sign = fa === fs ? -1 : 1;
const M = sqrt((prx * pry - prx * py - pry * px) / (prx * py + pry * px)) * sign;
const _cx = M * (rx * y) / ry,
_cy = M * (-ry * x) / rx;
const cx = cosphi * _cx - sinphi * _cy + (x1 + x2) / 2,
cy = sinphi * _cx + cosphi * _cy + (y1 + y2) / 2;
const theta = vectorAngle(
[1, 0],
[(x - _cx) / rx, (y - _cy) / ry]
);
let _dTheta = deg(vectorAngle(
[(x - _cx) / rx, (y - _cy) / ry],
[(-x - _cx) / rx, (-y - _cy) / ry]
)) % 360;
if (fs === 0 && _dTheta > 0) _dTheta -= 360;
if (fs === 1 && _dTheta < 0) _dTheta += 360;
return { cx, cy, theta, dTheta: rad(_dTheta) };
}