1
c $Id: x28f.fm4 11680 2011-03-27 17:57:51Z airwin $
3
c Demonstrates plotting text in 3D (plmtex3, plptex3)
5
c Copyright (C) 2007 Alan W. Irwin
7
c This file is part of PLplot.
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.
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.
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
27
include 'plplot_parameters.h'
29
integer XPTS, YPTS, NREVOLUTION, NROTATION, NSHEAR
32
parameter(NREVOLUTION = 16)
33
parameter(NROTATION = 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 ))
64
real*8 x_inclination, y_inclination, z_inclination,
65
& x_shear, y_shear, z_shear,
66
& omega, sin_omega, cos_omega, domega
68
real*8 radius, pitch, xpos, ypos, zpos
73
& "The future of our civilization depends on software freedom."
76
x(i) = xmin + dble(i-1)*(xmax-xmin)/dble(XPTS-1)
80
y(j) = ymin + dble(j-1)*(ymax-ymin)/dble(YPTS-1)
89
c Parse and process command line arguments
91
call plparseopts(PL_PARSE_FULL)
95
c Page 1: Demonstrate inclination and shear capability pattern.
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,
105
call plbox3("b", "", xmax-xmin, 0,
106
& "b", "", ymax-ymin, 0,
107
& "bcd", "", zmax-zmin, 0)
110
call plschr(0.d0, 1.0d0)
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
118
x_shear = -0.5d0*xrange*sin_omega
119
y_shear = 0.5d0*yrange*cos_omega
123
& x_inclination, y_inclination, z_inclination,
124
& x_shear, y_shear, z_shear,
125
& 0.0d0, " revolution")
129
call plschr(0.d0, 1.0d0)
131
omega = 2.d0*PI*(dble(i-1)/dble(NREVOLUTION))
132
sin_omega = sin(omega)
133
cos_omega = cos(omega)
135
y_inclination = -0.5d0*yrange*cos_omega
136
z_inclination = 0.5d0*zrange*sin_omega
138
y_shear = 0.5d0*yrange*sin_omega
139
z_shear = 0.5d0*zrange*cos_omega
142
& x_inclination, y_inclination, z_inclination,
143
& x_shear, y_shear, z_shear,
144
& 0.0d0, " revolution")
148
call plschr(0.d0, 1.0d0)
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
155
z_inclination = 0.5d0*zrange*sin_omega
156
x_shear = -0.5d0*xrange*sin_omega
158
z_shear = 0.5d0*zrange*cos_omega
161
& x_inclination, y_inclination, z_inclination,
162
& x_shear, y_shear, z_shear,
163
& 0.0d0, " revolution")
165
c Draw minimal 3D grid to finish defining the 3D box.
166
call plmesh(x, y, z, XPTS, YPTS, DRAW_LINEXY, XPTS)
168
c Page 2: Demonstrate rotation of string around its axis.
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,
177
call plbox3("b", "", xmax-xmin, 0,
178
& "b", "", ymax-ymin, 0,
179
& "bcd", "", zmax-zmin, 0)
182
call plschr(0.d0, 1.0d0)
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)
196
& x_inclination, y_inclination, z_inclination,
197
& x_shear, y_shear, z_shear,
198
& 0.5d0, "rotation for y = y#dmax#u")
202
call plschr(0.d0, 1.0d0)
204
y_inclination = -1.d0
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)
216
& x_inclination, y_inclination, z_inclination,
217
& x_shear, y_shear, z_shear,
218
& 0.5d0, "rotation for x = x#dmax#u")
222
call plschr(0.d0, 1.0d0)
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)
236
& x_inclination, y_inclination, z_inclination,
237
& x_shear, y_shear, z_shear,
238
& 0.5d0, "rotation for z = z#dmin#u")
240
c Draw minimal 3D grid to finish defining the 3D box.
241
call plmesh(x, y, z, XPTS, YPTS, DRAW_LINEXY, XPTS)
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.)
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,
256
call plbox3("b", "", xmax-xmin, 0,
257
& "b", "", ymax-ymin, 0,
258
& "bcd", "", zmax-zmin, 0)
261
call plschr(0.d0, 1.0d0)
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)
275
& x_inclination, y_inclination, z_inclination,
276
& x_shear, y_shear, z_shear,
277
& 0.5d0, "shear for y = y#dmax#u")
281
call plschr(0.d0, 1.0d0)
283
y_inclination = -1.d0
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)
295
& x_inclination, y_inclination, z_inclination,
296
& x_shear, y_shear, z_shear,
297
& 0.5d0, "shear for x = x#dmax#u")
301
call plschr(0.d0, 1.0d0)
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)
315
& x_inclination, y_inclination, z_inclination,
316
& x_shear, y_shear, z_shear,
317
& 0.5d0, "shear for z = z#dmin#u")
320
c Draw minimal 3D grid to finish defining the 3D box.
321
call plmesh(x, y, z, XPTS, YPTS, DRAW_LINEXY, XPTS)
323
c Page 4: Demonstrate drawing a string on a 3D path.
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,
332
call plbox3("b", "", xmax-xmin, 0,
333
& "b", "", ymax-ymin, 0,
334
& "bcd", "", zmax-zmin, 0)
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)
342
c 3D function is a helix of the given radius and pitch
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.
364
& x_inclination, y_inclination, z_inclination,
365
& x_shear, y_shear, z_shear,
366
& 0.5d0, pstring(i:i))
367
omega = omega + domega
369
c Draw minimal 3D grid to finish defining the 3D box.
370
call plmesh(x, y, z, XPTS, YPTS, DRAW_LINEXY, XPTS)
372
c Page 5: Demonstrate plmtex3 axis labelling capability
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,
381
call plbox3("b", "", xmax-xmin, 0,
382
& "b", "", ymax-ymin, 0,
383
& "bcd", "", zmax-zmin, 0)
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)