/usr/share/doc/libplplot12/examples/lua/x18.lua is in libplplot-dev 5.10.0+dfsg2-0.1ubuntu2.
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 | --[[ $Id: x18.lua 11680 2011-03-27 17:57:51Z airwin $
3-d line and point plot demo. Adapted from x08c.c.
Copyright (C) 2008 Werner Smekal
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 either version 2 of the License, or
(at your option) any later version.
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
--]]
-- initialise Lua bindings for PLplot examples.
dofile("plplot_examples.lua")
function test_poly(k)
draw= { { 1, 1, 1, 1 },
{ 1, 0, 1, 0 },
{ 0, 1, 0, 1 },
{ 1, 1, 0, 0 } }
x = {}
y = {}
z = {}
pl.adv(0)
pl.vpor(0, 1, 0, 0.9)
pl.wind(-1, 1, -0.9, 1.1)
pl.col0(1)
pl.w3d(1, 1, 1, -1, 1, -1, 1, -1, 1, alt[k], az[k])
pl.box3("bnstu", "x axis", 0, 0,
"bnstu", "y axis", 0, 0,
"bcdmnstuv", "z axis", 0, 0)
pl.col0(2)
-- x = r sin(phi) cos(theta)
-- y = r sin(phi) sin(theta)
-- z = r cos(phi)
-- r = 1 :=)
for i=0, 19 do
for j=0, 19 do
x[1] = math.sin( math.pi*j/20.1 ) * math.cos( 2*math.pi*i/20 )
y[1] = math.sin( math.pi*j/20.1 ) * math.sin( 2*math.pi*i/20 )
z[1] = math.cos( math.pi*j/20.1 )
x[2] = math.sin( math.pi*(j+1)/20.1 ) * math.cos( 2*math.pi*i/20 )
y[2] = math.sin( math.pi*(j+1)/20.1 ) * math.sin( 2*math.pi*i/20 )
z[2] = math.cos( math.pi*(j+1)/20.1 )
x[3] = math.sin( math.pi*(j+1)/20.1 ) * math.cos( 2*math.pi*(i+1)/20 )
y[3] = math.sin( math.pi*(j+1)/20.1 ) * math.sin( 2*math.pi*(i+1)/20 )
z[3] = math.cos( math.pi*(j+1)/20.1 )
x[4] = math.sin( math.pi*j/20.1 ) * math.cos( 2*math.pi*(i+1)/20 )
y[4] = math.sin( math.pi*j/20.1 ) * math.sin( 2*math.pi*(i+1)/20 )
z[4] = math.cos( math.pi*j/20.1 )
x[5] = math.sin( math.pi*j/20.1 ) * math.cos( 2*math.pi*i/20 )
y[5] = math.sin( math.pi*j/20.1 ) * math.sin( 2*math.pi*i/20 )
z[5] = math.cos( math.pi*j/20.1 )
pl.poly3( x, y, z, draw[k], 1 )
end
end
pl.col0(3)
pl.mtex("t", 1, 0.5, 0.5, "unit radius sphere" )
end
----------------------------------------------------------------------------
-- main
--
-- Does a series of 3-d plots for a given data set, with different
-- viewing options in each plot.
----------------------------------------------------------------------------
NPTS = 1000
opt = { 1, 0, 1, 0 }
alt = { 20, 35, 50, 65 }
az = { 30, 40, 50, 60 }
-- Parse and process command line arguments
pl.parseopts(arg, pl.PL_PARSE_FULL)
-- Initialize plplot
pl.init()
for k=1, 4 do
test_poly(k)
end
x = {}
y = {}
z = {}
-- From the mind of a sick and twisted physicist...
for i=1, NPTS do
z[i] = -1 + 2*(i-1)/NPTS
-- Pick one ...
-- r = 1 - (i-1) / NPTS
r = z[i]
x[i] = r * math.cos( 12*math.pi*(i-1)/NPTS )
y[i] = r * math.sin( 12*math.pi*(i-1)/NPTS )
end
for k=1, 4 do
pl.adv(0)
pl.vpor(0, 1, 0, 0.9)
pl.wind(-1, 1, -0.9, 1.1)
pl.col0(1)
pl.w3d(1, 1, 1, -1, 1, -1, 1, -1, 1, alt[k], az[k])
pl.box3("bnstu", "x axis", 0, 0,
"bnstu", "y axis", 0, 0,
"bcdmnstuv", "z axis", 0, 0)
pl.col0(2)
if opt[k]~=0 then
pl.line3( x, y, z )
else
-- U+22C5 DOT OPERATOR.
pl.string3( x, y, z, "⋅" )
end
pl.col0(3)
pl.mtex("t", 1.0, 0.5, 0.5, "#frPLplot Example 18 - Alt=" .. alt[k] .. ", Az=" .. az[k])
end
pl.plend()
|