Perl: the Markov chain saw PerlMonks

### Re: 3D Dot "Graph" with motion

by moklevat (Priest)
 on Mar 19, 2008 at 13:45 UTC ( #674998=note: print w/replies, xml ) Need Help??

in reply to 3D Dot "Graph" with motion

Lu's suggestion to use PDL is what I would do if you want to run the visualization "live". I would go with moritz's approach if you want to store the visualization as an animation for later playback. Here is a brief example of a 3D visualization of points using PDL adapted from one of the examples from the docs. The nokeeptwiddling3d() function is what allows the changes in position to be plotted while the iteration happens. If you remove that then you can step through each change in position by pressing the "q" key.

```#!/usr/bin/perl -w

use strict;
use PDL;

use PDL::Graphics::TriD;

my        \$size = 25;
my        \$x = (xvals zeroes \$size+1,\$size+1) / \$size;
my        \$y = (yvals zeroes \$size+1,\$size+1) / \$size;
my        \$z = 0.5 + 0.5 * (sin(\$x*6.3) * sin(\$y*6.3)) ** 3;   # Bumps

my        \$r = \$x;
my        \$g = \$y;
my        \$b = \$z;

nokeeptwiddling3d();

for (1..50){

points3d [\$x,\$y,\$z], [\$r,\$g,\$b];  # Draw several colored dots
\$x+=\$y*\$z;
}

keeptwiddling3d();
points3d [\$x,\$y,\$z], [\$r,\$g,\$b];

Create A New User
Node Status?
node history
Node Type: note [id://674998]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2018-04-23 06:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My travels bear the most uncanny semblance to ...

Results (84 votes). Check out past polls.

Notices?