5
$\begingroup$

I have this:

f[x_, y_] = x y/(x^2 + y^2);
ParametricPlot3D[{t, 2 t, f[t, 2 t]}, {t, -1/2, Sqrt[0.002]},
  PlotStyle -> Directive[Red, Thick]] /. Line -> Tube

Which works, but I would like an arrowhead at the end of the tube. What do I have to add?

And maybe I want the arrow of the tube? I do want a three dimensional tubular arrowhead which is normally done with Graphics3d[{Arrow[Tube[ ....

Difficulty with Composition:

f[x_, y_] = x y/(x^2 + y^2);
Show[
 Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1},
  PlotStyle -> Opacity[0.5],
  MeshStyle -> Opacity[0.5],
  MeshFunctions -> Function[{x, y, z}, z],
  RegionFunction -> Function[{x, y, z}, x^2 + y^2 > 0.01],
  AxesLabel -> {"x", "y", "z"},
  ViewPoint -> {2.3, -2.4, 0.7}],
 ParametricPlot3D[{t, 2 t, f[t, 2 t]}, {t, -1/2, -Sqrt[0.002]}, 
   PlotStyle -> Directive[Red, Thickness[0.02]]] /. 
  Line -> Composition[Arrow, Tube],
 Graphics3D[{
   Blue, Arrow[Tube[{{1, 0, 0}, {0.1, 0, 0}}, 0.02]],
   Blue, Arrow[Tube[{{0, -1, 0}, {0, -0.1, 0}}, 0.02]]
   }]
 ]

Which produces:

enter image description here

Apparently, I can't control the thickness this way?

Difficulty with Graphics3D Method:

f[x_, y_] = x y/(x^2 + y^2);
Show[
 Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1},
  PlotStyle -> Opacity[0.5],
  MeshStyle -> Opacity[0.5],
  MeshFunctions -> Function[{x, y, z}, z],
  RegionFunction -> Function[{x, y, z}, x^2 + y^2 > 0.01],
  AxesLabel -> {"x", "y", "z"},
  ViewPoint -> {2.3, -2.4, 0.7}],
 Graphics3D[{
   Blue, Arrow[Tube[{{1, 0, 0}, {0.1, 0, 0}}, 0.02]],
   Blue, Arrow[Tube[{{0, -1, 0}, {0, -0.1, 0}}, 0.02]],
   Red, Arrowheads[.04], 
   Arrow[Tube[
     Table[{t, 2 t, 
       f[t, 2 t]}, {t, -1/2, -Sqrt[0.002]}], .02], {0, -0.1}]
   }]
 ]

Which produces:

enter image description here

For some reason, the red arrow is not showing up. My Bad: Turns out I had only one point produced by my table.

$\endgroup$
  • 2
    $\begingroup$ Use Composition[Arrow, Tube] instead in the replacement rule. $\endgroup$ – J. M. will be back soon Jul 10 '15 at 5:53
  • 1
    $\begingroup$ Change Tube to Arrow@*Tube $\endgroup$ – Szabolcs Jul 10 '15 at 5:53
  • 1
    $\begingroup$ Also the same, change the replacement rule by /. Line[x__] :> Arrow[Tube[x]] $\endgroup$ – Dr. belisarius Jul 10 '15 at 6:05
  • 1
    $\begingroup$ @Szabolcs Could you please comment, what does this construct @* do? $\endgroup$ – Alexei Boulbitch Jul 10 '15 at 7:30
  • 1
    $\begingroup$ @AlexeiBoulbitch In version 10 and later, f @* g is short for Composition[f,g]. $\endgroup$ – Szabolcs Jul 10 '15 at 7:35
6
$\begingroup$

My experiments with this question indicate that something more than simple composition of Arrow and Tube is needed. What I came up with is

ParametricPlot3D[{Cos[t], Sin[t], t/4}, {t, 0, 2 π},
  PlotRange -> All, 
  PlotStyle -> Directive[{Red, Arrowheads[.08]}]] /. 
  Line[pts_] :> Arrow[Tube[pts, .04], {0, -.1}]

which produces

plot

Of course, this can also be reproduced directly and I think even more easily, with Graphics3D.

Graphics3D[{
  Red, Arrowheads[.08], 
  Arrow[Tube[Table[{Cos[t], Sin[t], t/4}, {t, 0, 2 π, π/20}], .04], {0, -.1}]}]

graphics

Update

Now that the OP has given us a definition of f, I can work with his real problem, for which I recommend

f[x_, y_] = x y/(x^2 + y^2);

Show[
  Plot3D[f[x, y], {x, -1, 1}, {y, -1, 1}, 
    PlotStyle -> Opacity[0.5], 
    MeshStyle -> Opacity[0.5], 
    MeshFunctions -> Function[{x, y, z}, z], 
    RegionFunction -> Function[{x, y, z}, x^2 + y^2 > 0.01], 
    AxesLabel -> {"x", "y", "z"}, 
    ViewPoint -> {2.3, -2.4, 0.7}], 
  Graphics3D[{
    Blue, Arrow[Tube[{{1, 0, 0}, {0.1, 0, 0}}, 0.02]], 
          Arrow[Tube[{{0, -1, 0}, {0, -0.1, 0}}, 0.02]],
    Red, Arrowheads[.04], 
         Arrow[
           Tube[
             Table[{t, 2 t, f[t, 2 t]}, {t, {-1/2, -Sqrt[0.004]}}], 
             .017], 
           {0, -0.05}]}],
  ImageSize -> Medium]

plot

$\endgroup$
  • $\begingroup$ For some reason, my arrow is not showing up in my image. See the updated example in my original post. $\endgroup$ – David Jul 10 '15 at 15:17

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.