1
//--------------------------------------------------------------------------
2
// $Id: x11.java 11301 2010-11-02 17:21:08Z airwin $
3
//--------------------------------------------------------------------------
5
//--------------------------------------------------------------------------
6
// Copyright (C) 2001 Geoffrey Furnish
7
// Copyright (C) 2001, 2002, 2003 Alan W. Irwin
8
// Copyright (C) 2004 Andrew Ross
10
// This file is part of PLplot.
12
// PLplot is free software; you can redistribute it and/or modify
13
// it under the terms of the GNU Library General Public License as published by
14
// the Free Software Foundation; version 2 of the License.
16
// PLplot is distributed in the hope that it will be useful,
17
// but WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
// GNU Library General Public License for more details.
21
// You should have received a copy of the GNU Library General Public License
22
// along with PLplot; if not, write to the Free Software
23
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24
//--------------------------------------------------------------------------
26
//--------------------------------------------------------------------------
27
// Implementation of PLplot example 11 in Java.
28
//--------------------------------------------------------------------------
30
package plplot.examples;
34
import java.lang.Math;
37
PLStream pls = new PLStream();
39
static final int XPTS = 35;
40
static final int YPTS = 46;
41
static final int LEVELS = 10;
43
static int opt[] = { 3, 3 };
44
static double alt[] = { 33.0, 17.0 };
45
static double az[] = { 24.0, 115.0 };
47
static String[] title =
49
"#frPLplot Example 11 - Alt=33, Az=24, Opt=3",
50
"#frPLplot Example 11 - Alt=17, Az=115, Opt=3"
55
double [] i = new double[2];
56
double [] h = new double[2];
57
double [] l = new double[2];
58
double [] s = new double[2];
59
boolean [] rev = new boolean[2];
61
i[0] = 0.0; // left boundary
62
i[1] = 1.0; // right boundary
64
h[0] = 240; // blue -> green -> yellow ->
73
rev[0] = false; // interpolate on front side of colour wheel.
74
rev[1] = false; // interpolate on front side of colour wheel.
77
pls.scmap1l( false, i, h, l, s, rev );
80
// Does a series of mesh plots for a given data set, with different viewing
81
// options in each plot.
83
public static void main( String[] args )
88
public x11( String[] args )
92
double[] x = new double[ XPTS ];
93
double[] y = new double[ YPTS ];
94
double[][] z = new double[XPTS][YPTS];
95
double zmin = Double.MAX_VALUE, zmax = Double.MIN_VALUE;
99
double[] clevel = new double[LEVELS];
103
// Parse and process command line arguments.
105
pls.parseopts( args, PLStream.PL_PARSE_FULL | PLStream.PL_PARSE_NOPROGRAM );
107
// Initialize plplot.
111
for ( i = 0; i < XPTS; i++ )
112
x[i] = 3. * (double) ( i - ( XPTS / 2 ) ) / (double) ( XPTS / 2 );
114
for ( j = 0; j < YPTS; j++ )
115
y[j] = 3. * (double) ( j - ( YPTS / 2 ) ) / (double) ( YPTS / 2 );
117
for ( i = 0; i < XPTS; i++ )
120
for ( j = 0; j < YPTS; j++ )
123
z[i][j] = 3. * ( 1. - xx ) * ( 1. - xx ) * Math.exp( -( xx * xx ) - ( yy + 1. ) * ( yy + 1. ) ) -
124
10. * ( xx / 5. - Math.pow( xx, 3. ) - Math.pow( yy, 5. ) ) * Math.exp( -xx * xx - yy * yy ) -
125
1. / 3. * Math.exp( -( xx + 1 ) * ( xx + 1 ) - ( yy * yy ) );
126
if ( false ) // Jungfraujoch/Interlaken
131
if ( zmin > z[i][j] )
133
if ( zmax < z[i][j] )
138
step = ( zmax - zmin ) / ( nlevel + 1 );
139
for ( i = 0; i < nlevel; i++ )
140
clevel[i] = zmin + step + step * i;
143
for ( k = 0; k < 2; k++ )
145
for ( i = 0; i < 4; i++ )
149
pls.vpor( 0.0, 1.0, 0.0, 0.9 );
150
pls.wind( -1.0, 1.0, -1.0, 1.5 );
152
pls.w3d( 1.0, 1.0, 1.2, -3.0, 3.0, -3.0, 3.0, zmin, zmax,
154
pls.box3( "bnstu", "x axis", 0.0, 0,
155
"bnstu", "y axis", 0.0, 0,
156
"bcdmnstuv", "z axis", 0.0, 4 );
162
pls.mesh( x, y, z, opt[k] );
164
// magnitude colored wireframe plot
166
pls.mesh( x, y, z, opt[k] | PLStream.MAG_COLOR );
168
// magnitude colored wireframe plot with sides
170
pls.plot3d( x, y, z, opt[k] | PLStream.MAG_COLOR, true );
172
// magnitude colored wireframe plot with base contour
174
pls.meshc( x, y, z, opt[k] | PLStream.MAG_COLOR | PLStream.BASE_CONT,
179
pls.mtex( "t", 1.0, 0.5, 0.5, title[k] );
187
//--------------------------------------------------------------------------
189
//--------------------------------------------------------------------------