17
$\begingroup$

I've read the documentation, but am still very unclear as to what the difference is between ViewVector and ViewPoint for Graphics3D. Could someone explain it concisely and clearly enough so that an amateur like myself could understand?

$\endgroup$
9
$\begingroup$

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}.

| improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ So basically if you only set ViewVector->{1,1,1} that's identical to setting the ViewPoint? $\endgroup$ – Aron Apr 17 '14 at 13:30
  • 1
    $\begingroup$ Yes, I believe so. $\endgroup$ – C. E. Apr 17 '14 at 14:02
  • 2
    $\begingroup$ I have not realised that before this question appeared but the important difference is that ViewPoint can't handle absolute coordinates, so ViewVector is not just doublind the functionality but allowes that. The point is, it's worth to stress this :) $\endgroup$ – Kuba Apr 20 '14 at 7:16
  • $\begingroup$ @Kuba Good point, it was definitely something I should have mentioned to begin with. Added it. $\endgroup$ – C. E. Apr 20 '14 at 9:04
4
$\begingroup$

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.

| improve this answer | |
$\endgroup$

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.