Listing 2. Geomview Example Listing
\cat geom-ex.r | pr -t -n:2 -
1:N = 40;
2:x = linspace(-1,1,N);
3:y = x;
4:z = zeros(N, N);
5:
6:for (i in 1:N)
7:{
8: for (j in 1:N)
9: {
10: r = sqrt(x[i]^2 + y[j]^2);
11: z[i;j]=.4*(exp(-r*r)*cos(2*pi*r));
12: }
13:}
14:
15:GM = "|/usr/local/bin/geomview -c -";
16:fprintf(GM,...
17: "(geometry rmesh { : rmesh })\n");
18:fprintf(GM,...
19: "(read geometry { define rmesh\n");
20:fprintf(GM,"MESH\n");
21:fprintf(GM,"%i %i\n", N, N);
22:
23:for (i in 1:x.n)
24:{
25: for (j in 1:y.n)
26: {
27: fprintf(GM,"%f %f %f\n",...
28: x[i],y[j],z[i;j]);
29: }
30:}
31:
32:fprintf(GM, "})\n");
Copyright © 1994 - 2019 Linux Journal. All rights reserved.