const lgArcFl = (S,V,E) => Math.abs(angle(S,V,E)) > pi/2 ? 0 : 1;
const sweepFl = (S,V,E) => angle(E,S,V) > 0 ? 0 : 1;
const angle = ([a,b],[c,d],[e,f]) => (Math.atan2(f-d,e-c)-Math.atan2(b-d,a-c)+3*pi)%(2*pi)-pi;
const qs = sel => document.querySelector(sel), pi = Math.PI, pts = [];
const radius = ([a,b],[c,d],[e,f]) => {
const g=c-a,h=2*(c-e)/g,i=d-b,j=c*c+d*d,k=j-a*a-b*b,l=(j-e*e-f*f-h*k/2)/(2*(d-f)-h*i);
return Math.hypot(a+(i*l-k/2)/g,b-l);
};
const mkArc = (arc, [sx, sy], [ex, ey], r, lg, sw) => arc.setAttribute('d',
`M ${sx} ${sy} A ${r} ${r} 0 ${lg} ${sw} ${ex} ${ey}`);
const calcArcs = (S,V,E) => {
const args = [S, E, radius(S,V,E)];
[[0,0],[0,1],[1,0],[1,1]].forEach(([lg,sw]) => mkArc(qs(`#arc${lg}${sw}`), ...args, lg, sw));
mkArc(qs(`#arc`), ...args, lgArcFl(S,V,E), sweepFl(S,V,E));
};
let ptNum = 0;
qs('svg').addEventListener('click', evt => {
const x = evt.x - 10, y = evt.y - 10;
pts[ptNum] = [x, y];
qs('#pt' + ptNum).setAttribute('transform', `translate(${x},${y})`);
if (ptNum++ === 2) {
calcArcs(...pts);
ptNum = 0;
}
});
text {
font-family: courier;
font-size: 18px;
fill: black;
stroke: none;
transform: translate(-5px,5px);
}
#arc00, #arc01 {
stroke: red;
}
#arc10, #arc11 {
stroke: blue;
}
#arc00, #arc10 {
stroke-width: 4;
stroke-dasharray: 5,5;
}
#arc01, #arc11 {
stroke-width: 2;
}
rect {
fill: none;
stroke: black;
height: 200px;
width: 600px;
}
<svg height="200" width="600">
<defs>
<path id="arc" />
<circle id="circ" cx="0" cy="0" r="10" />
</defs>
<g fill="none">
<use xlink:href="#arc" stroke="black" stroke-width="12" />
<use xlink:href="#arc" stroke="#ff8" stroke-width="10" />
<path id="arc00" />
<path id="arc01" />
<path id="arc10" />
<path id="arc11" />
</g>
<g fill="#ff8" stroke="black">
<g id="pt0" transform="translate(-99,0)"><use xlink:href="#circ" /><text>S</text></g>
<g id="pt1" transform="translate(-99,0)"><use xlink:href="#circ" /><text>V</text></g>
<g id="pt2" transform="translate(-99,0)"><use xlink:href="#circ" /><text>E</text></g>
</g>
<rect />
</svg>