2 import sys
; sys
.path
[:0] = ["../.."]
6 p
= lambda phi
: graph
.graphxyz
.central(10, phi
, 10-phi
/18.0)
7 # p = lambda phi: graph.graphxyz.parallel(phi, 10/18.0)
9 d
= document
.document()
13 g
= c
.insert(graph
.graphxyz(10.5, 10, size
=6, projector
=p(phi
),
14 x
=graph
.axis
.lin(painter
=graph
.axis
.painter
.regular(gridattrs
=[])),
15 y
=graph
.axis
.lin(painter
=graph
.axis
.painter
.regular(gridattrs
=[])),
16 z
=graph
.axis
.lin(painter
=graph
.axis
.painter
.regular(gridattrs
=[]))))
17 g
.plot(graph
.data
.values(x
=[0, 0, 0, 1], y
=[0, 0, 1, 1], z
=[0, 1, 0, 1], color
=[0, 0.33, 0.67, 1]),
18 [graph
.style
.gridpos(index1
=1, index2
=2), graph
.style
.surface(gridcolor
=color
.gray(0.9))])
20 g
.text(2, 2, str(phi
))
21 def vrect(vx1
, vy1
, vz1
, vx2
, vy2
, vz2
):
22 assert len([v1_v2
for v1_v2
in [(vx1
, vx2
), (vy1
, vy2
), (vz1
, vz2
)] if v1_v2
[0] == v1_v2
[1]]) == 1
24 return path
.path(path
.moveto_pt(*g
.vpos_pt(vx1
, vy1
, vz1
)),
25 path
.lineto_pt(*g
.vpos_pt(vx1
, vy2
, vz1
)),
26 path
.lineto_pt(*g
.vpos_pt(vx2
, vy2
, vz1
)),
27 path
.lineto_pt(*g
.vpos_pt(vx2
, vy1
, vz1
)),
30 return path
.path(path
.moveto_pt(*g
.vpos_pt(vx1
, vy1
, vz1
)),
31 path
.lineto_pt(*g
.vpos_pt(vx1
, vy1
, vz2
)),
32 path
.lineto_pt(*g
.vpos_pt(vx2
, vy1
, vz2
)),
33 path
.lineto_pt(*g
.vpos_pt(vx2
, vy1
, vz1
)),
36 return path
.path(path
.moveto_pt(*g
.vpos_pt(vx1
, vy1
, vz1
)),
37 path
.lineto_pt(*g
.vpos_pt(vx1
, vy2
, vz1
)),
38 path
.lineto_pt(*g
.vpos_pt(vx1
, vy2
, vz2
)),
39 path
.lineto_pt(*g
.vpos_pt(vx1
, vy1
, vz2
)),
41 g
.fill(vrect(0.4, 0.4, 0, 0.6, 0.6, 0), [g
.pz0show
and color
.rgb
.green
or color
.rgb
.red
])
42 g
.fill(vrect(0.4, 0.4, 1, 0.6, 0.6, 1), [g
.pz1show
and color
.rgb
.green
or color
.rgb
.red
])
43 g
.fill(vrect(0.4, 0, 0.4, 0.6, 0, 0.6), [g
.py0show
and color
.rgb
.green
or color
.rgb
.red
])
44 g
.fill(vrect(0.4, 1, 0.4, 0.6, 1, 0.6), [g
.py1show
and color
.rgb
.green
or color
.rgb
.red
])
45 g
.fill(vrect(0, 0.4, 0.4, 0, 0.6, 0.6), [g
.px0show
and color
.rgb
.green
or color
.rgb
.red
])
46 g
.fill(vrect(1, 0.4, 0.4, 1, 0.6, 0.6), [g
.px1show
and color
.rgb
.green
or color
.rgb
.red
])
47 for axis
in list(g
.axes
.values()):
48 g
.stroke(axis
.basepath(), [axis
.hidden
and color
.rgb
.red
or color
.rgb
.green
])
49 d
.append(document
.page(c
))
52 d
.writePSfile("test_graph3dloop")
53 d
.writePDFfile("test_graph3dloop")