Example: Spiral Data connected with Tubes

A spiral data set is charted with tubes connecting the data points.

import com.imsl.chart3d.*;
import com.imsl.chart3d.ColorFunction;
import java.awt.Color;

public class DataEx1 extends JFrameChart3D implements ColorFunction {    

    public DataEx1() {
        Chart3D chart = getChart3D();
        AxisXYZ axis = new AxisXYZ(chart);
        
        axis.getAxisBox().setPaint(false);
        
        int nSpiral = 400;
        double xSpiral[] = new double[nSpiral];
        double ySpiral[] = new double[nSpiral];
        double zSpiral[] = new double[nSpiral];
        for (int i = 0;  i < nSpiral;  i++) {
            double t = 8.0 * Math.PI * i / (double)(nSpiral-1);
            double r = 0.6 + (double)i / (double)(nSpiral-1);
            xSpiral[i] = r * Math.cos(t);
            ySpiral[i] = r * Math.sin(t);
            zSpiral[i] = (double)i / (double)(nSpiral-1);
        }
        Data spiral = new Data(axis, xSpiral, ySpiral, zSpiral);
        spiral.setDataType(spiral.DATA_TYPE_TUBE);
        spiral.setLineWidth(2);
        spiral.setColorFunction(this);
        this.setSize(375, 375);
        render();
    }
 
    public Color color(double x, double y, double z) {
        return com.imsl.chart.Colormap.SPECTRAL.color(z);
    }
    
    public static void main(String args[]) throws Exception {
        new DataEx1().setVisible(true);
    }   
}

Output

Link to Java source.