Message Boards Message Boards

Draw a line connecting Earth and Mars in SolarSystemPlot3D?

Posted 2 years ago
ResourceFunction["SolarSystemPlot3D"][{Blue, Sphere[Entity["Planet", "Earth"], 0.05], Red, Sphere[Entity["Planet", "Mars"],0.06]},
    PlotRange->1.8,ViewPoint->Above,Boxed->False,"IncludeSun"->True,"IncludeReferenceObjects"->False,
    "SunStyle"->{Hue[.14],Lighting->{{"Ambient",GrayLevel[.3]},{"Directional",White,ImageScaled[{0,0,1}]}},Sphere[{0,0,0},.1]}
    ]
    Graphics[Line[{{Entity["Planet","Earth"]},{Entity["Planet","Mars"]}}]]

Result: image

As you see, in the codes I tried to connect Earth and Mars with a line, but failed. Also, Mathematica didn't return any error warning. Is there a way to connect them?

POSTED BY: L L

One way would be to figure out the necessary information of the respective planet from the output of

Entity["Planet", "Earth"]["Properties"]

But if you just want this connecting line, it it probably easier to use some kind of "reverse engineering" and do it simply like so:

ssp = ResourceFunction["SolarSystemPlot3D"][{Blue, 
    Sphere[Entity["Planet", "Earth"], 0.05], Red, 
    Sphere[Entity["Planet", "Mars"], 0.06]}, PlotRange -> 1.8, 
   ViewPoint -> Above, Boxed -> False, "IncludeSun" -> True, 
   "IncludeReferenceObjects" -> False, "SunStyle" -> {Hue[.14], 
     Lighting -> {{"Ambient", GrayLevel[.3]}, {"Directional", White, 
        ImageScaled[{0, 0, 1}]}}, Sphere[{0, 0, 0}, .1]}];

connLine = Line[Most@Cases[ssp, Sphere[pos_, rad_] :> pos, Infinity]];
Show[ssp, Graphics3D[{Dashed, connLine}]]

enter image description here

POSTED BY: Henrik Schachner
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract