# Coordinate Systems for Three‐Dimensional Graphics

Whenever the Wolfram Language draws a three‐dimensional 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.

In[1]:= |

In[2]:= |

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[{sx,sy,sz}], 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.

Once you have specified where various graphical elements go inside a three‐dimensional 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 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.

BoxRatios->{xr,yr,zr} | specify the ratio of side lengths for the box |

BoxRatios->Automatic | determine the ratio of side lengths from the range of actual coordinates (default for Graphics3D) |

Specifying the shape of the bounding box for three‐dimensional objects.

To produce an image of a three‐dimensional 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.

option name | default value | |

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

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.

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

The Wolfram Language 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, the Wolfram Language 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.

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