Introduction To 3D Plotting Techniques

# Basic Plotting

3-Dimensional Plotting is one of SWIFTVis's newest and most powerful features. You do 3-D plotting using the same plot object that is done for 2-D plotting by adding a 3-D plot to the Plot Region. These function similarly to the 2-D plotting, but there are a few distinctions that are worth noting. This section contains a tutorial to introduce you to the basic techniques involved with 3-D plotting.

## Graph Data

In order to make a plot, we need a set of data. For this, we will use a Sequence. Select Insert > Data Source and pick "Sequence". By default, a Sequence will range from 0 to 1 with 10 values. While this may work for our purposes, the output promises to be boring. Set the field of the Sequence to reflect the following:

## Creating the Plot

To create a new 3-D Plot in a Plot Region that takes data from the Sequence, right-click on the Sequence and create a new Plot. Then, select the plot and click "Add 3-D Plot".

Next, select "Create" and select which type of 3-D plot you would like to create, a [[Scatter Plot]] or a [[Surface Plot]]. Currently there are only three plot styles for 3-D plots, but like 2-D plots, the code has been written so that more can easily be added. A scatter plot provides 3-D spheres in space, while a surface plot builds a single surface from the data provided. Note that the properties of the scatter plot allow you to specify formulas for the x, y, and z coordinates as well as sizes of the spheres. For this example, select the scatter plot.

Now you should see the following:

The first tab of settings for a 3-D plot, like that for 2-D plots, is the data sets tab. For this example, update the fields to reflect the ones in the image. Now, we should have a smooth curve made up of individual points, like with a scatter plot. However, if you select "Show / Redraw" you will only see a blank window. SwiftVis isn't broken - the scene is just dark. The scene currently has no lights in it, so nothing is visible by the camera to provide a picture.

## Setting up the Scene

In order to correct this problem, we will now add some lights to our scene. Move to the "Lights" tab of the 3D plot pane and click the "Add" button under Point Lights. This will add a single point light at a default location to the rendering. Then, click "add" under Directional Lights. This will add a single directional light to the scene at a default location. Your Lights pane should now look like this:

After that, click "Apply Changes". Then, click "Show / Redraw" and your plot should look like the following:

We now have a basic rendering of some data. You can move the camera around the plot by selecting the plot and using W, A, S, and D to move up, left, right, and down respectively. You can also change the focal point of the camera by clicking and dragging on the plot window.

# Data Sets and Input

Other data sets may be similarly plotted in the manner described above. For example, a file with tuples (x,y,z) of particle locations may be graphed using a scatter plot by setting the x-value field of the plot to the x-value variable of the input file, and doing the same for y and z.

# Rendering Engines: A Brief Discussion

There are many ways to render 3-D graphics on a computer. The 3-D capabilities in SwiftVis were written in such a way to allow multiple different libraries to be used. The Render Engine tab allows you to select which engine you wish to use and change any settings associated with that engine. Currently SwiftVis supports two engines, both or which will work with any Java install and do all of their work on the CPU. There are plans to add other engines that will require other libraries to be installed, but which will use graphics card optimizations to do the rendering. The two default engines are a CPU polygon engine and a ray tracing engine. By default the CPU polygon engine is used. This engine has been written in Java to transform objects from 3-D into 2-D so that they can be rendered with the Java2D library. The second rendering engine that comes with a standard SwiftVis install is a ray tracer. The ray tracer will provide much higher quality output, but it is significantly slower. The output of the two engines can be seen side-by-side below.