2
$\begingroup$

I am trying to plot a curved arrow on a wavy surface. I tried a couple of approaches using the Arrow command but the results are not aesthetically pleasing bec

  1. The arrow gets hidden from the view I want to see it from.Is it possible to plot an arrow that is always facing the camera in the desired "proper" way?
  2. The curve itself isn't very visible and produces artifacts with the surface. Is there a way to avoid this?

My code:

f[x_, y_] := Sin[x + y^2]/5;
Show[Plot3D[f[x, y], {x, -3, 3}, {y, -2, 2}, PlotPoints -> 70, 
  MeshStyle -> None, PlotStyle -> Opacity[0.8]],
 Graphics3D[{Black, Thickness[0.01], Arrowheads[0.05], 
   Arrow[Table[{0.5 + Cos[\[Theta]], Sin[\[Theta]], 
      f[0.5 + Cos[\[Theta]], Sin[\[Theta]]] + 0.01}, {\[Theta], 0, 
      2 \[Pi], \[Pi]/20}], {0, -0.1}]}]]

My image: enter image description here

$\endgroup$
2
  • $\begingroup$ We are unable to execute your code because you have not provided the definition for f[x, y] $\endgroup$
    – Bob Hanlon
    Commented Jan 5 at 0:20
  • $\begingroup$ Thanks for pointing that out. Updated. $\endgroup$ Commented Jan 5 at 18:51

2 Answers 2

4
$\begingroup$

Use a Tube with the Arrow

$Version

(* "13.3.1 for Mac OS X ARM (64-bit) (July 24, 2023)" *)

Clear["Global`*"]

f[x_, y_] := Cos[x]*Sin[y]

Show[
 Plot3D[Evaluate@f[x, y], {x, -3, 3}, {y, -2, 2},
  PlotPoints -> 70,
  MeshStyle -> None,
  PlotStyle -> Opacity[0.8]],
 Graphics3D[{Black, Thickness[0.01], Arrowheads[0.05],
   Arrow[Tube[
     Table[{0.5 + Cos[θ], Sin[θ], 
       f[0.5 + Cos[θ], Sin[θ]] + 0.01},
      {θ, 0, 2 π, π/20}], 0.025]]}]]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Great, this gave me the right idea on what to do. A couple of minor improvements: 1. Changing the color from black to something lighter makes the arrow looks aesthetically pleasing. 2. It is better to use Show[Graphics3D[...],Plot3D[...]] than the other way around because that produces good arrows regardless of plot range. $\endgroup$ Commented Jan 6 at 0:15
6
$\begingroup$

Here is one approach to avoid Graphics3D by using Mesh.

f[x_, y_] := Sin[x + y^2]; 
Plot3D[f[x, y], {x, -3, 3}, {y, -2, 2}, PlotPoints -> 70, 
  PlotStyle -> Opacity[0.8], 
  MeshFunctions -> Function[{x, y}, (x - .5)^2 + y^2], Mesh -> {{1}}, 
  MeshStyle -> Thick, BoundaryStyle -> None] /. 
 Line[pts_] :> {Arrowheads[{{.05, .75}}], Appearance -> "Projected", 
   Arrow[pts]}

enter image description here

$\endgroup$
1
  • $\begingroup$ Thanks for the suggestion. It solves issue 2 of my question very well. However, it isn't solving issue 1 yet. As your picture shows, the arrow isn't "in line" with the curve. Further, when I rotate the plot around, the arrow gets hidden and points perpendicular to the surface. $\endgroup$ Commented Jan 5 at 20:43

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.