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.

My main problem is: I plotted a curve here, but the tip of some arrows are missing. Why does this happen, and how can I fix this?

Not the main problem: Also, I once tried to make the arrows with different colors, but all of them would be of the same color as the first one. How can I make them different colors? And I have a strong impression that I'm not being intelligent using Graphics3D all this much, for every single arrow. It must have a cleaner way to do it. (Maybe I should ask a different question for this, but I don't want to flood the site. If you can help me with the main problem, I'll be happy already)

[EDIT: wxffles already helped me with this issue in the comments. What is left is the main problem now.]

enter image description here

The code as it is now, in case it helps:

a[t_] := {1 + Cos[t], Sin[t], 2 Sin[t/2]}
tf[t_] := {(-Sin[t])/(Sqrt[1 + Cos[t/2]^2]), (Cos[t])/(Sqrt[
     1 + Cos[t/2]^2]), (Cos[t/2])/(Sqrt[1 + Cos[t/2]^2])}
bf[t_] := 
 Rationalize@{(-0.5 Cos[t] Sin[t/2] + Cos[t/2] Sin[t])/ 
    Sqrt[1.625 + 0.375 Cos[t]], (-Cos[t/2] Cos[t] - 
      0.5 Sin[t/2] Sin[t])/Sqrt[1.625 + 0.375 Cos[t]], 
   1/Sqrt[1.625 + 0.375 Cos[t]]}
nf[t_] := {-((3 + 12 Cos[t] + Cos[2 t])/(
   2 Sqrt[3 + Cos[t]] Sqrt[13 + 3 Cos[t]])), -(((6 + Cos[t]) Sin[t])/(
   Sqrt[3 + Cos[t]] Sqrt[13 + 3 Cos[t]])), -((2 Sin[t/2])/(
   Sqrt[3 + Cos[t]] Sqrt[13 + 3 Cos[t]]))}    


Show[ParametricPlot3D[{1 + Cos[t], Sin[t], 2 Sin[t/2]}, {t, 0, 
       4 \[Pi]}, 
      PlotStyle -> Directive[RGBColor[0.91`, 0.`, 0.`], Opacity[1.`]], 
      BoxRatios -> {1, 1, 1}, Boxed -> False, AxesOrigin -> {0, 0, 0}], 
     Graphics3D[Arrowheads[0.02], Arrow[{a[0], a[0] + tf[0]}]], 
     Graphics3D[Arrow[{a[0], a[0] + tf[0]}]], 
     Graphics3D[Arrow[{a[1], a[1] + tf[1]}]], 
     Graphics3D[Arrow[{a[Pi/2], a[Pi/2] + tf[Pi/2]}]], 
     Graphics3D[Arrow[{a[2], a[2] + tf[2]}]], 
     Graphics3D[Arrow[{a[Pi], a[Pi] + tf[Pi]}]], 
     Graphics3D[Arrow[{a[3 Pi/2], a[3 Pi/2] + tf[3 Pi/2]}]], 
     Graphics3D[Arrow[{a[2 Pi], a[2 Pi] + tf[2 Pi]}]], 
     Graphics3D[Arrow[{a[0], a[0] + bf[0]}]], 
     Graphics3D[Arrow[{a[0], a[0] + bf[0]}]], 
     Graphics3D[Arrow[{a[1], a[1] + bf[1]}]], 
     Graphics3D[Arrow[{a[Pi/2], a[Pi/2] + bf[Pi/2]}]], 
     Graphics3D[Arrow[{a[2], a[2] + bf[2]}]], 
     Graphics3D[Arrow[{a[Pi], a[Pi] + bf[Pi]}]], 
     Graphics3D[Arrow[{a[3 Pi/2], a[3 Pi/2] + bf[3 Pi/2]}]], 
     Graphics3D[Arrow[{a[2 Pi], a[2 Pi] + bf[2 Pi]}]], 
     Graphics3D[Arrow[{a[0], a[0] + nf[0]}]], 
     Graphics3D[Arrow[{a[0], a[0] + nf[0]}]], 
     Graphics3D[Arrow[{a[1], a[1] + nf[1]}]], 
     Graphics3D[Arrow[{a[Pi/2], a[Pi/2] + nf[Pi/2]}]], 
     Graphics3D[Arrow[{a[2], a[2] + nf[2]}]], 
     Graphics3D[Arrow[{a[Pi], a[Pi] + nf[Pi]}]], 
     Graphics3D[Arrow[{a[3 Pi/2], a[3 Pi/2] + nf[3 Pi/2]}]], 
     Graphics3D[Arrow[{a[2 Pi], a[2 Pi] + nf[2 Pi]}]]]

Thanks for your time.

share|improve this question
1  
PlotRange -> All? –  wxffles Aug 25 at 21:15
1  
Graphics3D can take a list of primitives, so you don't need a separate Graphics3D for each arrow. You can also have nested lists to provide scoping for your styling. E.g. Graphics3D[{{Red, Arrow[...]}, Arrow[...], ...}] –  wxffles Aug 25 at 21:22
    
Hey, thanks! Your comment really helped me (: –  Ivo Terek Aug 25 at 21:29

1 Answer 1

up vote 3 down vote accepted

Let me shorten your example a little bit

par =
  ParametricPlot3D[{1 + Cos[t], Sin[t], 2 Sin[t/2]}, {t, 0, 4 \[Pi]},
   PlotStyle -> Red,
   Boxed -> False,
   AxesOrigin -> {0, 0, 0},
   AspectRatio -> 1];

arr =
  Graphics3D[
   {
    Arrowheads[0.02],
    {Red, Arrow[{a[0], a[0] + tf[0]}]},
    {Green, Arrow[{a[1], a[1] + tf[1]}]},
    {Blue, Arrow[{a[Pi/2], a[Pi/2] + tf[Pi/2]}]},
    {Black, Arrow[{a[2 Pi], a[2 Pi] + nf[3 Pi]}]}
    }];

Show[par, arr, PlotRange -> All]

enter image description here

share|improve this answer
    
Great. I didn't knew that you could name the graph and do something like Show[par, arr, PlotRange -> All], also. Very helpful and instructive. (: –  Ivo Terek Aug 25 at 21:40
    
@IvoTerek Thanks :) –  eldo Aug 25 at 21:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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