1
$\begingroup$

I have a question concerning Tooltip. I got a ParametricPlot and included two pictures and a dynamic point.

I try to use Tooltip for each of those 2 Objects. But it doesn't work. I am not quite sure, how to include the command in my code.

erde = ImageCrop[Import["https://cdn.goconqr.com/uploads/slide_property/image/8468/1d8af5e5-90e8-49f9-b20d-c3cef7fd7087.jpg"]];

arenstorf[y10_,y20_,y30_,y40_,mu_,tend_,ein_]:=Block[{problem,solArens,out},


  problem= {y1'[t] == y2[t],
  y2'[t] == 
  y1[t] + 2*y4[t] - 
  (1-mu)*(y1[t] + mu)/((y1[t] + mu)^2 + (y3[t])^2)^(3/2) - 
  mu*(y1[t] - (1-mu))/((y1[t] - (1-mu))^2 + (y3[t])^2)^(3/2),
  y3'[t] == y4[t],
  y4'[t] == 
  y3[t] - 2*y2[t] - 
  (1-mu)*(y3[t] )/((y1[t] + mu)^2 + (y3[t])^2)^(3/2) - 
  mu*(y3[t] )/((y1[t] - (1-mu))^2 + (y3[t])^2)^(3/2),
  y1[0] == y10,
  y2[0] == y20,
  y3[0] == y30,
  y4[0] == y40};

 solArens = NDSolve[problem,
  {y1, y2, y3, y4},
  {t, 0, tend}];

out= {ParametricPlot[
      Evaluate[{y1[t],y3[t]}/.solArens],{t,0,tend},
      Frame->False,PlotPoints->40,
      Epilog-> 
        {PointSize[0.02],Black,Tooltip[Point/@({y1[ein],y3[ein]}/.solArens),
        "Satellit"]},
      Prolog ->  {
        Texture[erde],
        Polygon[{{-mu-.03, -.03}, {-mu+.03, -.03}, {-mu+.03,.03},
        {-mu-.03, .03}},
        VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}, {0, 1}}
        ]}
      ] };
Return[out]]

Manipulate[arenstorf[0.994,0,0,-2.1139 ,0.012277471,5.4368,zeit],{zeit,0,5.4368}]  

The point should move dynamically in the plot. Could anybody help me?

Thanks

$\endgroup$
3
  • $\begingroup$ There are several undefined variables in your code block. Please add values for these, or, even better, modify the code to be a minimal working example for your problem. The easier it is for others to replicate the issue the more likely you'll get some help. $\endgroup$
    – Karsten7
    Jan 9, 2016 at 11:52
  • $\begingroup$ Thank you, I will change the code to a working example. $\endgroup$
    – gumpel
    Jan 9, 2016 at 15:39
  • $\begingroup$ @BobHanlon now it is really working. Sorry! $\endgroup$
    – gumpel
    Jan 9, 2016 at 16:39

1 Answer 1

1
$\begingroup$

I added the Tooltip to the Prolog and added satellite location to Tooltip in Epilog. I cleaned up the code a bit by removing unnecessary parts. To see the Tooltip you must put the pointer over the object. To see the Texture the ImageSize must be very large.

erde = ImageCrop[
   Import[
    "https://cdn.goconqr.com/uploads/slide_property/image/8468/1d8af5e5-90e8-\
49f9-b20d-c3cef7fd7087.jpg"
    ]];

arenstorf[y10_, y20_, y30_, y40_, mu_, tend_, ein_] :=
 Block[
  {problem, solArens, pt},
  problem = {
    y1'[t] == y2[t],
    y2'[t] == y1[t] + 2*y4[t] - (1 - mu)*(y1[t] + mu)/
        ((y1[t] + mu)^2 + (y3[t])^2)^(3/2) -
      mu*(y1[t] - (1 - mu))/((y1[t] - (1 - mu))^2 + (y3[t])^2)^(3/2),
    y3'[t] == y4[t],
    y4'[t] == y3[t] - 2*y2[t] - (1 - mu)*(y3[t])/
        ((y1[t] + mu)^2 + (y3[t])^2)^(3/2) -
      mu*(y3[t])/((y1[t] - (1 - mu))^2 + (y3[t])^2)^(3/2),
    y1[0] == y10, y2[0] == y20, y3[0] == y30, y4[0] == y40};
  solArens = NDSolve[
     problem, {y1, y2, y3, y4}, {t, 0, tend}][[1]];
  (*  [[1]] removes outer list brackets  *)
  ParametricPlot[
   {y1[t], y3[t]} /. solArens,
   {t, 0, tend},
   Frame -> False,
   PlotPoints -> 40,
   Epilog -> {PointSize[0.02], Black,
     Tooltip[
      Point[pt = {y1[ein], y3[ein]} /. solArens],
      "Satellit\n" <> ToString[pt]]},
   Prolog -> {
     Texture[erde],
     Tooltip[
      Polygon[{{-mu - .03, -.03}, {-mu + .03, -.03},
        {-mu + .03, .03}, {-mu - .03, .03}},
       VertexTextureCoordinates ->
        {{0, 0}, {1, 0}, {1, 1}, {0, 1}}],
      "Erde"]},
   ImageSize -> 2000 (* large ImageSize needed to see Texture in Prolog *)]]

Manipulate[
 arenstorf[0.994, 0, 0, -2.1139, 0.012277471, 5.4368, zeit],
 {zeit, 0, 5.4368, Appearance -> "Labeled"}]
$\endgroup$
4
  • $\begingroup$ Hello, I tried the following: Epilog->{PointSize[0.02],Black,Tooltip[Point[#], "Satellit"]&/@({y1[ein],y3[ein]}/.solArens)} but it doesn't work. Is your example working for a set of point or for a "dynamic point" too? I gues I don't quite understand the part "& /@ pts".. $\endgroup$
    – gumpel
    Jan 9, 2016 at 15:34
  • $\begingroup$ Sorry, I answered your question before editing the code. Now my example is working. I hope my question get clearer now :) $\endgroup$
    – gumpel
    Jan 9, 2016 at 16:05
  • $\begingroup$ Thanks for all your effors @BobHanlon. Does this code work on your machine? I tried it out on Mathematica Online and the Tooltip-option didn't work. I'll try it out on another machine tomorrow and will report, if it was successful. :) $\endgroup$
    – gumpel
    Jan 10, 2016 at 11:19
  • $\begingroup$ @Merlin - I just copied the above code into a notebook and it evaluated just fine. $\endgroup$
    – Bob Hanlon
    Jan 10, 2016 at 16:48

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.