in reply to Re^4: 3D module
in thread 3D module
Now you've explained what you are trying to do, which if I've understood you, is a 3D version of Equidistant Letter Sequences (ELS), I am rather baffled as to why you think that you need a matrix of the huge proportions that you indicated.
The way the ELS work in 2D space is to form a 2D grid from the 304805 letters such that x*y is equal to (or slightly greater) than 304805. Not 304805 **2 = 93 billion (and definitely not (304805*2+1)**2 = 371 billion which would be the 2d equivalent of the -304805 < (x=y=z)< 304805 you indicated you are looking for?).
Eg.
The 3D equivalent of the ELS would be to print the characters as (for example) 60 lines of 80 characters on 64 pages (80x60x64=307200) and then search the 3D space. Building an matrix of these dimensions takes less that 10 MB using standard Perl nested arrays.
However, the fastest way to search for patterns in the text in 3D space would be to leave the text as a single long string and use the regex engine to do the work. For example, to search for a particular word along the Z-axis, you might use a regex like
my( $x, $y, $z ) = ( 80, 60, 64 ); my $searchWord = 'BrowserUk'; my $re_Z = qr[ ## Not a valid regex. B .{80*60} r .{80*60} o .{80*60} w .{80*60} s .{80*60} e .{80*60} r .{80*60} U .(80*60} k ]x;
You can't actually use math within a quantifier brackets, but that's just to show how the math would be used.
Generating regexes to search the 14 26 directions for any given word is a pretty simple process:
my( $x, $y, $z ) = ( 80, 60, 64 ); ## Loop over the chosen sets of dim +ensions my $word = 'browseruk'; ## and a set of words to look for my $spacing = 80 * 60;; my $z_f2b = join ".{$spacing}", split '', $word;; print $z_f2b; ## Z-axis front to back b.{4800}r.{4800}o.{4800}w.{4800}s.{4800}e.{4800}r.{4800}u.{4800}k my $z_b2f = join ".{$spacing}", reverse split '', $word;; print $z_b2f;; ## Z-axis back to front k.{4800}u.{4800}r.{4800}e.{4800}s.{4800}w.{4800}o.{4800}r.{4800}b $spacing = 80 * 61 + 1;; ## Diagonally down and back my $d_ftl2bbr = join ".{$spacing}", split '', $word;; print $d_ftl2bbr;; ## Diagonal front top left to back bottom right b.{4881}r.{4881}o.{4881}w.{4881}s.{4881}e.{4881}r.{4881}u.{4881}k my $d_bbr2ftl = join ".{$spacing}", reverse split '', $word;; print $d_bbr2ftl;; ## diagonal back bottom right to front top left k.{4881}u.{4881}r.{4881}e.{4881}s.{4881}w.{4881}o.{4881}r.{4881}b ## The other twentytwo are generated similarly.
When each of these regexes is applied to the single long string, it will efficiently search the entire 3D matrix of the set dimensions and locate any occurrences of the specified word along the indicated direction. All that is required is record the positions at which any matches occur for each word.
It's then just a looping over the chosen search terms and the sets of dimensions. Given a reasonable minimum word length, there are surprisingly few 3D dimensions sets that make sense to search. Depending upon the number of words you choose to look for and a reasonably fast machine, it shouldn't take more than a few hours to do.
The hardest problem will be deciding which matches are "in close proximity". This is where some kind of 3D visualisation would be useful, and displaying an 80x60x64 or 40x30x255 matrix will be rather easier (and less expensive) than the behemoth you were talking about :)
Generating jpg with just the matched words, using an x/y offset and colour (shade) or perhaps font size to indicate Z-axis depth would be fairly easy to program and interpret. A nice rotatable, zoomable 3D plot would be even better, but quite difficult to program.
All that would be left then is to trying to ascribe meaning to those groupings found--but that's your task :)
Good luck.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. |