function to draw a 3-point arc
Simplification
fun[p_] :=
Module[{cs = List @@ Circumsphere[p], c, r, u, v, w, reg, rm,
regc}, {c, r} = cs;
{u, v, w} = Sort[Mod[ArcTan @@@ (# - c & /@ p), 2 Pi]];
reg = {{u, w}, {v, 2 Pi + u}, {w, 2 Pi + v}};
rm = Abs[Subtract @@@ reg];
regc = Pick[reg, # == Min[rm] & /@ rm];
ParametricPlot[c + r {Cos[t], Sin[t]}, {t, ##},
Epilog -> {PointSize[0.03], Red, Point[p], Green, Point[c], Gray,
Dashed, Circle[c, r]}, AspectRatio -> Automatic,
PlotRange -> Table[{-2, 2}, 2], Frame -> True, Axes -> False] & @@@
regc]
Original Answer
Not efficient but for what it's worth (using Circumsphere
):
func[p_] :=
Module[{cs = List @@ Circumsphere[p], c, r, u, v, w, reg, rm, regc},
{c, r} = cs;
{u, v, w} = Sort[Mod[ArcTan @@@ (# - c & /@ p), 2 Pi]];
reg = ParametricRegion[c + r {Cos[t], Sin[t]}, {{t, ##}}] & @@@ {{u,
w}, {v, 2 Pi + u}, {w, 2 Pi + v}};
rm = RegionMeasure /@ reg;
regc = Pick[reg, # == Min[rm] & /@ rm];
RegionPlot[regc,
Epilog -> {PointSize[0.03], Red, Point[p], Green, Point[c], Gray,
Dashed, Circle[c, r]}, AspectRatio -> Automatic,
PlotRange -> Table[{-2, 2}, 2]]]
Testing on 10 random triples:
pts = RandomReal[1, {10, 3, 2}];
anim=func/@pts;
Updated based on ubpdqn's brilliant use of Circumsphere
. The function is now more than two orders of magnitude faster.
Ok, since it seems like there is no simple form solution based on additional readings of other posts, I am posting the general form of the function I suggested in the question:
arc3v2[pts_List] :=
Module[{center, radius, theta},
{center, radius} = List @@ Circumsphere[pts];
theta = SortBy[Mod[ArcTan @@ (# - center), 2 Pi] & /@ pts, # &];
{center, radius, {First@theta, Last@theta}}
]
Verifying that it works (the function in the original question didn't correctly calculate angles, as VectorAngle
is not accounting for quadrants):
pts = {{1, 5}, {-1, .1}, {-.7, -0.1}};
arc = arc3v2[pts];
Show[
Sequence @@ Table[Graphics[{Red, Disk[pts[[i]], 0.1]}], {i, 3}],
Graphics[{Green, Disk[arc[[1]], 0.1]}],
Graphics[{LightGray, Circle[Sequence @@ Most@arc]}],
Graphics @ Circle[Sequence @@ arc],
Axes -> True]
Comments are welcome!