/usr/share/doc/libplplot12/examples/java/x18.java is in libplplot-java 5.10.0-0ubuntu5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | //--------------------------------------------------------------------------
// $Id: x18.java 12240 2012-10-04 22:10:12Z andrewross $
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Copyright (C) 2001 Geoffrey Furnish
// Copyright (C) 2002 Alan W. Irwin
// Copyright (C) 2004 Andrew Ross
//
// This file is part of PLplot.
//
// PLplot is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// PLplot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public License
// along with PLplot; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// Implementation of PLplot example 18 in Java.
//--------------------------------------------------------------------------
package plplot.examples;
import plplot.core.*;
import static plplot.core.plplotjavacConstants.*;
import java.lang.Math;
import java.text.*;
class x18 {
static final int NPTS = 1000;
static int opt[] = { 1, 0, 1, 0 };
static double alt[] = { 20.0, 35.0, 50.0, 65.0 };
static double az[] = { 30.0, 40.0, 50.0, 60.0 };
PLStream pls = new PLStream();
double THETA( int a )
{
return 2. * Math.PI * a / 20.;
}
double PHI( int a )
{
return Math.PI * a / 20.1;
}
void test_poly( int k )
{
int i, j;
boolean [][] draw = {
{ true, true, true, true },
{ true, false, true, false },
{ false, true, false, true },
{ true, true, false, false }
};
double [] x = new double [5];
double [] y = new double [5];
double [] z = new double [5];
pls.adv( 0 );
pls.vpor( 0.0, 1.0, 0.0, 0.9 );
pls.wind( -1.0, 1.0, -0.9, 1.1 );
pls.col0( 1 );
pls.w3d( 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, alt[k], az[k] );
pls.box3( "bnstu", "x axis", 0.0, 0,
"bnstu", "y axis", 0.0, 0,
"bcdmnstuv", "z axis", 0.0, 0 );
pls.col0( 2 );
// x = r sin(phi) cos(theta)
// y = r sin(phi) sin(theta)
// z = r cos(phi)
// r = 1 :=)
for ( i = 0; i < 20; i++ )
{
for ( j = 0; j < 20; j++ )
{
x[0] = Math.sin( PHI( j ) ) * Math.cos( THETA( i ) );
y[0] = Math.sin( PHI( j ) ) * Math.sin( THETA( i ) );
z[0] = Math.cos( PHI( j ) );
x[1] = Math.sin( PHI( j + 1 ) ) * Math.cos( THETA( i ) );
y[1] = Math.sin( PHI( j + 1 ) ) * Math.sin( THETA( i ) );
z[1] = Math.cos( PHI( j + 1 ) );
x[2] = Math.sin( PHI( j + 1 ) ) * Math.cos( THETA( i + 1 ) );
y[2] = Math.sin( PHI( j + 1 ) ) * Math.sin( THETA( i + 1 ) );
z[2] = Math.cos( PHI( j + 1 ) );
x[3] = Math.sin( PHI( j ) ) * Math.cos( THETA( i + 1 ) );
y[3] = Math.sin( PHI( j ) ) * Math.sin( THETA( i + 1 ) );
z[3] = Math.cos( PHI( j ) );
x[4] = Math.sin( PHI( j ) ) * Math.cos( THETA( i ) );
y[4] = Math.sin( PHI( j ) ) * Math.sin( THETA( i ) );
z[4] = Math.cos( PHI( j ) );
pls.poly3( x, y, z, draw[k], true );
}
}
pls.col0( 3 );
pls.mtex( "t", 1.0, 0.5, 0.5, "unit radius sphere" );
}
// Does a series of 3-d plots for a given data set, with different
// viewing options in each plot.
public static void main( String[] args )
{
new x18( args );
}
public x18( String[] args )
{
NumberFormat nf = NumberFormat.getNumberInstance();
int i, k;
double r;
// Parse and process command line arguments.
pls.parseopts( args, PL_PARSE_FULL | PL_PARSE_NOPROGRAM );
// Initialize plplot.
pls.init();
for ( k = 0; k < 4; k++ )
test_poly( k );
double[] x = new double[NPTS];
double[] y = new double[NPTS];
double[] z = new double[NPTS];
// From the mind of a sick and twisted physicist...
for ( i = 0; i < NPTS; i++ )
{
z[i] = -1. + 2. * i / NPTS;
// Pick one ...
// r = 1. - ( (double) i / (double) NPTS );
r = z[i];
x[i] = r * Math.cos( 2. * Math.PI * 6. * i / NPTS );
y[i] = r * Math.sin( 2. * Math.PI * 6. * i / NPTS );
}
for ( k = 0; k < 4; k++ )
{
pls.adv( 0 );
pls.vpor( 0.0, 1.0, 0.0, 0.9 );
pls.wind( -1.0, 1.0, -0.9, 1.1 );
pls.col0( 1 );
pls.w3d( 1.0, 1.0, 1.0, -1.0, 1.0, -1.0, 1.0, -1.0, 1.0, alt[k], az[k] );
pls.box3( "bnstu", "x axis", 0.0, 0,
"bnstu", "y axis", 0.0, 0,
"bcdmnstuv", "z axis", 0.0, 0 );
pls.col0( 2 );
if ( opt[k] > 0 )
pls.line3( x, y, z );
else
// U+22C5 DOT OPERATOR.
pls.string3( x, y, z, "⋅" );
pls.col0( 3 );
String title = "#frPLplot Example 18 - Alt=" +
nf.format( (int) alt[k] ) +
", Az=" +
nf.format( (int) az[k] );
pls.mtex( "t", 1.0, 0.5, 0.5, title );
}
pls.end();
}
}
//--------------------------------------------------------------------------
// End of x18.java
//--------------------------------------------------------------------------
|