11
$\begingroup$

I made this Graphics3D of the Sun with the plotted orbits of a few astronomical objects.

otherCelestials = AstronomicalData["MinorPlanet"][[;; 10]];
Graphics3D[{
  {Yellow, Sphere[AstronomicalData["Sun", "Position"], 0.05]},
  AstronomicalData[#, "OrbitPath"] & /@ otherCelestials
  }, Axes -> True, SphericalRegion -> True]

enter image description here

I would like it to rotate around the sphere representing the sun's position though. At the moment the ViewCenter is somewhere next to the sun, which means that when you rotate the plot, it rotates around that point and not the sun. How can I make it so that it rotates around the sun?

(The obvious thing to do would be set the ViewCenter of the plot to the coordinates of the sun, but in this case the sun's coordinates are given as {0, 0, 0}, but that just makes the ViewCenter point to the corner of the graph.)

$\endgroup$
1
  • $\begingroup$ Yes I did, and I also just tried ViewCenter -> {{0.5, 0.5, 0.5}, {0.5, 0.5, 0.5}} to see whether that would make a difference, but neither of them did. $\endgroup$
    – Aron
    Commented Apr 18, 2014 at 16:11

1 Answer 1

12
$\begingroup$

Please tell me if this meets your needs, I feel it does:

Graphics3D[{{
   Yellow, Sphere[QuantityMagnitude @ AstronomicalData["Sun", "Position"], 0.05]},
   AstronomicalData[#, "OrbitPath"] & /@ otherCelestials
 },
  Axes -> True, SphericalRegion -> True,  ViewVector -> {{1, -2, 1}, {0, 0, 0}}
]

enter image description here


Manipulate[
 Graphics3D[{{
   Yellow, Sphere[QuantityMagnitude @ AstronomicalData["Sun", "Position"], 0.05]}, 
  Thick,  AstronomicalData[#, "OrbitPath"] & /@ otherCelestials
  }, 
  SphericalRegion -> True, 
  ViewVector -> Dynamic[{2.5 {Cos@t, Sin@t, 1}, {0, 0, 0}}, None],  
  ViewVertical -> {0, 0, 1}, ViewAngle -> 1, BaseStyle -> 18]
 ,
 {t, 0, 2 Pi, .1}
]

enter image description here

$\endgroup$
6
  • $\begingroup$ Thank you, @Kuba this actually does exactly what I was looking for. It's just very confusing when ViewPoint uses scaled coordinates and ViewVector uses ordinary coordinates... Btw for some reason this doesn't actually work for another Graphics3D that I'm working on but that's a matter for another question $\endgroup$
    – Aron
    Commented Apr 20, 2014 at 2:03
  • $\begingroup$ @Aron Yes, I didn't realised it either when you first asked about ViewCenter etc. So thank you, now I'm aware of the difference :) Maybe you can describe shortly your setup here, I mean this one where this solution does not work. $\endgroup$
    – Kuba
    Commented Apr 20, 2014 at 7:01
  • $\begingroup$ Well in short, I have a very similar, albeit more elaborate setup with planets and their orbits around the sun, with sliders that control the zoom and rotation around the sun. For some reason though, although the rotation works and even seems to be focused on the sun, it seems to follow a highly elliptical orbit around the sun. Since I am using the exact same parametric function to control the ViewVector I don't know why it is behaving differently $\endgroup$
    – Aron
    Commented Apr 20, 2014 at 13:35
  • $\begingroup$ @Aron Is ViewAngle fixed? $\endgroup$
    – Kuba
    Commented Apr 20, 2014 at 14:08
  • $\begingroup$ Yes, it is fixed at 35 degrees. Since I'm new here, would the best practice be to edit my question and add this other problem in with it, or is it better to create a new question for this? $\endgroup$
    – Aron
    Commented Apr 20, 2014 at 15:09

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.