Message Boards Message Boards

Print a variable in degrees on the canvas in Manipulate

I think I wrote everything right but I don't get the result I want... I want to print the value of an angle in degrees onto the canvas of Manipulate. But after many attempts, I always get the variable written in radians. (Sorry for the greek letter)

Manipulate[degree = Degree@\[Phi]; 
 Show[Graphics@Text[ToString[degree]]], {{\[Phi], 45 \[Degree]}, 
  0 \[Degree], 90 \[Degree]}]

Does not work as I intend...

JGuy

POSTED BY: Jean Guy Lussier
3 Replies

Degree is not a function--rather it is a parameter. So you do not want Degree@, (i.e., no @) and also yo want to divide by Degree in your definition of degree as in the following:

Manipulate[
 With[{degree = \[Phi]/Degree},
  Graphics@Text[ToString[degree]]], {{\[Phi], 45 Degree}, 0 Degree, 
  90 Degree}]

In this I also localized your definition of degree using With as well as removed the unnecessary Show.

POSTED BY: David Reiss
In[1]:= Manipulate[\[Phi] , {\[Phi], 0 Degree, 90 Degree, Degree}]

In[2]:= Manipulate[Graphics@Text@(ToString@(\[Phi]/Degree) Degree), {\[Phi], 0 Degree, 90 Degree, Degree}]

enter image description here

Another variation on the theme:

Manipulate[
 Graphics@Text[Row[{\[Phi], Degree}]], {{\[Phi], 45}, 0, 90}]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract