[Tex/LaTex] Draw a spiral on a sphere

asymptotegraphicspgfplotsplottikz-pgf

My goal is to visualize damped magnetic precession.

Wikipedia features an image, but it doesn't quite capture one essential constraint.
Namely, that the magnetization M should be normalized. So the curve shown in the following picture should lie on the sphere.

damped precession

So what I want to show is:

  • The vectors M and H_eff with M on the sphere.
  • A spiral lying on a sphere.
  • -M x H_eff being orthogonal to M and H_eff
  • M x dM/dt pointing towards H_eff (This is not exactly correct, but rather an approximation).

The tangent of the spiral at the endpoint of M should be a linear combination of MxdM/dt and -MxH_eff (to be more exact: alpha MxdM/dt – MxH_eff for some positive alpha), so the picture on Wikipedia looks fine concerning this requirement.

I have found a similar picture in the following answer:
https://tex.stackexchange.com/a/56617/50081

How can this be achieved with any of the modern plotting tools for LaTeX?

Edit:
As Christian pointed out one could start by generating the spiral via projection of a flat spiral. This is my first try using pgfplots.

\documentclass{minimal}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\xdef\w{10}

\begin{axis}[%
    axis equal,
    axis lines = none,
    xlabel = {$x$},
    ylabel = {$y$},
    zlabel = {$z$},
    enlargelimits = 0.5,
    ticks=none,
]
    \addplot3[%
        opacity = 0.2,
        surf,
        z buffer = sort,
        samples = 21,
        variable = \u,
        variable y = \v,
        domain = 0:180,
        y domain = 0:360,
    ]
    ({cos(u)*sin(v)}, {sin(u)*sin(v)}, {cos(v)});

    \addplot3+[color=blue,domain=0:4*pi, samples=100, samples y=0,no marks, smooth](
        {x*cos(deg(x))/sqrt(\w*\w+x*x)},
        {x*-sin(deg(x))/sqrt(\w*\w+x*x)},
        {\w/sqrt(\w*\w+x*x)}
        );
\end{axis}
\end{tikzpicture}
\end{document}

Best Answer

Here's an attempt using Asymptote. I took literally your statement that "any spirally shape" would be okay. To compile it, save the code below in a file called (e.g.) filename.tex and then run pdflatex --shell-escape filename. (Also, make sure you have Asymptote installed.)

\documentclass[margin=10pt,convert]{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=sphere_spiral}
    settings.outformat = "png";
    settings.render = 16;
    import graph3;
    size(10cm);

    triple eye = (5,2,3);
    currentprojection=orthographic(eye);

    surface hemisphere = surface(Arc(X,-X,c=O,normal=Z,n=16), c=O, axis=X, angle1=0, angle2=180);
    draw(shift(-5 eye)*hemisphere, material(white + opacity(0.5), emissivepen=0.2 white));

    usepackage("amsmath");  //for \text command
    draw(O -- 1.6Z, arrow=Arrow3, L=Label("$H_{\text{eff}}$", align=W, position=EndPoint));

    real theta(real t) { return t/20; }
    real phi(real t) { return -t + 1; }
    real r(real t) { return 1; }
    triple F(real t) { return polar(r(t), theta(t), phi(t)); }

    path3 spiral = reverse(graph(F, 0, 4pi, operator ..));
    draw(spiral, blue + dotted + linewidth(1pt));

    real t = 0.1;
    triple arrowpos = point(spiral, reltime(spiral, t));
    add(arrow(arrowhead=TeXHead2(normal=arrowpos), g=spiral, p=invisible, 
        arrowheadpen=emissive(blue), FillDraw(blue), position=Relative(t)));

    t = 0.7;
    arrowpos = point(spiral, reltime(spiral, t));
    add(arrow(arrowhead=TeXHead2(normal=arrowpos), g=spiral, p=invisible, 
        arrowheadpen=emissive(blue), FillDraw(blue), position=Relative(t)));

    triple M = point(spiral, 0);
    draw(O -- M, arrow=Arrow3, L=Label("$M$", position=MidPoint));
    draw(shift(M) * (O -- 0.5 cross(-M, Z)), red, arrow=Arrow3, L=Label("$-M \times H_{\text{eff}}$", position=MidPoint));
    triple dMdt = dir(spiral,0);
    triple crossprod = cross(M, dMdt);
    draw(shift(M) * (O -- 0.5 crossprod), blue, arrow=Arrow3, L=Label("$M \times \frac{dM}{dt}$", position=MidPoint));
\end{asypicture}
\end{document}

The result:

enter image description here