2
$\begingroup$

The following is nearly what I am after, but the angles don't behave quite as I'd like:

r[a_, b_] := RegionNearest[Circle[{0, 0}, 1], a[[b]]];
Manipulate[Graphics[{Circle[{0, 0}, 1],
   Line /@ {{Join[{{0, 0}}, a, {{0, 0}}]}},
   Circle[{0, 0}, 1/4, {
     If[a[[3, 2]] < 0, -#, #] &@VectorAngle[{1, 0}, a[[3]]], 
     If[a[[1, 2]] < 0, -#, #] &@VectorAngle[{1, 0}, a[[1]]]}],
   Circle[a[[2]], 1/4, {
     If[a[[3, 2]] - 1 < 0, -#, #] &@ VectorAngle[{1, 0}, {0, -1} + a[[3]]], 
     If[a[[1, 2]] - 1 < 0, -#, #] &@ VectorAngle[{1, 0}, {0, -1} + a[[1]]]}]
   }, PlotRange -> 1.1],
  {{a, CirclePoints[3]}, Locator,
    TrackingFunction -> (Switch[CurrentValue["CurrentLocatorPaneThumb"],
    1, a[[1]] = r[#, 1],
    2, a[[2]] = r[#, 2],
    3, a[[3]] = r[#, 3]
  ] &), Appearance -> None}]

Is there a more straightforward way to go about this, or is VectorAngle the simplest?

$\endgroup$
  • $\begingroup$ Huh? What are you trying to accomplish? $\endgroup$ – David G. Stork Nov 22 '17 at 16:22
  • $\begingroup$ @DavidG.Stork I'm trying to get the angles to move with the points - dragging the top angle is not right (remove Appearance -> None to show locators). $\endgroup$ – martin Nov 22 '17 at 19:33
4
$\begingroup$

Does this approximate what you want? It is not the most efficient. Since you're always referencing to {1,0} with VectorAngle, why not just use ArcTan. I used a couple of helper functions from messing with circular arcs for Indra's Pearls.

r[a_, b_] := RegionNearest[Circle[{0, 0}, 1], a[[b]]];

ang[p_, q_] := 
   Block[{a, b}, 
         If[(a = N[ArcTan @@ p]) < 0, a = a + 2 Pi];
         If[(b = N[ArcTan @@ q]) < 0, b = b + 2 Pi];
         If[b < a, {a, b + 2 Pi}, {a, b}]]

ang1[p_, q_] := 
   Block[{a, b}, 
         If[(a = N[ArcTan @@ p]) < 0, a = a + 2 Pi];
         If[(b = N[ArcTan @@ q]) < 0, b = b + 2 Pi];
         {a, b} = Sort[{a, b}];
         If[b - a > Pi, {b, a + 2 Pi}, {a, b}]]

Manipulate[
   Graphics[{Thick,
      Circle[{0, 0}, 1], 
      Line /@ {{Join[{{0, 0}}, a, {{0, 0}}]}}, Blue, 
      Circle[{0, 0}, 1/4, ang[a[[1]], a[[3]]]], Red, 
      Circle[a[[2]], 1/8, ang1[a[[1]] - a[[2]], a[[3]] - a[[2]]]]}, 
      PlotRange -> 1.1], {{a, CirclePoints[3]}, Locator, 
      TrackingFunction -> (Switch[CurrentValue["CurrentLocatorPaneThumb"],
         1, a[[1]] = r[#, 1],
         2, a[[2]] = r[#, 2],
         3, a[[3]] = r[#, 3]] &), Appearance -> None}]

interior angles

|improve this answer|||||
$\endgroup$
  • $\begingroup$ very nice! Thank you! $\endgroup$ – martin Nov 22 '17 at 22:17
  • $\begingroup$ slight anomoly moving top angle (red) about {0,1} - unsure how to fix? $\endgroup$ – martin Nov 22 '17 at 22:33
  • $\begingroup$ Not sure what you mean. One problem occurs when two points are very close to the red arc. In this case, the arc can be too large. That is why I reduced its radius from your 1/4 to 1/8. $\endgroup$ – KennyColnago Nov 23 '17 at 2:58
  • $\begingroup$ My mistake - yes - it works better at 1/8! $\endgroup$ – martin Nov 23 '17 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.