Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to plot a vector on the unit circle, depending on an angle Pi/k, and the same vector rotated by an angle d. I try the following:

k = 0.9; d = 0.3;
pt = {Sin[Pi/k], Cos[Pi/k]};
pt2 = {pt[[1]]*Cos[d] + pt[[2]]*Sin[d], 
pt[[2]]*Cos[d] - pt[[1]]*Sin[d]};

Graphics[Arrow[{{0, 0}, pt, {0, 0}, pt2}], Axes -> True, 
AxesLabel -> {x, z}, PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}]

In some cases, like when k=0.9 and d=0.3 as above, this almost works, except that the first vector has no arrowhead, only a line (see figure). In other cases, as when k=1, Only the second vector is drawn. Can anyone see what the problem is?

The plotted vectors

share|improve this question

closed as off-topic by m_goldberg, PlatoManiac, Artes, rm -rf Nov 26 '13 at 20:35

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, PlatoManiac, Artes, rm -rf
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
You have small mistake with the order of the points. Try this! Graphics[{{Dashed, Circle[]}, Arrow /@ {{{0, 0}, pt}, {{0, 0}, pt2}}}, Axes -> True, AxesLabel -> {x, z}, PlotRange -> {{-1.1, 1.1}, {-1.1, 1.1}}] –  PlatoManiac Nov 26 '13 at 17:04
    
That works perfectly, thanks! –  jorgen Nov 26 '13 at 17:06

1 Answer 1

up vote 2 down vote accepted
f[k_, d_] := Graphics[{Circle[], #, Dashed, Rotate[#, d, {0, 0}]} &@ 
                                                            Arrow[{{0, 0}, {Sin[Pi/k], Cos[Pi/k]}}]]

f[.9, .3]

enter image description here


f[k_, d_, c_] := Graphics[{Circle[], Thick, c, #, Dashed, Rotate[#, d, {0, 0}]} &@
                         Arrow[{{0, 0}, {Sin[k 2 Pi/11], Cos[k 2 Pi/11]}}]]
Export["c:\\test.gif", 
       Flatten@Table[(SeedRandom@k;c = RGBColor[Sequence @@ RandomReal[1, {3}]]; 
                     f[k, d, c]), {k, 1, 11}, {d, 2 Pi, 0, -Pi/12}], 
      "DisplayDurations" -> .2]

enter image description here

share|improve this answer

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