Explain the difference between ViewPoint and ViewVector?

If ViewVector is set to be Automatic it will be the vector that starts at ViewPoint and ends at ViewCenter, which means that ViewVector and ViewPoint are tied to each other.

You can think of the origin of ViewVector as the position where the camera filming the scene is located, and its direction as what direction it points in.

So as long as ViewVector is automatic you can implicitly set the ViewVector by positioning ViewPoint and ViewCenter, ViewVector will just be the vector between those two points. However if you change ViewVector that change will override any changes that you've made to ViewPoint and ViewCenter.

One important difference, as Kuba says, is that ViewCenter deals with relative coordinates, not absolut ones. ViewVector uses actual points in the room, but ViewCenter uses a fraction of the plot range. So if the plot range is {100, 200, 300} then ViewCenter -> {0.5, 0.5, 0.5} puts the view center at {50, 100, 150}.


I have also found this challenging recently, and, having made some progress with the documentation, I feel that the above answers, though helpful, are still perhaps incomplete. The point here is that ViewVector specifies two locations, the first one where the camera is, and the second one, which specifies a position towards which it is pointing. ViewPoint can be used to fix just the former and ViewCentre to fix just the latter. This was correctly mentioned in the answer given by @C.E. It was also emphasised by @Kuba that the coordinates used are different between ViewVector and ViewPoint, and added by @C.E. that they are different between ViewVector and ViewCenter.

The additional point which I have realised today is that the coordinate systems used by ViewPoint and ViewCenter are also different from each other. I take them in turn:

ViewPoint From the documentation, we find that the coordinates of the centre of the bounding box (BB) for ViewPoint are {0,0,0}, (c.f. the corresponding coordinates for ViewCenter, which are {1/2,1/2,1/2}). This caused me some confusion initially! The other factor which should be specified is the scale of the BB. The documentation clearly states that for ViewPoint, "The view point is given in a special scaled coordinate system in which the longest side of the bounding box has length 1". That sets the scale for just one of three dimensions. We find later that for ViewPoint: "The coordinates of the corners of the bounding box in the special coordinate system used for ViewPoint are determined by the setting for the BoxRatios option", and I find that the default values for this option are described thus: "BoxRatios->Automatic normally gives box ratios corresponding to the actual coordinate values in the 3D graphic". Taken together, this means for ViewPoint, that the scale factors for all three coordinates are the same and given by the quantity 1/(longest-length). Thus only one corner coordinate equals 1/2, that of the largest, with the others always smaller.

ViewCenter This is slightly easier. From the documentation: "ViewCenter->Automatic is equivalent to ViewCenter->{1/2,1/2,1/2}, which places the center of the three-dimensional bounding box at the center of the final image." For scales, we find: "ViewCenter is given in scaled coordinates, which run from 0 to 1 across each dimension of the bounding box". Thus, the eight corners of the BB each have all their coordinates as either 0 or 1.

I conclude that not only are the centre values of the BBs different from each other for ViewPoint and ViewCenter, but that all three scale factors are also different between the two cases, as described above.

It is no wonder that there are nearly 1,200 posts on MSE about ViewPoint alone.

Tags:

Graphics3D