Coordinate Systems for Three-Dimensional Graphics
Whenever
Mathematica draws a three-dimensional object, it always effectively puts a cuboidal box around the object. With the default option setting
Boxed->True,
Mathematica in fact draws the edges of this box explicitly. But in general,
Mathematica automatically "clips" any parts of your object that extend outside of the cuboidal box.
The option
PlotRange specifies the range of

,

, and

coordinates that
Mathematica should include in the box. As in two dimensions the default setting is
PlotRange->Automatic, which makes
Mathematica use an internal algorithm to try and include the "interesting parts" of a plot, but drop outlying parts. With
PlotRange->All,
Mathematica will include all parts.
This loads a package defining polyhedron operations.
This creates a stellated icosahedron.
This shows the stellated icosahedron, drawn in a box.
| Out[3]= |  |
With this setting for
PlotRange, many parts of the stellated icosahedron lie outside the box, and are clipped.
| Out[4]= |  |
Much as in two dimensions, you can use either "original" or "scaled" coordinates to specify the positions of elements in three-dimensional objects. Scaled coordinates, specified as
Scaled
are taken to run from 0 to 1 in each dimension. The coordinates are set up to define a right-handed coordinate system on the box.
| {x,y,z} | original coordinates |
| Scaled[{sx,sy,sz}] | scaled coordinates, running from 0 to 1 in each dimension |
Coordinate systems for three-dimensional objects.
This puts a cuboid in one corner of the box.
| Out[5]= |  |
Once you have specified where various graphical elements go inside a three-dimensional box, you must then tell
Mathematica how to draw the box. The first step is to specify what shape the box should be. This is analogous to specifying the aspect ratio of a two-dimensional plot. In three dimensions, you can use the option
BoxRatios to specify the ratio of side lengths for the box. For
Graphics3D objects, the default is
BoxRatios->Automatic, specifying that the shape of the box should be determined from the ranges of actual coordinates for its contents.
Specifying the shape of the bounding box for three-dimensional objects.
This displays the stellated icosahedron in a tall box.
| Out[6]= |  |
To produce an image of a three-dimensional object, you have to tell
Mathematica from what view point you want to look at the object. You can do this using the option
ViewPoint.
Some common settings for this option were given in
"Three-Dimensional Surface Plots". In general, however, you can tell
Mathematica to use any view point.
View points are specified in the form
ViewPoint
. The values
si are given in a special coordinate system, in which the center of the box is

. The special coordinates are scaled so that the longest side of the box corresponds to one unit. The lengths of the other sides of the box in this coordinate system are determined by the setting for the
BoxRatios option. For a cubical box, therefore, each of the special coordinates runs from

to

across the box. Note that the view point must always lie outside the box.
This generates a picture using the default view point

.
| Out[7]= |  |
This is what you get with a view point close to one of the corners of the box.
| Out[8]= |  |
As you move away from the box, the perspective effect gets smaller.
| Out[9]= |  |
| | |
| ViewPoint | {1.3,-2.4,2} | the point in a special scaled coordinate system from which to view the object |
| ViewCenter | Automatic | the point in the scaled coordinate system that appears at the center of the final image |
| ViewVertical | {0,0,1} | the direction in the scaled coordinate system that appears as vertical in the final image |
| ViewAngle | Automatic | the opening half-angle for a simulated camera used to view the graphic |
| ViewVector | Automatic | the position and direction of the simulated camera in the graphic's regular coordinate system |
Specifying the position and orientation of three-dimensional objects.
In making a picture of a three-dimensional object you have to specify more than just
where you want to look at the object from. You also have to specify how you want to "frame" the object in your final image. You can do this using the additional options
ViewCenter,
ViewVertical, and
ViewAngle.
ViewCenter allows you to tell
Mathematica what point in the object should appear at the center of your final image. The point is specified by giving its scaled coordinates, running from 0 to 1 in each direction across the box. With the setting
ViewCenter
, the center of the box will therefore appear at the center of your final image. With many choices of view point, however, the box will not appear symmetrical, so this setting for
ViewCenter will not center the whole box in the final image area. You can do this by setting
ViewCenter->Automatic.
ViewVertical specifies which way up the object should appear in your final image. The setting for
ViewVertical gives the direction in scaled coordinates which ends up vertical in the final image. With the default setting
ViewVertical
, the

direction in your original coordinate system always ends up vertical in the final image.
Mathematica uses the properties of a simulated camera to visualize the final image. The position, orientation, and facing of the camera are determined by the
ViewCenter,
ViewVertical, and
ViewPoint options. The
ViewAngle option specifies the width of the opening of the camera lens. The
ViewAngle specifies, in radians, the maximum angle from the line stretching from the
ViewPoint to the
ViewCenter that can be viewed by the camera. The effective viewing angle is double the value of
ViewAngle. This means that
ViewAngle can effectively be used to zoom in on a part of the image. The default value of
ViewAngle resolves to 35°, which is the typical viewing angle for the human eye.
This setting for
ViewVertical makes the

axis of the box appear vertical in your image.
| Out[10]= |  |
This uses
ViewAngle to effectively zoom in on the center of the image.
| Out[11]= |  |
When you set the options
ViewPoint,
ViewCenter, and
ViewVertical, you can think about it as specifying how you would look at a physical object.
ViewPoint specifies where your head is relative to the object.
ViewCenter specifies where you are looking (the center of your gaze). And
ViewVertical specifies which way up your head is.
In terms of coordinate systems, settings for
ViewPoint,
ViewCenter, and
ViewVertical specify how coordinates in the three-dimensional box should be transformed into coordinates for your image in the final display area.
| ViewVector->Automatic | uses the values of the ViewPoint and ViewCenter options to determine the position and facing of the simulated camera |
| ViewVector->{x,y,z} | position of the camera in the coordinates used for objects; the facing of the camera is determined by the ViewCenter option |
| ViewVector->{{x,y,z},{tx,ty,tz}} | position of the camera and of the point the camera is focused on in the coordinates used for objects |
Possible values of the ViewVector option.
The position and facing of the camera can be fully determined by the
ViewPoint and
ViewCenter options, but the
ViewVector option offers a useful generalization. Instead of specifying the position and facing of the camera using scaled coordinates,
ViewVector provides the ability to position the camera using the same coordinate system used to position objects within the graphic.
This specifies that the camera should be placed on the negative

axis and facing toward the center of the graphic.
| Out[12]= |  |
The camera is in the same position but pointing in a different direction. In combination with
ViewAngle, this zooms in on a particular section of the graphic.
| Out[13]= |  |
Once you have obtained a two-dimensional image of a three-dimensional object, there are still some issues about how this image should be rendered. The issues however are identical to those that occur for two-dimensional graphics. Thus, for example, you can modify the final shape of your image by changing the
AspectRatio option. And you specify what region of your whole display area your image should take up by setting the
PlotRegion option.
| drag | rotate the graphic about its center |
| Ctrl+drag | zoom into or out of the graphic |
| Shift+drag | pan across the graphic in the plane of the screen |
Mouse gestures used for interacting with three-dimensional graphics.
When interactively modifying graphics,
Mathematica makes changes to the view options. If you have specified the position of the camera using
ViewPoint, then rotating the graphic causes
Mathematica to change the value of the
ViewPoint option. If the position of the camera is specified using
ViewVector, interactive rotation will instead change the value of that option. In both cases, interactive rotation can also affect the value of the
ViewVertical option. Interactive zooming of the graphic corresponds directly to changing the
ViewAngle option. Interactively panning the graphic changes values of the
ViewCenter option.
This modifies the aspect ratio of the final image.
| Out[14]= |  |
Mathematica usually scales the images of three-dimensional objects to be as large as possible, given the display area you specify. Although in most cases this scaling is what you want, it does have the consequence that the size at which a particular three-dimensional object is drawn may vary with the orientation of the object. You can set the option
SphericalRegion->True to avoid such variation. With this option setting,
Mathematica effectively puts a sphere around the three-dimensional bounding box, and scales the final image so that the whole of this sphere fits inside the display area you specify. The sphere has its center at the center of the bounding box, and is drawn so that the bounding box just fits inside it.
This draws a rather elongated version of the plot.
| Out[15]= |  |
With
SphericalRegion->True, the final image is scaled so that a sphere placed around the bounding box would fit in the display area.
| Out[16]= |  |
By setting
SphericalRegion->True, you can make the scaling of an object consistent for all orientations of the object. This is useful if you create animated sequences which show a particular object in several different orientations.
| SphericalRegion->False | scale three-dimensional images to be as large as possible |
| SphericalRegion->True | scale images so that a sphere drawn around the three-dimensional bounding box would fit in the final display area |
Changing the magnification of three-dimensional images.