~uhh-ssd/+junk/humidity_readout

« back to all changes in this revision

Viewing changes to plplot/plplot-5.9.9/examples/f77/x28f.fm4

  • Committer: Joachim Erfle
  • Date: 2013-07-24 13:53:41 UTC
  • Revision ID: joachim.erfle@desy.de-20130724135341-1qojpp701zsn009p
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
c  $Id: x28f.fm4 11680 2011-03-27 17:57:51Z airwin $
 
2
c
 
3
c   Demonstrates plotting text in 3D (plmtex3, plptex3)
 
4
c
 
5
c   Copyright (C) 2007  Alan W. Irwin
 
6
c
 
7
c   This file is part of PLplot.
 
8
c
 
9
c   PLplot is free software; you can redistribute it and/or modify
 
10
c   it under the terms of the GNU Library General Public License as
 
11
c   published by the Free Software Foundation; either version 2 of the
 
12
c   License, or (at your option) any later version.
 
13
c
 
14
c   PLplot is distributed in the hope that it will be useful,
 
15
c   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
c   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
c   GNU Library General Public License for more details.
 
18
c
 
19
c   You should have received a copy of the GNU Library General Public
 
20
c   License along with PLplot; if not, write to the Free Software
 
21
c   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
22
c
 
23
 
 
24
      program x28f
 
25
 
 
26
      implicit none
 
27
      include 'plplot_parameters.h'
 
28
 
 
29
      integer XPTS, YPTS, NREVOLUTION, NROTATION, NSHEAR
 
30
      parameter(XPTS = 2)
 
31
      parameter(YPTS = 2)
 
32
      parameter(NREVOLUTION = 16)
 
33
      parameter(NROTATION = 8)
 
34
      parameter(NSHEAR = 8)
 
35
      real*8 x(XPTS), y(YPTS), z(XPTS,YPTS)
 
36
      real*8 xmin, xmax, xmid, xrange
 
37
      parameter(xmin = 0.d0)
 
38
      parameter(xmax = 1.d0)
 
39
      parameter(xmid = 0.5d0*(xmax+xmin))
 
40
      parameter(xrange = xmax-xmin)
 
41
      real*8 ymin, ymax, ymid, yrange
 
42
      parameter(ymin = 0.d0)
 
43
      parameter(ymax = 1.d0)
 
44
      parameter(ymid = 0.5d0*(ymax+ymin))
 
45
      parameter(yrange = ymax-ymin)
 
46
      real*8 zmin, zmax, zmid, zrange
 
47
      parameter(zmin = 0.d0)
 
48
      parameter(zmax = 1.d0)
 
49
      parameter(zmid = 0.5d0*(zmax+zmin))
 
50
      parameter(zrange = zmax-zmin)
 
51
      real*8 ysmin, ysmax, ysrange, dysrot, dysshear
 
52
      parameter(ysmin    = ymin + 0.1 * yrange)
 
53
      parameter(ysmax    = ymax - 0.1 * yrange)
 
54
      parameter(ysrange  = ysmax - ysmin)
 
55
      parameter(dysrot   = ysrange / ( NROTATION - 1 ))
 
56
      parameter(dysshear = ysrange / ( NSHEAR - 1 ))
 
57
      real*8 zsmin, zsmax, zsrange, dzsrot, dzsshear
 
58
      parameter(zsmin    = zmin + 0.1 * zrange)
 
59
      parameter(zsmax    = zmax - 0.1 * zrange)
 
60
      parameter(zsrange  = zsmax - zsmin)
 
61
      parameter(dzsrot   = zsrange / ( NROTATION - 1 ))
 
62
      parameter(dzsshear = zsrange / ( NSHEAR - 1 ))
 
63
      real*8 ys, zs
 
64
      real*8 x_inclination, y_inclination, z_inclination,
 
65
     &  x_shear, y_shear, z_shear,
 
66
     &  omega, sin_omega, cos_omega, domega
 
67
      integer i, j
 
68
      real*8 radius, pitch, xpos, ypos, zpos
 
69
      integer lnblnk
 
70
 
 
71
      character*80 pstring
 
72
      pstring =
 
73
     &  "The future of our civilization depends on software freedom."
 
74
 
 
75
      do i = 1,XPTS
 
76
         x(i) = xmin + dble(i-1)*(xmax-xmin)/dble(XPTS-1)
 
77
      enddo
 
78
 
 
79
      do j = 1,YPTS
 
80
         y(j) = ymin + dble(j-1)*(ymax-ymin)/dble(YPTS-1)
 
81
      enddo
 
82
       
 
83
      do j = 1,YPTS
 
84
        do i = 1,XPTS
 
85
          z(i,j) = 0.d0
 
86
        enddo
 
87
      enddo
 
88
 
 
89
c      Parse and process command line arguments
 
90
 
 
91
      call plparseopts(PL_PARSE_FULL)
 
92
 
 
93
      call plinit()
 
94
 
 
95
c      Page 1: Demonstrate inclination and shear capability pattern.
 
96
 
 
97
      call pladv(0)
 
98
      call plvpor(-0.15d0, 1.15d0, -0.05d0, 1.05d0)
 
99
      call plwind(-1.2d0, 1.2d0, -0.8d0, 1.5d0)
 
100
      call plw3d(1.0d0, 1.0d0, 1.0d0,
 
101
     &  xmin, xmax, ymin, ymax, zmin, zmax,
 
102
     &  20.d0, 45.d0)
 
103
 
 
104
      call plcol0(2)
 
105
      call plbox3("b",   "", xmax-xmin, 0,
 
106
     & "b",   "", ymax-ymin, 0,
 
107
     & "bcd", "", zmax-zmin, 0)
 
108
 
 
109
c      z = zmin.
 
110
      call plschr(0.d0, 1.0d0)
 
111
      do i = 1,NREVOLUTION
 
112
         omega = 2.d0*PI*(dble(i-1)/dble(NREVOLUTION))
 
113
         sin_omega = sin(omega)
 
114
         cos_omega = cos(omega)
 
115
         x_inclination = 0.5d0*xrange*cos_omega
 
116
         y_inclination = 0.5d0*yrange*sin_omega
 
117
         z_inclination = 0.d0
 
118
         x_shear = -0.5d0*xrange*sin_omega
 
119
         y_shear = 0.5d0*yrange*cos_omega
 
120
         z_shear = 0.d0
 
121
         call plptex3(
 
122
     &     xmid, ymid, zmin,
 
123
     &     x_inclination, y_inclination, z_inclination,
 
124
     &     x_shear, y_shear, z_shear,
 
125
     &     0.0d0, "  revolution")
 
126
      enddo
 
127
 
 
128
c      x = xmax.
 
129
      call plschr(0.d0, 1.0d0)
 
130
      do i = 1,NREVOLUTION
 
131
         omega = 2.d0*PI*(dble(i-1)/dble(NREVOLUTION))
 
132
         sin_omega = sin(omega)
 
133
         cos_omega = cos(omega)
 
134
         x_inclination = 0.d0
 
135
         y_inclination = -0.5d0*yrange*cos_omega
 
136
         z_inclination = 0.5d0*zrange*sin_omega
 
137
         x_shear = 0.d0
 
138
         y_shear = 0.5d0*yrange*sin_omega
 
139
         z_shear = 0.5d0*zrange*cos_omega
 
140
         call plptex3(
 
141
     &     xmax, ymid, zmid,
 
142
     &     x_inclination, y_inclination, z_inclination,
 
143
     &     x_shear, y_shear, z_shear,
 
144
     &     0.0d0, "  revolution")
 
145
      enddo
 
146
 
 
147
c      y = ymax.
 
148
      call plschr(0.d0, 1.0d0)
 
149
      do i = 1,NREVOLUTION
 
150
         omega = 2.d0*PI*(dble(i-1)/dble(NREVOLUTION))
 
151
         sin_omega = sin(omega)
 
152
         cos_omega = cos(omega)
 
153
         x_inclination = 0.5d0*xrange*cos_omega
 
154
         y_inclination = 0.d0
 
155
         z_inclination = 0.5d0*zrange*sin_omega
 
156
         x_shear = -0.5d0*xrange*sin_omega
 
157
         y_shear = 0.d0
 
158
         z_shear = 0.5d0*zrange*cos_omega
 
159
         call plptex3(
 
160
     &     xmid, ymax, zmid,
 
161
     &     x_inclination, y_inclination, z_inclination,
 
162
     &     x_shear, y_shear, z_shear,
 
163
     &     0.0d0, "  revolution")
 
164
      enddo
 
165
c      Draw minimal 3D grid to finish defining the 3D box.
 
166
      call plmesh(x, y, z, XPTS, YPTS, DRAW_LINEXY, XPTS)
 
167
 
 
168
c      Page 2: Demonstrate rotation of string around its axis.
 
169
      call pladv(0)
 
170
      call plvpor(-0.15d0, 1.15d0, -0.05d0, 1.05d0)
 
171
      call plwind(-1.2d0, 1.2d0, -0.8d0, 1.5d0)
 
172
      call plw3d(1.0d0, 1.0d0, 1.0d0,
 
173
     &  xmin, xmax, ymin, ymax, zmin, zmax,
 
174
     &  20.d0, 45.d0)
 
175
 
 
176
      call plcol0(2)
 
177
      call plbox3("b",   "", xmax-xmin, 0,
 
178
     & "b",   "", ymax-ymin, 0,
 
179
     & "bcd", "", zmax-zmin, 0)
 
180
 
 
181
c      y = ymax.
 
182
      call plschr(0.d0, 1.0d0)
 
183
      x_inclination = 1.d0
 
184
      y_inclination = 0.d0
 
185
      z_inclination = 0.d0
 
186
      x_shear = 0.d0
 
187
      do i = 1,NROTATION
 
188
         omega = 2.d0*PI*dble(i-1)/dble(NROTATION)
 
189
         sin_omega = sin(omega)
 
190
         cos_omega = cos(omega)
 
191
         y_shear = 0.5d0*yrange*sin_omega
 
192
         z_shear = 0.5d0*zrange*cos_omega
 
193
         zs        = zsmax - dzsrot * dble(i-1)
 
194
         call plptex3(
 
195
     &     xmid, ymax, zs,
 
196
     &     x_inclination, y_inclination, z_inclination,
 
197
     &     x_shear, y_shear, z_shear,
 
198
     &     0.5d0, "rotation for y = y#dmax#u")
 
199
      enddo
 
200
 
 
201
c      x = xmax.
 
202
      call plschr(0.d0, 1.0d0)
 
203
      x_inclination = 0.d0
 
204
      y_inclination = -1.d0
 
205
      z_inclination = 0.d0
 
206
      y_shear = 0.d0
 
207
      do i = 1,NROTATION
 
208
         omega = 2.d0*PI*dble(i-1)/dble(NROTATION)
 
209
         sin_omega = sin(omega)
 
210
         cos_omega = cos(omega)
 
211
         x_shear = 0.5d0*xrange*sin_omega
 
212
         z_shear = 0.5d0*zrange*cos_omega
 
213
         zs        = zsmax - dzsrot * dble(i-1)
 
214
         call plptex3(
 
215
     &     xmax, ymid, zs,
 
216
     &     x_inclination, y_inclination, z_inclination,
 
217
     &     x_shear, y_shear, z_shear,
 
218
     &     0.5d0, "rotation for x = x#dmax#u")
 
219
      enddo
 
220
 
 
221
c      z = zmin.
 
222
      call plschr(0.d0, 1.0d0)
 
223
      x_inclination = 1.d0
 
224
      y_inclination = 0.d0
 
225
      z_inclination = 0.d0
 
226
      x_shear = 0.d0
 
227
      do i = 1,NROTATION
 
228
         omega = 2.d0*PI*dble(i-1)/dble(NROTATION)
 
229
         sin_omega = sin(omega)
 
230
         cos_omega = cos(omega)
 
231
         y_shear = 0.5d0*yrange*cos_omega
 
232
         z_shear = 0.5d0*zrange*sin_omega
 
233
         ys        = ysmax - dysrot * dble(i-1)
 
234
         call plptex3(
 
235
     &     xmid, ys, zmin,
 
236
     &     x_inclination, y_inclination, z_inclination,
 
237
     &     x_shear, y_shear, z_shear,
 
238
     &     0.5d0, "rotation for z = z#dmin#u")
 
239
      enddo
 
240
c      Draw minimal 3D grid to finish defining the 3D box.
 
241
      call plmesh(x, y, z, XPTS, YPTS, DRAW_LINEXY, XPTS)
 
242
 
 
243
c      Page 3: Demonstrate shear of string along its axis.
 
244
c      Work around xcairo and pngcairo (but not pscairo) problems for
 
245
c      shear vector too close to axis of string. (N.B. no workaround
 
246
c      would be domega = 0.d0.)
 
247
      domega = 0.05d0
 
248
      call pladv(0)
 
249
      call plvpor(-0.15d0, 1.15d0, -0.05d0, 1.05d0)
 
250
      call plwind(-1.2d0, 1.2d0, -0.8d0, 1.5d0)
 
251
      call plw3d(1.0d0, 1.0d0, 1.0d0,
 
252
     &  xmin, xmax, ymin, ymax, zmin, zmax,
 
253
     &  20.d0, 45.d0)
 
254
 
 
255
      call plcol0(2)
 
256
      call plbox3("b",   "", xmax-xmin, 0,
 
257
     & "b",   "", ymax-ymin, 0,
 
258
     & "bcd", "", zmax-zmin, 0)
 
259
 
 
260
c      y = ymax.
 
261
      call plschr(0.d0, 1.0d0)
 
262
      x_inclination = 1.d0
 
263
      y_inclination = 0.d0
 
264
      z_inclination = 0.d0
 
265
      y_shear = 0.d0
 
266
      do i = 1,NSHEAR
 
267
         omega = domega + 2.d0*PI*dble(i-1)/dble(NSHEAR)
 
268
         sin_omega = sin(omega)
 
269
         cos_omega = cos(omega)
 
270
         x_shear = 0.5d0*xrange*sin_omega
 
271
         z_shear = 0.5d0*zrange*cos_omega
 
272
         zs        = zsmax - dzsshear * dble(i-1)
 
273
         call plptex3(
 
274
     &     xmid, ymax, zs,
 
275
     &     x_inclination, y_inclination, z_inclination,
 
276
     &     x_shear, y_shear, z_shear,
 
277
     &     0.5d0, "shear for y = y#dmax#u")
 
278
      enddo
 
279
 
 
280
c      x = xmax.
 
281
      call plschr(0.d0, 1.0d0)
 
282
      x_inclination = 0.d0
 
283
      y_inclination = -1.d0
 
284
      z_inclination = 0.d0
 
285
      x_shear = 0.d0
 
286
      do i = 1,NSHEAR
 
287
         omega = domega + 2.d0*PI*dble(i-1)/dble(NSHEAR)
 
288
         sin_omega = sin(omega)
 
289
         cos_omega = cos(omega)
 
290
         y_shear = -0.5d0*yrange*sin_omega
 
291
         z_shear = 0.5d0*zrange*cos_omega
 
292
         zs        = zsmax - dzsshear * dble(i-1)
 
293
         call plptex3(
 
294
     &     xmax, ymid, zs,
 
295
     &     x_inclination, y_inclination, z_inclination,
 
296
     &     x_shear, y_shear, z_shear,
 
297
     &     0.5d0, "shear for x = x#dmax#u")
 
298
      enddo
 
299
 
 
300
c      z = zmin.
 
301
      call plschr(0.d0, 1.0d0)
 
302
      x_inclination = 1.d0
 
303
      y_inclination = 0.d0
 
304
      z_inclination = 0.d0
 
305
      z_shear = 0.d0
 
306
      do i = 1,NSHEAR
 
307
         omega = domega + 2.d0*PI*dble(i-1)/dble(NSHEAR)
 
308
         sin_omega = sin(omega)
 
309
         cos_omega = cos(omega)
 
310
         y_shear = 0.5d0*yrange*cos_omega
 
311
         x_shear = 0.5d0*xrange*sin_omega
 
312
         ys        = ysmax - dysshear * dble(i-1)
 
313
         call plptex3(
 
314
     &     xmid, ys, zmin,
 
315
     &     x_inclination, y_inclination, z_inclination,
 
316
     &     x_shear, y_shear, z_shear,
 
317
     &     0.5d0, "shear for z = z#dmin#u")
 
318
      enddo
 
319
 
 
320
c      Draw minimal 3D grid to finish defining the 3D box.
 
321
      call plmesh(x, y, z, XPTS, YPTS, DRAW_LINEXY, XPTS)
 
322
 
 
323
c      Page 4: Demonstrate drawing a string on a 3D path.
 
324
      call pladv(0)
 
325
      call plvpor(-0.15d0, 1.15d0, -0.05d0, 1.05d0)
 
326
      call plwind(-1.2d0, 1.2d0, -0.8d0, 1.5d0)
 
327
      call plw3d(1.0d0, 1.0d0, 1.0d0,
 
328
     &  xmin, xmax, ymin, ymax, zmin, zmax,
 
329
     &  40.d0, -30.d0)
 
330
 
 
331
      call plcol0(2)
 
332
      call plbox3("b",   "", xmax-xmin, 0,
 
333
     & "b",   "", ymax-ymin, 0,
 
334
     & "bcd", "", zmax-zmin, 0)
 
335
 
 
336
      call plschr(0.d0, 1.2d0)
 
337
c      domega controls the spacing between the various characters of the
 
338
c      string and also the maximum value of omega for the given number
 
339
c      of characters in pstring.
 
340
      domega = 2.d0*PI/lnblnk(pstring)
 
341
      omega = 0.d0
 
342
c      3D function is a helix of the given radius and pitch
 
343
      radius = 0.5d0
 
344
      pitch = 1.d0/(2.d0*PI)
 
345
      do i = 1,lnblnk(pstring)
 
346
         sin_omega = sin(omega)
 
347
         cos_omega = cos(omega)
 
348
         xpos = xmid + radius*sin_omega
 
349
         ypos = ymid - radius*cos_omega
 
350
         zpos = zmin + pitch*omega
 
351
c         In general, the inclination is proportional to the derivative of
 
352
c         the position wrt theta.
 
353
         x_inclination = radius*cos_omega
 
354
         y_inclination = radius*sin_omega
 
355
         z_inclination = pitch
 
356
c         The shear vector should be perpendicular to the 3D line with Z
 
357
c         component maximized, but for low pitch a good approximation is
 
358
c         a constant vector that is parallel to the Z axis.
 
359
         x_shear = 0.d0
 
360
         y_shear = 0.d0
 
361
         z_shear = 1.d0
 
362
         call plptex3(
 
363
     &     xpos, ypos, zpos,
 
364
     &     x_inclination, y_inclination, z_inclination,
 
365
     &     x_shear, y_shear, z_shear,
 
366
     &     0.5d0, pstring(i:i))
 
367
           omega = omega + domega
 
368
      enddo
 
369
c      Draw minimal 3D grid to finish defining the 3D box.
 
370
      call plmesh(x, y, z, XPTS, YPTS, DRAW_LINEXY, XPTS)
 
371
 
 
372
c Page 5: Demonstrate plmtex3 axis labelling capability
 
373
      call pladv(0)
 
374
      call plvpor(-0.15d0, 1.15d0, -0.05d0, 1.05d0)
 
375
      call plwind(-1.2d0, 1.2d0, -0.8d0, 1.5d0)
 
376
      call plw3d(1.0d0, 1.0d0, 1.0d0,
 
377
     &  xmin, xmax, ymin, ymax, zmin, zmax,
 
378
     &  20.d0, 45.d0)
 
379
 
 
380
      call plcol0(2)
 
381
      call plbox3("b",   "", xmax-xmin, 0,
 
382
     & "b",   "", ymax-ymin, 0,
 
383
     & "bcd", "", zmax-zmin, 0)
 
384
 
 
385
      call plschr(0.d0, 1.0d0)
 
386
      call plmtex3("xp", 3.0d0, 0.5d0, 0.5d0, "Arbitrarily displaced")
 
387
      call plmtex3("xp", 4.5d0, 0.5d0, 0.5d0, "primary X-axis label")
 
388
      call plmtex3("xs", -2.5d0, 0.5d0, 0.5d0, "Arbitrarily displaced")
 
389
      call plmtex3("xs", -1.0d0, 0.5d0, 0.5d0, "secondary X-axis label")
 
390
      call plmtex3("yp", 3.0d0, 0.5d0, 0.5d0, "Arbitrarily displaced")
 
391
      call plmtex3("yp", 4.5d0, 0.5d0, 0.5d0, "primary Y-axis label")
 
392
      call plmtex3("ys", -2.5d0, 0.5d0, 0.5d0, "Arbitrarily displaced")
 
393
      call plmtex3("ys", -1.0d0, 0.5d0, 0.5d0, "secondary Y-axis label")
 
394
      call plmtex3("zp", 4.5d0, 0.5d0, 0.5d0, "Arbitrarily displaced")
 
395
      call plmtex3("zp", 3.0d0, 0.5d0, 0.5d0, "primary Z-axis label")
 
396
      call plmtex3("zs", -2.5d0, 0.5d0, 0.5d0, "Arbitrarily displaced")
 
397
      call plmtex3("zs", -1.0d0, 0.5d0, 0.5d0, "secondary Z-axis label")
 
398
c      Draw minimal 3D grid to finish defining the 3D box.
 
399
      call plmesh(x, y, z, XPTS, YPTS, DRAW_LINEXY, XPTS)
 
400
 
 
401
      call plend()
 
402
      stop
 
403
      end