Coordinate Systems for ThreeDimensional Graphics

Whenever the Wolfram Language draws a threedimensional object, it always effectively puts a cuboidal box around the object. With the default option setting Boxed->True, the Wolfram Language in fact draws the edges of this box explicitly. But in general, the Wolfram Language automatically "clips" any parts of your object that extend outside of the cuboidal box.

The option PlotRange specifies the range of , , and coordinates that the Wolfram Language should include in the box. As in two dimensions the default setting is PlotRange->Automatic, which makes the Wolfram Language use an internal algorithm to try and include the "interesting parts" of a plot, but drop outlying parts. With PlotRange->All, the Wolfram Language will include all parts.

This loads a package defining polyhedron operations.
Click for copyable input
This creates a stellated icosahedron.
Click for copyable input
This shows the stellated icosahedron, drawn in a box.
Click for copyable input
With this setting for PlotRange, many parts of the stellated icosahedron lie outside the box, and are clipped.
Click for copyable input

Much as in two dimensions, you can use either "original" or "scaled" coordinates to specify the positions of elements in threedimensional objects. Scaled coordinates, specified as Scaled[{sx,sy,sz}], are taken to run from 0 to 1 in each dimension. The coordinates are set up to define a righthanded 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 threedimensional objects.

This puts a cuboid in one corner of the box.
Click for copyable input

Once you have specified where various graphical elements go inside a threedimensional box, you must then tell the Wolfram Language 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 twodimensional 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.

BoxRatios->{xr,yr,zr}specify the ratio of side lengths for the box
BoxRatios->Automaticdetermine the ratio of side lengths from the range of actual coordinates (default for Graphics3D)

Specifying the shape of the bounding box for threedimensional objects.

This displays the stellated icosahedron in a tall box.
Click for copyable input

To produce an image of a threedimensional object, you have to tell the Wolfram Language 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 the Wolfram Language to use any view point.

View points are specified in the form ViewPoint->{sx,sy,sz}. The values si are given in a special coordinate system, in which the center of the box is {0,0,0}. 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 {1.3,-2.4,2}.
Click for copyable input
This is what you get with a view point close to one of the corners of the box.
Click for copyable input
As you move away from the box, the perspective effect gets smaller.
Click for copyable input
option name
default value
ViewPoint{1.3,-2.4,2}the point in a special scaled coordinate system from which to view the object
ViewCenterAutomaticthe 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
ViewAngleAutomaticthe opening angle for a simulated camera used to view the graphic
ViewVectorAutomaticthe position and direction of the simulated camera in the graphic's regular coordinate system

Specifying the position and orientation of threedimensional objects.

In making a picture of a threedimensional 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 the Wolfram Language 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->{1/2,1/2,1/2}, 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 that ends up vertical in the final image. With the default setting ViewVertical->{0,0,1}, the direction in your original coordinate system always ends up vertical in the final image.

The Wolfram Language 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, twice of the maximum angle from the line stretching from the ViewPoint to the ViewCenter that can be viewed by the camera. 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.
Click for copyable input
This uses ViewAngle to effectively zoom in on the center of the image.
Click for copyable input

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 threedimensional box should be transformed into coordinates for your image in the final display area.

ViewVector->Automaticuses 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.
Click for copyable input
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.
Click for copyable input

Once you have obtained a twodimensional image of a threedimensional object, there are still some issues about how this image should be rendered. The issues, however, are identical to those that occur for twodimensional 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.

dragrotate the graphic about its center
Ctrl+dragzoom into or out of the graphic
Shift+dragpan across the graphic in the plane of the screen

Mouse gestures used for interacting with three-dimensional graphics.

When interactively modifying graphics, the Wolfram Language makes changes to the view options. If you have specified the position of the camera using ViewPoint, then rotating the graphic causes the Wolfram Language 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.
Click for copyable input

The Wolfram Language usually scales the images of threedimensional 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 threedimensional 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, the Wolfram Language effectively puts a sphere around the threedimensional 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.
Click for copyable input
With SphericalRegion->True, the final image is scaled so that a sphere placed around the bounding box would fit in the display area.
Click for copyable input

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 that show a particular object in several different orientations.

SphericalRegion->Falsescale threedimensional images to be as large as possible
SphericalRegion->Truescale images so that a sphere drawn around the threedimensional bounding box would fit in the final display area

Changing the magnification of threedimensional images.

Related Tutorials