4
$\begingroup$

I have a list of coordinates in 3D all of which lie on the surface of a unit sphere (for all intents and purpose these are just random points on the sphere).

I want to view them as from the centre of the sphere and be able to rotate the view using the mouse. When I set ViewPoint to {0,0,0} (the centre of the sphere) it looks OK but when I use the mouse to rotate it the view is messed up. It looks like the image is rotating about some other point, but I can't work out which and how to correct it. Essentially I want the view to rotate about the origin as though standing at the centre of the sphere and looking around (imagine standing on the Earth and looking around at the night sky - that would be a suitable analogy).

The code I have is:

ListPointPlot3D[coords, BoxRatios -> {1, 1, 1}, 
  ViewPoint -> {0, 0, 0}]

Where "coords" is a list of the 3D coordinates of the points.

$\endgroup$
0

1 Answer 1

5
$\begingroup$
  • Use ViewVector
coords = RandomPoint[Ellipsoid[{0, 0, 0}, {4, 3, 2}], 500];
ListPointPlot3D[coords, BoxRatios -> {1, 1, 1}, 
 ViewVector -> {0, 0, 0}]
coords = RandomPoint[Ellipsoid[{0, 0, 0}, {4, 3, 2}], 500];
Show[ListPointPlot3D[coords, BoxRatios -> {1, 1, 1}, 
  ViewVector -> {0, 0, 0}, Boxed -> False, Axes -> False], 
 Graphics3D[{Arrowheads[Medium], 
   Arrow[{{0, 0, 0}, #}] & /@ coords[[1 ;; 10]]}], 
 ViewVector -> {1, 1, 1}]

enter image description here

  • Another example is
ContourPlot3D[
 x^2/5^2 + y^2/4^2 + z^2/3^2 == 1, {x, -5, 5}, {y, -5, 5}, {z, -5, 5},
  ViewVector -> {1, 1, 1}, 
 MeshStyle -> Directive@{Opacity[.3], Thick}]

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ Thank you, yes, that seems to do the trick. I thought I had tried this, but I think my previous efforts had reset viewing points etc and I needed to set back to default. $\endgroup$
    – Peter King
    May 15 at 10:20

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.