I am trying to have a satellite (camera) move around the earth (unit sphere) and take picture of the earth. The satellite keeps constant distance from the earth, and always looks toward earth center.

   Graphics3D[Sphere[{0, 0, 0}, 1], ViewVector -> {2*{Cos[t], 0, Sin[t]}, {0, 0, 0}}], 
   {t, 0, 2*Pi}]

This should produce the same size of circle no matter what angle t is being used, but the above code scales the images. I think I am not using ViewVector correctly here. Any clarification would be greatly appreciated.

  • $\begingroup$ Add the option SphericalRegion -> True and specify a ViewAngle manually, e.g. ViewAngle -> 70 Degree. I don't claim to have a full understanding of setting up views in 3D in Mathematica, so I won't comment on details ... $\endgroup$ – Szabolcs Feb 14 '14 at 18:08
  • $\begingroup$ Thanks a lot! That fixed the problem. $\endgroup$ – Tim Feb 14 '14 at 18:13
  • $\begingroup$ Maybe someone who actually understands why this works will come along and write a proper answer. ... $\endgroup$ – Szabolcs Feb 14 '14 at 18:17
  • $\begingroup$ You can surround any code you post with backtick characters. This not only gives prettier and more readable formatting, it also protects the code from being mangled (such as backslashes removed). $\endgroup$ – Szabolcs Feb 14 '14 at 18:39
  • $\begingroup$ Actually, I think it does not work. I first thought it does, because the plain sphere does not have texture. However, once you put texture on, you will notice a discontinuity jump around t=1.57. Try this: Manipulate[ SphericalPlot3D[ 1, {\[Theta], 0, \[Pi]}, {\[CapitalPhi], 0, 2 \[Pi]}, PlotStyle -> {Opacity[1], Texture[ExampleData[{"TestImage", "Lena"}]]}, Mesh -> False, Boxed -> False, Axes -> False, SphericalRegion -> True, ViewAngle -> 70/180*Pi, ViewVector -> {2*{Cos[t], 0, Sin[t]}, {0, 0, 0}}], {t, 1.56, 1.58, 0.001}] $\endgroup$ – Tim Feb 14 '14 at 18:47

I don't think kuba answer, although correct, really addresses the texture issue. ViewVertical is essential, but ViewAngle is not needed. Also, SphericalRegion helps.

  SphericalPlot3D[1 , {u, 0, 180 °}, {v, 0, 360 °},
    Mesh -> None,
    TextureCoordinateFunction -> ({#5 - 1/2, 1 - #4} &), 
    PlotStyle -> Texture[satelliteImage],
    Lighting -> "Neutral",
    Axes -> False,
    PerformanceGoal -> "Quality",
    ViewVector -> {5*{Cos[t], 0, Sin[t]}, {0, 0, 0}}, 
    SphericalRegion -> True,
    ViewVertical -> {-Sin[t], 0, Cos[t]}],
  {t, 0., 2.*Pi, Pi/18.}]

The Manipulate rotated a world globe about the y-axis like so


where satelliteImage is this image


  • $\begingroup$ Is seems that one can fix ViewAngle or use SphericalRegion. But what's the difference at the end that you say I've missed the point? $\endgroup$ – Kuba Feb 15 '14 at 18:15
  • $\begingroup$ No, not at all. But the OP was was looking for an answer that applied a texture. The problem he has with a discontinuity at the poles doesn't show up well with a simple graphic. $\endgroup$ – m_goldberg Feb 15 '14 at 18:23
  • $\begingroup$ Oh, ok, thanks for comment. There were no votes or comments, I was afraid I'm missing something again :p $\endgroup$ – Kuba Feb 15 '14 at 18:25

As suggested by Szabolcs ViewAngle and ViewVertical is the answer. SphericalRegion is, in fact, redundant so I don't have to explain it (I can't ;P).

Manipulate[Graphics3D[Cone[{{0, 0, -1}, {0, 0, 1}}, 1], 
                      ViewVector -> {2*{Cos[t], 0, Sin[t]}, {0, 0, 0}}, 
                      ViewAngle -> Pi/2,
                      ViewVertical -> {-Sin[t], 0, Cos[t]}]
          , {t, 0, 2*Pi, .3}]

ViewVertical is related with ViewVector by:

RotationTransform[-Pi/2, {0, 1, 0}][{Cos[t], 0, Sin[t]}]
{-Sin[t], 0, Cos[t]}

This fixes the problem of reorientation over the pole ;)

enter image description here

Is this what you are after?


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.