Table Of Contents

Graph IDEProgramming ► Perspective Scatter

The following is a complete script for programming a 3D Scatter Plot. It loads in a spiral of data and rotates the graph.

/* Declarations */

double cos(double a);
double sin(double a);

@@class() PerspectiveScatter:Object

@@method(public, class) (id)alloc;
@@method(public, instance) (id)init;
@@method(public, instance) (void)emptyData;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void)appendXValue:(double)xValue yValue:(double)yValue zValue:(double)zValue;
@@method(public, instance) (void)setCurveRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)setInteriorRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void) rotateToPhi:(double)phiAngle theta:(double)thetaAngle psi:(double)psiAngle;
@@method(public, instance) (void)release;

@@end

/* Execution block */

{
id myScatter;
int ii;
double tValue, xValue, yValue, zValue;
unsigned animationCount;
double red;
double phiAngle;

myScatter = [[PerspectiveScatter alloc] init];

animationCount = [myScatter animationCount];

printf("animationCount: %d\n", animationCount);

/*
Empty the data and then append new data.
*/

[myScatter emptyData];

for(ii = 0; ii < 500; ii++)
{
tValue = 0.04 * ii + animationCount * 0.5;
xValue = 5.0 * cos(tValue) + 5.0;
yValue = 5.0 * sin(tValue) + 5.0;
zValue = tValue / 2.0;
[myScatter appendXValue:xValue yValue:yValue zValue:zValue];
}

red = (animationCount % 10) / 10.0;
phiAngle = animationCount * 0.1;

[myScatter setCurveRed:red green:0.0 blue:0.0 alpha:1.0];

[myScatter rotateToPhi:phiAngle theta:0.0 psi:0.0];

[myScatter release];

}

The general API is define in the section Graphic. The following is API description specific to the 3D Scatter Plot.

@@method(public, instance) (void)appendXValue:(double)xValue yValue:(double)yValue zValue:(double)zValue;
  Call like this:

[myScatter appendXValue:xValue yValue:yValue zValue:zValue];

Appends the x, y and z values to the list of data points for the graphic. The x, y and z values forms a 3D point. Each value must be of type double.

@@method(public, instance) (void)appendMarkerRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
  Call like this:

[myScatter appendMarkerRed:0.5 green:0.4 blue:1.0 alpha:1.0];

That appends the marker color to the red, green, blue and alpha values of 0.5, 0.4, 1.0 and 1.0 respectively. Those values must be between 0.0 and 1.0. An alpha of 0.0 is transparent while 1.0 is completely opaque. Each argument must be a number literal or a variable (or expression) of type double. Note that this call must accompany a appendXValue:xValue yValue: call in order to synchronize the parameters that depend upon sequence index.

@@method(public, instance) (void)appendSegmentRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
  Call like this:

[myScatter appendSegmentRed:0.5 green:0.4 blue:1.0 alpha:1.0];

That appends the segment color to the red, green, blue and alpha values of 0.5, 0.4, 1.0 and 1.0 respectively. Those values must be between 0.0 and 1.0. An alpha of 0.0 is transparent while 1.0 is completely opaque. Each argument must be a number literal or a variable (or expression) of type double. Note that this call must accompany a appendXValue:xValue yValue: call in order to synchronize the parameters that depend upon sequence index. In order for this to take effect, the scatter stroke type needs to be set to other than none. By setting some segment colors to have an alpha of 0.0, the stroke appears discontiguous. Using this method permits the 3D scatter plot to appear as a trajectory plot and when alpha is set to 0.0 for appropriate segments the trajectories appear as multiple 3D trajectories in space.

@@method(public, instance) (void)emptyData;
  Call like this:

[myScatter emptyData];

Removes (empties) all data from the graphic. Call this right before adding new data points.

@@method(public, instance) (void) rotateToPhi:(double)phiAngle theta:(double)thetaAngle psi:(double)psiAngle;
  Call like this:

[myScatter rotateToPhi:phi theta:theta psi:psi];

Rotates the scatter plot to the phi, theta and psi angles which are yaw, pitch and roll angles respectively in units of radians.




© Copyright 1993-2022 by VVimaging, Inc. (VVI); All Rights Reserved. Please email support@vvi.com with any comments you have concerning this documentation. See Legal for trademark and legal information.