Plotting boolean 3-array, roughly equivalent to 3D version of viewmat. Also plots a list of 3-coordinates similarly.
Summary
plotcubes
plotcubes (v) plot #y cubes at (x,y,z)=i{y
x is palette string of GRAYSCALE,STDCLR,RBCLR,RGCLR,RGBCLR,BGCLR simpler form of this verb is: 'poly'"_ plot cubes
view3d
view3d (v) boolean 3d viewmat
Details
The following script can be loaded by itself, which will load plot, and can be used straight away.
require 'plot' coclass 'jzplot' «support» «public» plotcubes_z_=: plotcubes_jzplot_ view3d_z_=: view3d_jzplot_ «test»
Implementation of public verbs.
NB.* plotcubes v plot #y cubes at (x,y,z)=i{y
NB. x is palette string of GRAYSCALE,STDCLR,RBCLR,RGCLR,RGBCLR,BGCLR
NB. simpler form of this verb is: 'poly'"_ plot cubes
plotcubes=: 3 : 0
'GRAYSCALE' plotcubes y
:
d=. |:_6<\ &> cubes (/: {:"1)^:(-.'STDCLR'-:x) y
MYCOLOR_jzplot_=: c{~6#<.(<:#c=.(x,'_jzplot_')~)*(i.%<:)#d
pd 'new;type poly;edgecolor gray;color MYCOLOR'
pd"1 d
pd'show'
)
NB.*view3d v boolean 3d viewmat
view3d=: 'GRAYSCALE'&$: : (plotcubes $ #: I.@,)
Private support verbs operate on cube representations.
cut3=: <"2 @ (0 1&|:) NB. 3-array to list of boxed matrices
cubic=: 3 : 0 NB. unit 3-cube
v =. 2 2 2#: i.8
ndx =. 0 2 6 4, 4 6 7 5, 1 5 7 3, 0 1 3 2, 2 3 7 6,: 0 4 5 1
ndx { v
)
NB. unit cubes shited by list of 3-coords
cubes=: [: cut3 cubic ,/@:(+"1"_ 1) ]
NB. y 3-coords from 0..x
randcubes=: 4 : '3 (# (#: ?) y&#@^~) x'
Here we do some testing and illustration. The results are given in the pictures above. Hilbert curve was built with
view3d H_3d 3
using general/2005-August/024079
NB. =========================================================
Note 'Test'
plotcubes 5 randcubes_jzplot_ 10
'STDCLR'plotcubes 5 randcubes_jzplot_ 20
'RGBCLR'plotcubes 10 randcubes_jzplot_ 100
plotcubes 30 randcubes_jzplot_ 1000
plotcubes 100 randcubes_jzplot_ 10000
]CUBES=: 5 randcubes_jzplot_ 10
cut3_jzplot_ QUBES=: 1(<"1 CUBES)}5 5 5$0 NB. coord to boolean 3-cube
(/:~CUBES) -: ($ #: I.@,) QUBES
plotcubes CUBES
view3d QUBES
'STDCLR' view3d 1>? (3#5)$10
view3d 3>? (3#20)$100
)
Thanks to RE Boss for the ideas about 3D plot shading.
See RE Boss/Jblog for comment.
See Also
- [Jgeneral] 3d plot, dot style,
- [Jgeneral] RE: Plotting high dimensional figures
- [Jforum] Visualizing (Hilbert)curves (was Re: [Jforum] assign numbers to areas)
general/2005-August/024079 general/2005-August/023984 general/2005-August/024012 general/2005-August/024020
Contributed by OlegKobchenko

