1
$\begingroup$

Here is what I have tried thus far:

Manipulate[
 Graphics[{
   Black,
   Arrow[{{-5, 0}, {5, 0}}],
   Arrow[{{0, -5}, {0, 5}}],
   Blue,
   Arrow[{{0, 0}, arrowA}],
   Arrow[{{0, 0}, arrowB}]
   }],
 {{arrowA, {3, 3}}, Locator},
 {{arrowB, {-3, 3}}, Locator},
 FrameLabel -> {{None, None}, {None, 
    Row["\[Theta] = ", 
     ArcCos[(arrowA.arrowB)/(Norm[arrowA] Norm[arrowB])]]}}
 ]

Which produces the following image.

enter image description here

It doesn't calculate the angle. Any suggestions?

Due to helpful suggestions: The suggestions get me to this point.

Manipulate[
 Graphics[{Black, Arrow[{{-5, 0}, {5, 0}}], Arrow[{{0, -5}, {0, 5}}], 
   Blue, Arrow[{{0, 0}, arrowA}], 
   Arrow[{{0, 0}, arrowB}]}], {{arrowA, {3, 3}}, 
  Locator}, {{arrowB, {-3, 3}}, Locator}, 
 FrameLabel -> {{None, None}, {None, 
    Row["\[Theta] = ", 
     Dynamic[N[
       ArcCos[(arrowA.arrowB)/(Norm[arrowA] Norm[arrowB])]/
        Degree]]]}}]

enter image description here

But I just want $\theta=90$, not the Row and the Brackets.

Any further suggestions?

$\endgroup$
5
  • 1
    $\begingroup$ Do Dynamic@ArcCos[(arrowA.arrowB)/(Norm[arrowA] Norm[arrowB])] $\endgroup$
    – N.J.Evans
    Commented May 28, 2015 at 22:16
  • 1
    $\begingroup$ Row[{"\[Theta] = ", Dynamic[ArcCos[(arrowA.arrowB)/(Norm[arrowA] Norm[arrowB])]]}]? $\endgroup$
    – kglr
    Commented May 28, 2015 at 22:20
  • $\begingroup$ @kguler: Almost. See your idea in my original post above. How do I get rid of the Row and the Brackets? $\endgroup$
    – David
    Commented May 28, 2015 at 22:41
  • $\begingroup$ As a second question, is it possible to put some code prior to the Graphics block that I could use in the Frame title without the use of Dynamic? $\endgroup$
    – David
    Commented May 28, 2015 at 22:43
  • 1
    $\begingroup$ Dynamic[Row[{"\[Theta] = ", N[ArcCos[(arrowA.arrowB)/(Norm[arrowA] Norm[arrowB])]/Degree]}]] $\endgroup$ Commented May 28, 2015 at 23:02

1 Answer 1

2
$\begingroup$

The 1-st argument given to Row must be a list.

Manipulate[
  Graphics[{
    Black, Arrow[{{-5, 0}, {5, 0}}], Arrow[{{0, -5}, {0, 5}}], 
    Blue, Arrow[{{0, 0}, arrowA}], Arrow[{{0, 0}, arrowB}]}], 
  {{arrowA, {3, 3}}, Locator},
  {{arrowB, {-3, 3}}, Locator}, 
  FrameLabel -> {{None, None}, {None, 
    Row[{"θ = ", 
      Dynamic[ArcCos[(arrowA.arrowB)/Norm[arrowA]/Norm[arrowB]]/
        N @ Degree], "°"}]}}]

graphics

Update

Just a suggestion, but I think the label looks better when the Row expression is written to round the angle to the nearest degree.

Row[{
  "θ = ", 
  Dynamic[Round[ArcCos[(arrowA.arrowB)/Norm[arrowA]/Norm[arrowB]]/N @ Degree]], 
  "°"}]
$\endgroup$
5
  • $\begingroup$ Perfect! Thanks to everyone who helped. $\endgroup$
    – David
    Commented May 28, 2015 at 23:10
  • 2
    $\begingroup$ @David, you might be interested to know that VectorAngle[] is built-in… $\endgroup$ Commented May 28, 2015 at 23:22
  • $\begingroup$ @Guesswhoitis. How do you guys highlight VectorAngle[]. I've often seen this, but don't know how to do it. Think it would be good if I knew how. $\endgroup$
    – David
    Commented May 28, 2015 at 23:38
  • $\begingroup$ @m_goldberg: I had just tried this: Row[{"[Theta] = ", Dynamic[NumberForm[ ArcCos[(arrowA.arrowB)/Norm[arrowA]/Norm[arrowB]]/N@Degree, {3, 1}]], "[Degree]"}] $\endgroup$
    – David
    Commented May 28, 2015 at 23:40
  • $\begingroup$ We just enclose them in backticks (`), @David. $\endgroup$ Commented May 28, 2015 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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