0
$\begingroup$

I want to plot an ellipsoid and geodesic on it depending on a, b, c. What is wrong with my code? I mean there is problem with Manipulate, if I remove this command and parameters a, b, c, then everything works. But now it doesn't.

ellipsoid[{a_, b_, c_, u_, v_}] := {a*Cos[u]*Cos[v], b*Cos[u]*Sin[v], 
      c*Sin[u]}

    Needs["VariationalMethods`"]

    eq = EulerEquations[Sqrt[Total[D[ellipsoid[{u, v[u]}], u]^2]], v[u], u];
    pts = {{2, 2}, {3, 6}};
    geodesic[{{u1_, v1_}, {u2_, v2_}}] := 
     Module[{start, g, sol}, 
      If[u2 < u1, Return[geodesic[{{u2, v2}, {u1, v1}}]]];
      sol = ParametricNDSolve[Flatten[{eq, v[0] == v1, v'[0] == l}], 
        v, {u, 0, u2 - u1}, {l}];
      start = l /. FindRoot[Evaluate[(v[l][u2 - u1] - v2 /. sol)], {l, 0}];
      g = v[start] /. sol;
      Function[t, {u1 + t*(u2 - u1), g[t*(u2 - u1)]}]]
    Manipulate[Show[ParametricPlot3D[
      torus[{a, b, c, u, v}], {u, -\[Pi], \[Pi]}, {v, -\[Pi], \[Pi]}, 
      PlotStyle -> White, ImageSize -> 500], 
     ParametricPlot3D[Evaluate[ellipsoid[geodesic[pts][t]]], {t, 0, 1}, 
      PlotStyle -> Red], {a, 1, 15}, {b, 1, 15}, {c, 1, 15}]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.