3
$\begingroup$

I am trying to plot a vector field over a torus. Here is my code and the image it produces:

f[x_, y_, z_] = x^2 + y^2 + z^2;
x[u_, v_] = 4 + (3 + Cos[v]) Sin[u];
y[u_, v_] = 4 + (3 + Cos[v]) Cos[u];
z[u_, v_] = 4 + Sin[v];

ParametricPlot3D[{4 + (3 + Cos[v]) Sin[u], 4 + (3 + Cos[v]) Cos[u], 
  4 + Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, 
 PlotStyle -> 
  Texture[
   StreamPlot[
    Evaluate[D[f[x[u, v], y[u, v], z[u, v]], {{u, v}}]], {u, 0, 
     2 Pi}, {v, 0, 2 Pi}, Frame -> None, ImageSize -> Large]], 
 Mesh -> None, ImageSize -> Large, PlotPoints -> 100, 
 PlotRange -> {{0, 8}, {0, 8}, {0, 7}}]

enter image description here

The vector field isn't plotted around the outside of the torus, how do I get Mathematica to plot the entire vector field?

$\endgroup$

1 Answer 1

4
$\begingroup$

PlotRangePadding -> None.

StreamPlot[
 Evaluate[D[f[x[u, v], y[u, v], z[u, v]], {{u, v}}]], {u, 0, 
  2 Pi}, {v, 0, 2 Pi}, ImageSize -> Large, PlotRangePadding -> None]

enter image description here

ParametricPlot3D[{4 + (3 + Cos[v]) Sin[u], 4 + (3 + Cos[v]) Cos[u], 
  4 + Sin[v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, 
 PlotStyle -> 
  Texture[StreamPlot[
    Evaluate[D[f[x[u, v], y[u, v], z[u, v]], {{u, v}}]], {u, 0, 
     2 Pi}, {v, 0, 2 Pi}, Frame -> None, ImageSize -> Large, 
    PlotRangePadding -> None]], Mesh -> None, ImageSize -> Large, 
 PlotPoints -> 100, PlotRange -> {{0, 8}, {0, 8}, {0, 7}}]

enter image description here

$\endgroup$

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.