/* The source code for generating the above plot */
#include
#include
#define POINTS 50
#define NUM1 30
#define NUM2 360
#define NUMX1 36
#define NUMY1 20
#define NUMX2 30
#define NUMY2 30
#define NUMX3 40
#define NUMY3 60
int main() {
double t[POINTS], b0[POINTS], b1[POINTS], b2[POINTS], b3[POINTS];
int i, j, datasetnum=0, line_type=4, line_width = 2;
double theta2[NUM2], r2[NUM2];
double x3[NUM2], y3[NUM2], z3[NUM2], z32[NUM2];
double theta4[NUMX1], z4[NUMY1], r4[NUMX1*NUMY1];
double r, x5[NUMX2], y5[NUMY2], z5[NUMX2*NUMY2];
double x6[NUMX3], y6[NUMY3], z6[NUMX3*NUMY3];
class CPlot subplot, *spl;
/* plot 1 */
for(i=0; i< POINTS; i++) {
t[i] = 1+i*(10.0-1)/(POINTS-1);
b0[i] = j0(t[i]);
b1[i] = j1(t[i]);
b2[i] = jn(2, t[i]);
b3[i] = jn(3, t[i]);
}
/* plot 2 */
for(i=0; ititle("Line");
spl->label(PLOT_AXIS_X,"t");
spl->label(PLOT_AXIS_Y,"Bessel functions");
spl->data2DCurve(t, b0, POINTS);
spl->data2DCurve(t, b1, POINTS);
spl->data2DCurve(t, b2, POINTS);
spl->data2DCurve(t, b3, POINTS);
spl->legend("j0", 0);
spl->legend("j1", 1);
spl->legend("j2", 2);
spl->legend("j3", 3);
spl = subplot.getSubplot(0,1); /* get subplot (0,1) */
spl->title("Polar");
spl->axisRange(PLOT_AXIS_XY, -1, 1);
spl->ticsRange(PLOT_AXIS_XY, .5, -1, 1);
spl->data2DCurve(theta2, r2, NUM2);
spl->polarPlot(PLOT_ANGLE_RAD);
spl->sizeRatio(-1);
spl = subplot.getSubplot(0,2); /* get subplot (0,2) */
spl->title("3D curve");
spl->data3DCurve(x3, y3, z3, NUM2);
spl->data3DCurve(x3, y3, z32, NUM2);
spl->axisRange(PLOT_AXIS_X, 0, 400);
spl->ticsRange(PLOT_AXIS_X, 200, 0, 400);
spl->axisRange(PLOT_AXIS_Y, -1, 1);
spl->ticsRange(PLOT_AXIS_Y, 1, -1, 1);
spl->axisRange(PLOT_AXIS_Z, -1, 1);
spl->ticsRange(PLOT_AXIS_Z, 1, -1, 1);
spl->colorBox(PLOT_OFF);
spl = subplot.getSubplot(1,0); /* get subplot (1,0) */
spl->title("Cylindrical");
spl->data3DSurface(theta4, z4, r4, NUMX1, NUMY1);
spl->coordSystem(PLOT_COORD_CYLINDRICAL, PLOT_ANGLE_DEG);
spl->axisRange(PLOT_AXIS_Z, 0, 8);
spl->ticsRange(PLOT_AXIS_Z, 2, 0, 8);
spl->axisRange(PLOT_AXIS_XY, -4, 4);
spl->colorBox(PLOT_OFF);
spl->ticsRange(PLOT_AXIS_XY, 2, -4, 4);
spl->label(PLOT_AXIS_XYZ, NULL);
spl = subplot.getSubplot(1,1); /* get subplot (1,1) */
spl->title("3D Mesh");
spl->axisRange(PLOT_AXIS_X, -10, 10);
spl->ticsRange(PLOT_AXIS_X, 5, -10, 10);
spl->axisRange(PLOT_AXIS_Y, -10, 10);
spl->ticsRange(PLOT_AXIS_Y, 5, -10, 10);
spl->axisRange(PLOT_AXIS_Z, -.4, 1.2);
spl->ticsRange(PLOT_AXIS_Z, .4, -.4, 1.2);
spl->data3DSurface(x5, y5, z5, NUMX2, NUMY2);
spl->colorBox(PLOT_OFF);
spl->label(PLOT_AXIS_XYZ, NULL);
spl = subplot.getSubplot(1,2); /* get subplot (1,2) */
spl->title("3D Mesh");
spl->data3DSurface(x6, y6, z6, NUMX3, NUMY3);
spl->axisRange(PLOT_AXIS_X, -3, 3);
spl->ticsRange(PLOT_AXIS_X, 2, -3, 3);
spl->axisRange(PLOT_AXIS_Y, -4, 4);
spl->ticsRange(PLOT_AXIS_Y, 2, -4, 4);
spl->axisRange(PLOT_AXIS_Z, -8, 8);
spl->ticsRange(PLOT_AXIS_Z, 4, -8, 8);
spl->colorBox(PLOT_OFF);
spl->label(PLOT_AXIS_XYZ, NULL);
spl->ticsLevel(0.1);
subplot.plotting();
return 0;
}
|